diff options
author | Peter Palfrader <peter@palfrader.org> | 2005-09-02 16:17:26 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2005-09-02 16:17:26 +0000 |
commit | 95bd15d07b681613f2e845aca6c1c8349924b9c5 (patch) | |
tree | 873a88cc2509d27b36e54a4d6389c383082b2d35 /build-nagios | |
parent | 3a4fc7a1acf01489554ceff0e5a2b08a992cc737 (diff) |
Make it more general
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@11 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'build-nagios')
-rwxr-xr-x | build-nagios | 20 |
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 }" } |