]> andersk Git - moira.git/blame - gen/nagios-printers.gen
Don't tell nagios about deleted printers
[moira.git] / gen / nagios-printers.gen
CommitLineData
a1d1b496 1#!/moira/bin/perl -Tw
2
3# $Id$
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') " .
b06dd0d3 18 "AND p.mach_id = m.mach_id AND m.status=1")
a1d1b496 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 use generic-host
37 }
38
39define service{
40 host_name $name
41 contact_groups ops-printers
42 use ping-service
43 }
44
45define service{
46 host_name $name
47 contact_groups ops-printers
48 use hpjd-service
49 }
50
51define hostescalation{
52 host_name $name
53 contact_groups ops-printers
54 first_notification 2
55 last_notification 0
56 notification_interval 0
57 }
58
59define serviceescalation{
60 host_name $name
61 contact_groups ops-printers
62 service_description PING
63 first_notification 2
64 last_notification 0
65 notification_interval 0
66 }
67
68define serviceescalation{
69 host_name $name
70 contact_groups ops-printers
71 service_description HPJD
72 first_notification 2
73 last_notification 0
74 notification_interval 0
75 }
76
77END
78
79}
80
81print OUT <<END;
82define hostgroup{
83 hostgroup_name printers
84 alias printers
85 contact_groups ops-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;
This page took 0.096193 seconds and 5 git commands to generate.