diff options
author | msil <michael.silas@sohonet.com> | 2018-09-07 11:13:46 +0100 |
---|---|---|
committer | ytti <saku@ytti.fi> | 2018-09-07 13:13:46 +0300 |
commit | 921a4a201b6ec12864a24310d669e07ce0a57c4e (patch) | |
tree | 79fab26b0eee52afa45a88230bd9cee2782daf84 /lib/oxidized/node.rb | |
parent | 40cd2ec8986d6c2040c725df8f6f84901cef6f2c (diff) |
Add configurable crashfile location and option to use hostnames
PR #1506
Diffstat (limited to 'lib/oxidized/node.rb')
-rw-r--r-- | lib/oxidized/node.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index 9dfeb19..e012b23 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -74,8 +74,11 @@ module Oxidized Oxidized.logger.send(level, '%s raised %s%s with msg "%s"' % [self.ip, err.class, resc, err.message]) return false rescue => err - file = Oxidized::Config::Crash + '.' + self.ip.to_s - open file, 'w' do |fh| + crashdir = Oxidized.config.crash.directory + crashfile = Oxidized.config.crash.hostnames? ? self.name : self.ip.to_s + FileUtils.mkdir_p(crashdir) unless File.directory?(crashdir) + + open File.join(crashdir, crashfile), 'w' do |fh| fh.puts Time.now.utc fh.puts err.message + ' [' + err.class.to_s + ']' fh.puts '-' * 50 |