]> andersk Git - moira.git/commitdiff
Colo hosts.
authorzacheiss <zacheiss>
Fri, 17 Aug 2007 15:26:40 +0000 (15:26 +0000)
committerzacheiss <zacheiss>
Fri, 17 Aug 2007 15:26:40 +0000 (15:26 +0000)
gen/Makefile.in
gen/nagios-colo.gen [new file with mode: 0755]
gen/nagios-colo.sh [new file with mode: 0644]

index 06475d0915b73d0c02b204ac5713422a2af842a2..b24ed0a06324b0860f573cbc634d10d4b65718c6 100644 (file)
@@ -45,10 +45,10 @@ TARGET=     acl.gen boot.gen dhcp.gen directory.gen events.gen hesiod.gen hosts.gen
 SCRIPTS=access.gen access.sh acl.sh aliases.sh boot.sh ca.gen calendar.gen \
        confluence.gen dhcp.sh events.sh hesiod.sh ip-billing.gen \
        ip-billing.sh ldap.gen longjobs.gen longjobs.sh mailhosts.gen mailhub.sh \
-       mailman.gen mailman.sh nagios-printers.gen nagios-printers.sh ndb.sh \
-       nfs.sh null.sh postoffice.sh print.sh sapprint.gen sapprint.sh \
-       spwatch.gen tsm.gen tsm.sh warehouse.gen warehouse.sh winstats.gen winstats.sh \
-       www.sh zephyr.sh install_dirs install_quotas zero_quotas
+       mailman.gen mailman.sh nagios-colo.gen nagios-colo.sh nagios-printers.gen \
+       nagios-printers.sh ndb.sh nfs.sh null.sh postoffice.sh print.sh sapprint.gen \
+       sapprint.sh spwatch.gen tsm.gen tsm.sh warehouse.gen warehouse.sh \
+       winstats.gen winstats.sh www.sh zephyr.sh install_dirs install_quotas zero_quotas
 
 .SUFFIXES: .pc .gen
 
diff --git a/gen/nagios-colo.gen b/gen/nagios-colo.gen
new file mode 100755 (executable)
index 0000000..2c9780f
--- /dev/null
@@ -0,0 +1,97 @@
+#!/moira/bin/perl -Tw
+
+# $Id$
+# The following exit codes are defined and MUST BE CONSISTENT with the
+# error codes the library uses:
+$MR_DBMS_ERR = 47836421;
+$MR_OCONFIG = 47836460;
+
+$outdir = '/moira/dcm/nagios-colo';
+
+use DBI;
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+    || exit $MR_DBMS_ERR;
+
+$sth0 = $dbh->prepare("SELECT l.list_id, m.name " .
+                      "FROM list l, machine m, serverhosts sh " .
+                      "WHERE sh.value3 = l.name AND sh.service = " .
+                     "'NAGIOS-COLO' AND m.mach_id = sh.mach_id")
+    || exit $MR_DBMS_ERR;
+$sth0->execute;
+
+while (($root_list_id, $hostname) = $sth0->fetchrow_array) {
+    umask 022;
+    open(OUT, ">$outdir/$hostname") || exit $MR_OCONFIG;
+    print OUT "# This file is automatically generated by Moira.  Do not edit.\n";
+    $sth = $dbh->prepare("SELECT m.name FROM machine m, imembers i " .
+                        "WHERE i.list_id = " . $dbh->quote($root_list_id) .
+                        "AND i.member_type = 'MACHINE' " .
+                        "AND i.member_id = m.mach_id AND i.direct = 1 ORDER BY m.name") 
+       || exit $MR_DBMS_ERR;
+    $sth->execute;
+
+    while (($name) = $sth->fetchrow_array) {
+       next if $name eq "[NONE]";
+       $name = lc($name);
+       push(@allcolohosts, $name);
+       print OUT <<END;
+define host{
+       host_name               $name
+       alias                   $name
+       address                 $name
+       use                     generic-host
+       }
+
+define service{
+       host_name               $name
+       contact_groups          ops
+       use                     ping-service
+       }
+
+define hostescalation{
+        host_name               $name
+        contact_groups          ops,dost
+        first_notification      2
+        last_notification       0
+        notification_interval   0
+        }
+
+define serviceescalation{
+        host_name               $name
+        contact_groups          ops,dost
+        service_description     PING
+        first_notification      2
+        last_notification       0
+        notification_interval   0
+        }
+
+END
+
+    }
+
+    print OUT <<END;
+define hostgroup{
+        hostgroup_name          colo-hosts
+        alias                   colo-hosts
+        contact_groups          dost
+END
+
+print OUT "\tmembers\t\t\t";
+
+$maybecomma = "";
+foreach $host (@allcolohosts) {
+    print OUT "$maybecomma$host";
+    $maybecomma = ",";
+}
+
+print OUT "\n\t}\n\n";
+
+close(OUT);
+}
+
+$dbh->disconnect;
+
+exit 0;
+
+
diff --git a/gen/nagios-colo.sh b/gen/nagios-colo.sh
new file mode 100644 (file)
index 0000000..c6451fd
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# $Id$
+
+file=/var/nagios/etc/moira-colo-hosts.cfg
+
+if [ -d /var/athena ] && [ -w /var/athena ]; then
+    exec >/var/athena/moira_update.log 2>&1
+else 
+    exec >/tmp/moira_update.log 2>&1
+fi
+
+chmod 644 $file
+
+exit 0
This page took 0.042011 seconds and 5 git commands to generate.