From a1d1b4961792159c7eee2fe62ee12e877b74b468 Mon Sep 17 00:00:00 2001 From: zacheiss Date: Tue, 31 Jan 2006 21:42:44 +0000 Subject: [PATCH] Add DCM to generate a list of all printers of type DORM or CLUSTER to be monitored by nagios, and Makefile glue to install it. --- gen/Makefile.in | 9 ++-- gen/nagios-printers.gen | 101 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 4 deletions(-) create mode 100755 gen/nagios-printers.gen diff --git a/gen/Makefile.in b/gen/Makefile.in index 6b90a16f..0f732950 100644 --- a/gen/Makefile.in +++ b/gen/Makefile.in @@ -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 index 00000000..4c66cc91 --- /dev/null +++ b/gen/nagios-printers.gen @@ -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 <disconnect; + +exit 0; -- 2.45.1