summaryrefslogtreecommitdiff
path: root/extra/nagios_check_failing_nodes.rb
blob: 1c81f668f4d46ddf4b1ffec4d4cd3c21cc1e3ea0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby

## contrib via https://github.com/ytti/oxidized/issues/67

require 'open-uri'
require 'json'

critical = false
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
  end
end

if critical
  puts 'Unable to backup: ' + critical_nodes.join(' ')
  exit 2
else
  puts 'Backup of all nodes completed successfully.'
  exit 0
end