Sha256: 556e5685315c4958bf6d227b23bbc835cc9599d78d8192b94278fd0899b65dc6

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 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|
  unless ARGV.empty?
    next if ARGV[0] != node['name']
  end
  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 '[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

2 entries across 2 versions & 1 rubygems

Version Path
oxidized-0.28.0 extra/nagios_check_failing_nodes.rb
oxidized-0.27.0 extra/nagios_check_failing_nodes.rb