Sha256: 956fbda699ecddb8fbf62b8491dbaf0364b9ba2a7275cfe8d8db030cfc51095b

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

#!/usr/bin/env ruby

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

require 'open-uri'
require 'json'

critical = false
pending = false
critical_nodes = []
pending_nodes = []

json = JSON.parse(open("http://localhost:8888/nodes.json").read)
json.each do |node|
  next if !ARGV.empty? && (ARGV[0] != node['name'])

  if node['last'].nil?
    pending_nodes << node['name']
    pending = true
  elsif node['last']['status'] != 'success'
    critical_nodes << node['name']
    critical = true
  end
end

if critical
  puts '[CRIT] Unable to backup: ' + critical_nodes.join(',')
  exit 2
elsif pending
  puts '[WARN] Pending backup: ' + pending_nodes.join(',')
  exit 1
else
  if ARGV.empty?
    puts '[OK] Backup of all nodes completed successfully.'
  else
    puts '[OK] Backup of node ' + ARGV[0] + ' completed successfully.'
  end
  exit 0
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
oxidized-0.30.1 extra/nagios_check_failing_nodes.rb
oxidized-0.30.0 extra/nagios_check_failing_nodes.rb
oxidized-0.29.1 extra/nagios_check_failing_nodes.rb
oxidized-0.29.0 extra/nagios_check_failing_nodes.rb