diff options
Diffstat (limited to 'extra/nagios_check_failing_nodes.rb')
-rw-r--r-- | extra/nagios_check_failing_nodes.rb | 22 |
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 |