source: trunk/third/moira/gen/nagios-printers.gen @ 23740

Revision 23740, 2.4 KB checked in by broder, 15 years ago (diff)
In moira: * New CVS snapshot (Trac: #195) * Drop patches that have been incorporated upstream. * Update to build without krb4 on systems that no longer have it. This doesn't build yet on squeeze, which lacks a krb4 library, but I'm committing now before I start hacking away at a patch to fix that.
  • Property svn:executable set to *
Line 
1#!/moira/bin/perl -Tw
2
3# $Id: nagios-printers.gen,v 1.3 2008-04-17 17:24:36 zacheiss Exp $
4# The following exit codes are defined and MUST BE CONSISTENT with the
5# error codes the library uses:
6$MR_DBMS_ERR = 47836421;
7$MR_OCONFIG = 47836460;
8
9$outfile = '/moira/dcm/nagios-printers.out';
10
11use DBI;
12
13$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
14  || exit $MR_DBMS_ERR;
15
16$sth = $dbh->prepare("SELECT m.name FROM machine m, printers p " .
17                     "WHERE (p.type = 'DORM' OR p.type ='CLUSTER') " .
18                     "AND p.mach_id = m.mach_id AND m.status=1")
19    || exit $MR_DBMS_ERR;
20
21$sth->execute || exit $MR_DBMS_ERR;
22
23umask 022;
24open(OUT, ">$outfile") || exit $MR_OCONFIG;
25print OUT "# This File is automatically generated by Moira.  Do not edit.\n";
26
27while (($name) = $sth->fetchrow_array) {
28    next if $name eq "[NONE]";
29    $name = lc($name);
30    push(@allprinters, $name);
31    print OUT <<"END";
32define host{
33        host_name               $name
34        alias                   $name
35        address                 $name
36        contact_groups          ops-printers
37        use                     generic-host
38        }
39
40define service{
41        host_name               $name
42        contact_groups          ops-printers
43        use                     ping-service
44        }
45
46define service{
47        host_name               $name
48        contact_groups          ops-printers
49        use                     hpjd-service
50        }
51
52define hostescalation{
53        host_name               $name
54        contact_groups          ops-printers
55        first_notification      2
56        last_notification       0
57        notification_interval   0
58        }
59
60define serviceescalation{
61        host_name               $name
62        contact_groups          ops-printers
63        service_description     PING
64        first_notification      2
65        last_notification       0
66        notification_interval   0
67        }
68
69define serviceescalation{
70        host_name               $name
71        contact_groups          ops-printers
72        service_description     HPJD
73        first_notification      2
74        last_notification       0
75        notification_interval   0
76        }
77
78END
79
80}
81
82print OUT <<END;
83define hostgroup{
84        hostgroup_name          printers
85        alias                   printers
86END
87
88print OUT "\tmembers\t\t";
89
90$maybecomma = "";
91foreach $printer (@allprinters) {
92    print OUT "$maybecomma$printer";
93    $maybecomma = ",";
94}
95
96print OUT "\n\t}\n\n";
97
98close(OUT);
99$dbh->disconnect;
100
101exit 0;
Note: See TracBrowser for help on using the repository browser.