From 99261121f25ac55f502436a0ace345b02e4a387a Mon Sep 17 00:00:00 2001 From: Antoine GUEVARA Date: Wed, 24 Jun 2015 16:29:12 +0200 Subject: Updated nagios_check_failing_nodes.rb --- extra/nagios_check_failing_nodes.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'extra') diff --git a/extra/nagios_check_failing_nodes.rb b/extra/nagios_check_failing_nodes.rb index 1c81f66..4436b1c 100644 --- a/extra/nagios_check_failing_nodes.rb +++ b/extra/nagios_check_failing_nodes.rb @@ -10,9 +10,11 @@ critical_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 end end -- cgit v1.2.1 From 50237f7d9044898fbee4526e22ba07f7cfaddc40 Mon Sep 17 00:00:00 2001 From: Antoine GUEVARA Date: Wed, 24 Jun 2015 16:34:47 +0200 Subject: Add [CRIT] & [OK] output --- extra/nagios_check_failing_nodes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'extra') diff --git a/extra/nagios_check_failing_nodes.rb b/extra/nagios_check_failing_nodes.rb index 4436b1c..848978d 100644 --- a/extra/nagios_check_failing_nodes.rb +++ b/extra/nagios_check_failing_nodes.rb @@ -19,9 +19,9 @@ json.each do |node| end if critical - puts 'Unable to backup: ' + critical_nodes.join(' ') + 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 -- cgit v1.2.1 From 069db4a8102993fd13b074473a2ca67e475bb2b1 Mon Sep 17 00:00:00 2001 From: Antoine GUEVARA Date: Wed, 24 Jun 2015 16:52:35 +0200 Subject: Added [WARN] which show the pending backups --- extra/nagios_check_failing_nodes.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'extra') diff --git a/extra/nagios_check_failing_nodes.rb b/extra/nagios_check_failing_nodes.rb index 848978d..27a5c66 100644 --- a/extra/nagios_check_failing_nodes.rb +++ b/extra/nagios_check_failing_nodes.rb @@ -6,7 +6,9 @@ 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| @@ -15,11 +17,17 @@ json.each do |node| critical_nodes << node['name'] critical = true end + else + pending_nodes << node['name'] + pending = true end end -if critical - puts '[CRIT] 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 '[OK] Backup of all nodes completed successfully.' -- cgit v1.2.1