Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 756a2b1
Showing
6 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.gem | ||
.bundle | ||
pkg/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in dynect-utils.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
dynect-utils (0.0.1) | ||
dynect_rest | ||
trollop | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
dynect_rest (0.4.0) | ||
json | ||
json | ||
rest-client | ||
rest-client | ||
json (1.6.5) | ||
mime-types (1.17.2) | ||
rest-client (1.6.7) | ||
mime-types (>= 1.16) | ||
trollop (1.16.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
dynect-utils! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env ruby | ||
# Nagios plugin to monitor the status of IP addresses in a GSLB region. | ||
|
||
require "rubygems" | ||
require "bundler/setup" | ||
|
||
require "dynect_rest" | ||
require "pp" | ||
require "trollop" | ||
|
||
progname = File.basename($0) | ||
|
||
opts = Trollop::options do | ||
opt :customer, "Dynect customer name", :short => "-c", :type => :string, | ||
:required => true | ||
opt :user, "Dynect user name", :short => "-u", :type => :string, | ||
:required => true | ||
opt :pass, "Dynect password", :short => "-p", :type => :string, | ||
:required => true | ||
opt :zone, "Zone name", :short => "-z", :type => :string, | ||
:required => true | ||
opt :record, "GSLB record name", :short => "-r", :type => :string, | ||
:required => true | ||
opt :region, "GSLB region", :short => "-R", :type => :string, | ||
:default => "global" | ||
end | ||
|
||
dyn = DynectRest.new(opts[:customer], opts[:user], opts[:pass], opts[:zone]) | ||
gslb = dyn.get("GSLB/#{opts[:zone]}/#{opts[:record]}") | ||
|
||
region = gslb["region"].select { |r| r["region_code"] == opts[:region] }.first | ||
if region.nil? | ||
puts "UNKNOWN: can't find region #{region}" | ||
exit 3 | ||
end | ||
|
||
down = {} | ||
region["pool"].each do |address| | ||
if address["status"] != "up" | ||
down[address["address"]] = address["status"] | ||
end | ||
end | ||
|
||
if down.length > 0 | ||
msg = down.collect { |addr, status| "#{addr}=#{status}" }.join("; ") | ||
puts "CRITICAL: GSLB addresses unhealthy: #{msg}" | ||
exit 2 | ||
end | ||
|
||
puts "OK: all GSLB addresses are healthy" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "dynect-utils" | ||
s.version = "0.0.1" | ||
s.authors = ["Pete Fritchman"] | ||
s.email = ["petef@databits.net"] | ||
s.homepage = "https://github.com/fetep/dynect-utils" | ||
s.summary = %q{Nagios plugin to monitor a DynECT GSLB region} | ||
|
||
s.rubyforge_project = "dynect-utils" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_runtime_dependency "dynect_rest" | ||
s.add_runtime_dependency "trollop" | ||
end |