Skip to content

Instantly share code, notes, and snippets.

@FlorianHeigl
Created June 25, 2023 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FlorianHeigl/0062fa1590fd0576e8d40ae053ec3230 to your computer and use it in GitHub Desktop.
Save FlorianHeigl/0062fa1590fd0576e8d40ae053ec3230 to your computer and use it in GitHub Desktop.
Oxidized nagios check
#!/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
@FlorianHeigl
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment