]> andersk Git - moira.git/commitdiff
Add DCM to generate a list of all printers of type DORM or CLUSTER to be
authorzacheiss <zacheiss>
Tue, 31 Jan 2006 21:42:44 +0000 (21:42 +0000)
committerzacheiss <zacheiss>
Tue, 31 Jan 2006 21:42:44 +0000 (21:42 +0000)
monitored by nagios, and Makefile glue to install it.

gen/Makefile.in
gen/nagios-printers.gen [new file with mode: 0755]

index 6b90a16f8b57aa47a325637b5ff5599cc4eb7d28..0f732950f92bca7b612060cc6be73901f05889dd 100644 (file)
@@ -44,10 +44,11 @@ TARGET=     acl.gen boot.gen dhcp.gen directory.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.gen events.sh hesiod.sh ip-billing.gen \
-       ip-billing.sh ldap.gen longjobs.gen longjobs.sh mailhub.sh mailman.gen \
-       mailman.sh ndb.sh nfs.sh null.sh postoffice.sh print.sh sapprint.gen \
-       sapprint.sh spwatch.gen warehouse.sh winstats.gen winstats.sh www.sh zephyr.sh \
-       install_dirs install_quotas zero_quotas
+       ip-billing.sh ldap.gen longjobs.gen longjobs.sh mailhub.sh \
+       mailman.gen mailman.sh nagios-printers.gen ndb.sh nfs.sh null.sh \
+       postoffice.sh print.sh sapprint.gen sapprint.sh spwatch.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-printers.gen b/gen/nagios-printers.gen
new file mode 100755 (executable)
index 0000000..4c66cc9
--- /dev/null
@@ -0,0 +1,101 @@
+#!/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;
+
+$outfile = '/moira/dcm/nagios-printers.out';
+
+use DBI;
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+  || exit $MR_DBMS_ERR;
+
+$sth = $dbh->prepare("SELECT m.name FROM machine m, printers p " .
+                    "WHERE (p.type = 'DORM' OR p.type ='CLUSTER') " .
+                    "AND p.mach_id = m.mach_id")
+    || exit $MR_DBMS_ERR;
+
+$sth->execute || exit $MR_DBMS_ERR;
+
+umask 022;
+open(OUT, ">$outfile") || exit $MR_OCONFIG;
+print OUT "# This File is automatically generated by Moira.  Do not edit.\n";
+
+while (($name) = $sth->fetchrow_array) {
+    next if $name eq "[NONE]";
+    $name = lc($name);
+    push(@allprinters, $name);
+    print OUT <<"END";
+define host{
+       host_name               $name
+       alias                   $name
+       address                 $name
+       use                     generic-host
+       }
+
+define service{
+        host_name               $name
+        contact_groups          ops-printers
+        use                     ping-service
+        }
+
+define service{
+        host_name               $name
+        contact_groups          ops-printers
+        use                     hpjd-service
+        }
+
+define hostescalation{
+        host_name               $name
+        contact_groups          ops-printers
+        first_notification      2
+        last_notification       0
+        notification_interval   0
+        }
+
+define serviceescalation{
+        host_name               $name
+        contact_groups          ops-printers
+        service_description     PING
+        first_notification      2
+        last_notification       0
+        notification_interval   0
+        }
+
+define serviceescalation{
+        host_name               $name
+        contact_groups          ops-printers
+        service_description     HPJD
+        first_notification      2
+        last_notification       0
+        notification_interval   0
+        }
+
+END
+
+}
+
+print OUT <<END;
+define hostgroup{
+        hostgroup_name          printers
+        alias                   printers
+        contact_groups          ops-printers
+END
+
+print OUT "\tmembers\t\t";
+
+$maybecomma = "";
+foreach $printer (@allprinters) {
+    print OUT "$maybecomma$printer";
+    $maybecomma = ",";
+}
+
+print OUT "\n\t}\n\n";
+
+close(OUT);
+$dbh->disconnect;
+
+exit 0;
This page took 0.043088 seconds and 5 git commands to generate.