]> andersk Git - moira.git/commitdiff
winstats DCM and Makefile glue to install it.
authorzacheiss <zacheiss>
Mon, 15 Dec 2003 20:16:23 +0000 (20:16 +0000)
committerzacheiss <zacheiss>
Mon, 15 Dec 2003 20:16:23 +0000 (20:16 +0000)
gen/Makefile.in
gen/winstats.gen [new file with mode: 0755]
gen/winstats.sh [new file with mode: 0644]

index 591996e201ccc57e7b193221a3e6c47a3f31ae17..97dc9c99e7edb0590415855f6b4142e80f232ee0 100644 (file)
@@ -46,7 +46,8 @@ SCRIPTS=access.gen access.sh acl.sh aliases.sh boot.sh ca.gen calendar.gen dhcp.
        events.gen events.sh hesiod.sh ip-billing.gen ip-billing.sh longjobs.gen \
        longjobs.sh mailhub.sh mailman.gen mailman.sh ndb.sh nfs.sh null.sh \
        postoffice.sh print.sh sapprint.gen sapprint.sh spwatch.gen stellar.gen \
-       stellar.sh warehouse.sh www.sh zephyr.sh install_dirs install_quotas zero_quotas
+       stellar.sh warehouse.sh winstats.gen winstats.sh www.sh zephyr.sh \
+       install_dirs install_quotas zero_quotas
 
 .SUFFIXES: .pc .gen
 
diff --git a/gen/winstats.gen b/gen/winstats.gen
new file mode 100755 (executable)
index 0000000..cefd8ee
--- /dev/null
@@ -0,0 +1,79 @@
+#!/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;
+
+$ENV{PATH} = "/bin:/usr/bin:/sbin:/usr/sbin";
+
+$outdir = '/moira/dcm/winstats';
+$outfile = '/moira/dcm/winstats.out';
+
+use DBI;
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+    || exit $MR_DBMS_ERR;
+
+umask 022;
+
+# mcntmap table
+$sth = $dbh->prepare("SELECT mach_id, cnt_id FROM mcntmap")
+    || exit $MR_DBMS_ERR;
+
+$sth->execute || exit $MR_DBMS_ERR;
+
+open(OUT, ">$outdir/mcntmap") || exit $MR_OCONFIG;
+
+while (($mach_id, $cnt_id) = $sth->fetchrow_array) {
+    $row = "$mach_id\t$cnt_id\n";
+    $row =~ s/\0//g;
+    print OUT $row;
+}
+close(OUT);
+
+# machine table
+$sth = $dbh->prepare("SELECT m.name, m.mach_id FROM machine m, " .
+                   "mcntmap mc WHERE m.mach_id = mc.mach_id")
+    || exit $MR_DBMS_ERR;
+
+$sth->execute || exit $MR_DBMS_ERR;
+
+open(OUT, ">$outdir/machine") || exit $MR_OCONFIG;
+
+while (($name, $mach_id) = $sth->fetchrow_array) {
+    $row = "$name\t$mach_id\n";
+    $row =~ s/\0//g;
+    print OUT $row;
+}
+close(OUT);
+
+# containers table
+$sth = $dbh->prepare("SELECT name, cnt_id, list_id, publicflg, description, " .
+                    "location, contact, acl_type, acl_id, memacl_type, memacl_id, " .
+                    "modtime, modby, modwith FROM containers")
+    || exit $MR_DBMS_ERR;
+
+$sth->execute || exit $MR_DBMS_ERR;
+
+open(OUT, ">$outdir/containers") || exit $MR_OCONFIG;
+
+while (($name, $cnt_id, $list_id, $publicflg, $description, $location, $contact,
+       $acl_type, $acl_id, $memacl_type, $memacl_id, $modtime, $modby, $modwith)
+       = $sth->fetchrow_array) {
+    $row = "$name\t$cnt_id\t$list_id\t$publicflg\t$description\t$location\t$contact\t$acl_type\t$acl_id\t$memacl_type\t$memacl_id\t$modtime\t$modby\t$modwith\n";
+    $row =~ s/\0//g;
+    print OUT $row;
+}
+close(OUT);
+
+# generate tar file
+
+system("cd $outdir && tar cf $outfile .") == 0 || exit $MR_OCONFIG;
+
+$dbh->disconnect;
+
+exit 0;
+
diff --git a/gen/winstats.sh b/gen/winstats.sh
new file mode 100644 (file)
index 0000000..6bda31b
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+dir=/var/ops/populate/stats
+tarfile=/var/tmp/winstats.out
+
+PATH="/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc"
+
+if [ -d /var/athena ] && [ -w /var/athena ]; then
+    exec >/var/athena/moira_update.log 2>&1
+else
+    exec >/tmp/moira_update.log 2>&1
+fi
+
+# The following exit codes are defined and MUST BE CONSISTENT with the
+# error codes the library uses:
+MR_MISSINGFILE=47836473
+MR_TARERR=47836476
+
+if [ ! -f $tarfile ]; then
+    exit $MR_MISSINGFILE
+fi
+
+cd $dir
+tar xf $tarfile
+
+if [ $? != 0 ]; then
+    exit $MR_TARERR;
+fi
+
+chmod 644 *
+
+rm -f $0
+exit 0
+
+
This page took 0.044894 seconds and 5 git commands to generate.