]> andersk Git - moira.git/commitdiff
DCM to feed ICE9.
authorzacheiss <zacheiss>
Tue, 21 Aug 2001 06:50:17 +0000 (06:50 +0000)
committerzacheiss <zacheiss>
Tue, 21 Aug 2001 06:50:17 +0000 (06:50 +0000)
gen/Makefile.in
gen/ip-billing.gen [new file with mode: 0755]

index 9e076a0d086a925b3e7634bf7ba87b60452539a6..57770094ea849abfab5a18d7cf203c1b9e3fd504 100644 (file)
@@ -42,9 +42,9 @@ TARGET=       acl.gen boot.gen dhcp.gen directory.gen hesiod.gen hosts.gen \
        mailhub.gen ndb.gen network.gen nfs.gen pobox.gen \
        postoffice.gen print.gen warehouse.gen winad.gen www.gen zephyr.gen
 
-SCRIPTS=boot.sh ca.gen dhcp.sh hesiod.sh longjobs.gen mailhub.sh ndb.sh \
-       nfs.sh null.sh postoffice.sh print.sh sapprint.gen sapprint.sh \
-       spwatch.gen warehouse.sh www.sh zephyr.sh install_dirs \
+SCRIPTS=boot.sh ca.gen dhcp.sh hesiod.sh ip-billing.gen longjobs.gen \
+       mailhub.sh ndb.sh nfs.sh null.sh postoffice.sh print.sh sapprint.gen \
+       sapprint.sh spwatch.gen warehouse.sh www.sh zephyr.sh install_dirs \
        install_quotas zero_quotas
 
 .SUFFIXES: .pc .gen
diff --git a/gen/ip-billing.gen b/gen/ip-billing.gen
new file mode 100755 (executable)
index 0000000..723e7e4
--- /dev/null
@@ -0,0 +1,36 @@
+#!/moira/bin/perl
+
+# $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;
+
+$outfile = '/moira/dcm/ip-billing.out';
+
+use DBI;
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+  || exit $MR_DBMS_ERR;
+
+$sth = $dbh->prepare("SELECT m.address, m.location, m.account_number, " .
+                    "m.name, m.contact FROM machine m, subnet s WHERE " .
+                    "m.status = 1 and m.snet_id = s.snet_id " .
+                    "AND s.status = 1") || exit $MR_DBMS_ERR;
+
+$sth->execute || exit $MR_DBMS_ERR;
+
+umask 022;
+open(OUT, ">$outfile") || exit $MR_OCONFIG;
+
+while (($address, $location, $accountnumber, $hostname, $contact) =
+       $sth->fetchrow_array) {
+    $row= "$address\t$location\t$accountnumber\t$hostname\t$contact\n";
+    $row =~ s/\0//g;
+    print OUT $row;
+}
+
+close(OUT);
+$dbh->disconnect;
+
+exit 0;
This page took 0.062339 seconds and 5 git commands to generate.