summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2015-06-24 18:05:36 +0300
committerytti <saku@ytti.fi>2015-06-24 18:05:36 +0300
commit441551400fb70ef93833917802bf799811ace7d4 (patch)
tree7af8b855f12ad7723cd88fdf3f11a7d3011d9687
parent9c3aa94f415503ab238b8ceed7c36f80b9e986ca (diff)
parent069db4a8102993fd13b074473a2ca67e475bb2b1 (diff)
Merge pull request #139 from darkounet/updated_check
Updated nagios_check_failing_nodes.rb
-rw-r--r--extra/nagios_check_failing_nodes.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/extra/nagios_check_failing_nodes.rb b/extra/nagios_check_failing_nodes.rb
index 1c81f66..27a5c66 100644
--- a/extra/nagios_check_failing_nodes.rb
+++ b/extra/nagios_check_failing_nodes.rb
@@ -6,20 +6,30 @@ require 'open-uri'
require 'json'
critical = false
+pending = false
critical_nodes = []
+pending_nodes = []
json = JSON.load(open("http://localhost:8888/nodes.json"))
json.each do |node|
- if node['last']['status'] != 'success'
- critical_nodes << node['name']
- critical = true
+ if not node['last'].nil?
+ if node['last']['status'] != 'success'
+ critical_nodes << node['name']
+ critical = true
+ end
+ else
+ pending_nodes << node['name']
+ pending = true
end
end
-if critical
- puts 'Unable to backup: ' + critical_nodes.join(' ')
+if pending
+ puts '[WARN] Pending backup: ' + pending_nodes.join(',')
+ exit 1
+elsif critical
+ puts '[CRIT] Unable to backup: ' + critical_nodes.join(',')
exit 2
else
- puts 'Backup of all nodes completed successfully.'
+ puts '[OK] Backup of all nodes completed successfully.'
exit 0
end