--- /dev/null
+#!/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;
+
--- /dev/null
+#!/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
+
+