#!/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 AND m.status=1") || 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 contact_groups ops-printers 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;