summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild-nagios20
1 files changed, 11 insertions, 9 deletions
diff --git a/build-nagios b/build-nagios
index 99234b8..8743209 100755
--- a/build-nagios
+++ b/build-nagios
@@ -4,8 +4,10 @@
require "yaml"
-ORG="came"
-CONTACTGROUP="cameadmins"
+ORG="relativity"
+SHORTORG="rela"
+CONTACTGROUP="weaselgroup"
+GENERATED_PREFIX="/etc/NOREPLY/generated/nagios/"
class Nrpe
def initialize
@@ -15,7 +17,7 @@ class Nrpe
def make_name( name, check )
name = name.tr_s("^a-zA-Z", "_").gsub("process", "ps")
- result = "#{ ORG }_" + name[0,18]
+ result = "#{ SHORTORG }_" + name[0,19]
hash = ''
skew = ''
@@ -57,7 +59,7 @@ end
config = YAML::load( File.open( 'nagios-master.cfg' ) )
%w{auto-hosts.cfg auto-hostgroups.cfg auto-services.cfg auto-dependencies.cfg}.each{ |file|
- File.delete("#{file}") if FileTest.file?("#{file}")
+ File.delete(GENERATED_PREFIX+"#{file}") if FileTest.file?(GENERATED_PREFIX+"#{file}")
}
#################################
@@ -87,7 +89,7 @@ config['servers'].each_key{ |name|
#######
# Hosts and Hostgroups
-f = File.new("auto-hosts.cfg", "w")
+f = File.new(GENERATED_PREFIX+"auto-hosts.cfg", "w")
config['servers'].each_pair{ |name, server|
f.puts "define host{"
f.puts " use generic-host"
@@ -100,7 +102,7 @@ config['servers'].each_pair{ |name, server|
f.puts
}
-f = File.new("auto-hostgroups.cfg", "w")
+f = File.new(GENERATED_PREFIX+"auto-hostgroups.cfg", "w")
config['hostgroups'].each_pair{ |name, hg|
next if hg['private']
f.puts "define hostgroup{"
@@ -164,8 +166,8 @@ def addService(hosts, service, f, deps)
end
-f = File.new("auto-services.cfg", "w")
-deps = File.new("auto-dependencies.cfg", "w")
+f = File.new(GENERATED_PREFIX+"auto-services.cfg", "w")
+deps = File.new(GENERATED_PREFIX+"auto-dependencies.cfg", "w")
config['services'].each{ |service|
throw "Empty service or service not a hash" unless service.kind_of?(Hash)
throw "nrpe, check, and remotecheck are mutually exclusive in service #{service['name']}" if
@@ -219,7 +221,7 @@ config['services'].each{ |service|
end
}
-f = File.new("nrpe_#{ ORG }.cfg", "w")
+f = File.new(GENERATED_PREFIX+"nrpe_#{ ORG }.cfg", "w")
$nrpe.checks.each_pair{ |name, check|
f.puts "command[#{ name }]=#{ check }"
}