]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | use 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 | ||
23 | umask 022; | |
24 | open(OUT, ">$outfile") || exit $MR_OCONFIG; | |
25 | print OUT "# This File is automatically generated by Moira. Do not edit.\n"; | |
26 | ||
27 | while (($name) = $sth->fetchrow_array) { | |
28 | next if $name eq "[NONE]"; | |
29 | $name = lc($name); | |
30 | push(@allprinters, $name); | |
31 | print OUT <<"END"; | |
32 | define host{ | |
33 | host_name $name | |
34 | alias $name | |
35 | address $name | |
92bd4d0d | 36 | contact_groups ops-printers |
a1d1b496 | 37 | use generic-host |
38 | } | |
39 | ||
40 | define service{ | |
41 | host_name $name | |
42 | contact_groups ops-printers | |
43 | use ping-service | |
44 | } | |
45 | ||
46 | define service{ | |
47 | host_name $name | |
48 | contact_groups ops-printers | |
49 | use hpjd-service | |
50 | } | |
51 | ||
52 | define hostescalation{ | |
53 | host_name $name | |
54 | contact_groups ops-printers | |
55 | first_notification 2 | |
56 | last_notification 0 | |
57 | notification_interval 0 | |
58 | } | |
59 | ||
60 | define 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 | ||
69 | define 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 | ||
78 | END | |
79 | ||
80 | } | |
81 | ||
82 | print OUT <<END; | |
83 | define hostgroup{ | |
84 | hostgroup_name printers | |
85 | alias printers | |
a1d1b496 | 86 | END |
87 | ||
88 | print OUT "\tmembers\t\t"; | |
89 | ||
90 | $maybecomma = ""; | |
91 | foreach $printer (@allprinters) { | |
92 | print OUT "$maybecomma$printer"; | |
93 | $maybecomma = ","; | |
94 | } | |
95 | ||
96 | print OUT "\n\t}\n\n"; | |
97 | ||
98 | close(OUT); | |
99 | $dbh->disconnect; | |
100 | ||
101 | exit 0; |