#!/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; $outdir = '/moira/dcm/nagios-colo'; use DBI; $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR; $sth0 = $dbh->prepare("SELECT l.list_id, m.name " . "FROM list l, machine m, serverhosts sh " . "WHERE sh.value3 = l.name AND sh.service = " . "'NAGIOS-COLO' AND m.mach_id = sh.mach_id") || exit $MR_DBMS_ERR; $sth0->execute; while (($root_list_id, $hostname) = $sth0->fetchrow_array) { umask 022; open(OUT, ">$outdir/$hostname") || exit $MR_OCONFIG; print OUT "# This file is automatically generated by Moira. Do not edit.\n"; $sth = $dbh->prepare("SELECT m.name FROM machine m, imembers i " . "WHERE i.list_id = " . $dbh->quote($root_list_id) . "AND i.member_type = 'MACHINE' AND m.status = 1 " . "AND i.member_id = m.mach_id AND i.direct = 1 ORDER BY m.name") || exit $MR_DBMS_ERR; $sth->execute; while (($name) = $sth->fetchrow_array) { next if $name eq "[NONE]"; $name = lc($name); push(@allcolohosts, $name); print OUT <disconnect; exit 0;