summaryrefslogtreecommitdiff
path: root/lib/oxidized/node.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-02-28 23:05:20 +0200
committerSaku Ytti <saku@ytti.fi>2014-02-28 23:05:20 +0200
commit65df741de7bdd837dc64f40b1fd3083cc98c9ad3 (patch)
tree133e0cfa13d5f9fbe303ebe99373bf62001d829d /lib/oxidized/node.rb
parent554ed10e16544c76447cc4e97865055eeef47482 (diff)
Rescue all StandardError from modules
If module crashes with unexpected error class, rescue it, and write it backtrace Also log if unknown model is attempted instead of crash
Diffstat (limited to 'lib/oxidized/node.rb')
-rw-r--r--lib/oxidized/node.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb
index 6c7b3aa..3027ccd 100644
--- a/lib/oxidized/node.rb
+++ b/lib/oxidized/node.rb
@@ -53,6 +53,15 @@ module Oxidized
end
Log.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|
+ fh.puts Time.now.utc
+ fh.puts err.message + ' [' + err.class.to_s + ']'
+ fh.puts '-' * 50
+ fh.puts err.backtrace
+ end
+ Log.error '%s raised %s with msg "%s", %s saved' % [self.ip, err.class, err.message, file]
end
end