]> andersk Git - moira.git/blame - gen/nagios-printers.gen
Command line printer manipulation client, and build goo.
[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
92bd4d0d 36 contact_groups ops-printers
a1d1b496 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
a1d1b496 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.077094 seconds and 5 git commands to generate.