Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nagios monitoring script #67

Closed
sts opened this issue Dec 21, 2014 · 1 comment
Closed

Nagios monitoring script #67

sts opened this issue Dec 21, 2014 · 1 comment

Comments

@sts
Copy link
Contributor

sts commented Dec 21, 2014

The following is a small script which we wrote to add failing oxidized nodes to our monitoring system. Might be worth to include it.

#!/usr/bin/env ruby

require 'open-uri'
require 'json'

critical = false
critical_nodes = []

json = JSON.load(open("http://localhost:8888/nodes.json"))
json.each do |node|
    last = node['last']
    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
@ytti ytti closed this as completed in 5fe82dc Feb 22, 2015
@afenioux
Copy link

afenioux commented Dec 12, 2019

Hi all,
I've made some adjustments to this script, I hope this could help :

#!/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 = []

begin
 json = JSON.parse(open("http://localhost:8888/nodes.json").read)
rescue
  puts '[CRIT] Unable to connect'
  exit 2
end
json.each do |node|
  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
  puts '[OK] Backup of all nodes completed successfully.'
  exit 0
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants