Browse files

Initial installation of update_dbcentral

  • Loading branch information...
1 parent 0ed9dbc commit 0bf29ad17d9071849859a1c4b6cfd0de16985f28 @flvernon flvernon committed Jan 26, 2012
View
7 bin/usarray/update_dbcentral/Makefile
@@ -0,0 +1,7 @@
+BIN=update_dbcentral
+PF=update_dbcentral.pf
+MAN1=update_dbcentral.1
+
+include $(ANTELOPEMAKE)
+DIRS=
+
View
64 bin/usarray/update_dbcentral/update_dbcentral.1
@@ -0,0 +1,64 @@
+.TH UPDATE_DBCENTRAL 1 "$Date$"
+.SH NAME
+update_dbcentral \- Makes sure dbcentral is consistent with event dbs and rt database
+.SH SYNOPSIS
+.nf
+\fBupdate_dbcentral \fP [-v] [-V] [-n] [-p \fIpf\fP] \fIdbcentral\fP
+.fi
+.SH DESCRIPTION
+\fBupdate_dbcentral\fP updates \fIdbcentral\fP to be consistent with the event dbs and the rt database
+
+.LP
+
+.SH OPTIONS
+.IP -v
+verbose
+.IP -V
+Extremely verbose. Used for debugging purposes only.
+.IP "-p parameter_file"
+Name of parameter file to use. $PFPATH is searched to find parameter file.
+The default parameter file is \fBupdate_dbcentral\fP.
+
+.SH ENVIRONMENT
+needs to have sourced $ANTELOPE/setup.csh.
+.SH PARAMETER FILE
+.in 2c
+.ft CW
+.nf
+.ne 7
+.IP evcluster
+event cluster name for dbcentral
+.IP rtcluster
+rt cluster name for dbcentral
+.IP evdirbase
+Path name for directory base for wfdiscs of monthly waveform data.
+.fi
+.ft R
+.in
+.SH EXAMPLE PARAMETER FILE
+.in 2c
+.ft CW
+.nf
+
+evcluster usarray # event cluster name for dbcentral
+
+rtcluster usarray_rt # rt cluster name for dbcentral
+
+evdirbase /anf/TA/dbs/event_dbs # Directory base path for monthly dbs
+
+.fi
+.ft R
+.in
+.SH RETURN VALUES
+0 if successful, 1 if not.
+.SH "SEE ALSO"
+.nf
+time_slice_db(1)
+monthly_wfs(1)
+.fi
+.SH "BUGS AND CAVEATS"
+This program is designed to be used with \fBtime_slice_db\fP and \fBmonthly_wfs\fP.
+.LP
+.SH AUTHOR
+Frank Vernon
+.br
View
8 bin/usarray/update_dbcentral/update_dbcentral.pf
@@ -0,0 +1,8 @@
+evcluster usarray # event cluster name for dbcentral
+
+rtcluster usarray_rt # rt cluster name for dbcentral
+
+evdirbase /anf/TA/dbs/event_dbs # Directory base path for monthly dbs
+
+
+
View
111 bin/usarray/update_dbcentral/update_dbcentral.xpl
@@ -0,0 +1,111 @@
+#
+# program needs:
+#
+ use Getopt::Std ;
+ use strict ;
+ use Datascope ;
+ use archive ;
+ use timeslice ;
+ use utilfunct ;
+
+ our ( $pgm, $host );
+ our ( $opt_v, $opt_V, $opt_n, $opt_p );
+ our ( %pf );
+
+{ # Main program
+
+ my ( $Pf, $cmd, $dir, $problems, $dbcentral, $stime, $subject, $time, $usage );
+ my ( @db, @dirs );
+#
+# Program setup
+#
+ $pgm = $0 ;
+ $pgm =~ s".*/"" ;
+ elog_init( $pgm, @ARGV );
+ $cmd = "\n$0 @ARGV" ;
+
+ if ( ! getopts('vVnp:') || @ARGV != 1 ) {
+ $usage = "\n\n\nUsage: $0 [-v] [-V] [-n] " ;
+ $usage .= "[-p pf] " ;
+ $usage .= "dbcentral \n\n" ;
+ elog_notify( $cmd ) ;
+ elog_die ( $usage ) ;
+ }
+
+ elog_notify( $cmd ) ;
+ $stime = strydtime( now() ) ;
+ chop ( $host = `uname -n` ) ;
+ elog_notify ( "\nstarting execution on $host $stime\n\n" ) ;
+
+ $Pf = $opt_p || $pgm ;
+
+ $dbcentral = $ARGV[0] ;
+
+ %pf = &getparam( $Pf );
+
+ $opt_v = defined($opt_V) ? $opt_V : $opt_v ;
+
+ if (system_check(0)) {
+ $subject = "Problems - $pgm $host Ran out of system resources";
+ elog_die( "\n$subject" );
+ }
+ $problems = 0;
+
+ $dir = &get_last_ev_dir( ) ;
+
+ elog_notify ( "\ndir $dir" ) if $opt_v ;
+
+ $dir =~ s/_// ;
+
+ $time = &next_month ( $dir ) ;
+ $time = &yearmonth2epoch ( $time ) ;
+
+ @db = dbopen( $dbcentral, "r+" ) ;
+
+ @db = dblookup( @db, 0, "clusters", 0, 0 ) ;
+
+ $db[3] = dbfind( @db, "clustername =~ /$pf{rtcluster}/", 0 ) ;
+
+ dbputv ( @db, "time", $time ) ;
+
+ $db[3] = dbfind( @db, "clustername =~ /$pf{evcluster}/", 0 ) ;
+
+ dbputv ( @db, "time", $time - 0.001 ) ;
+
+ dbclose ( @db ) ;
+
+#
+# Finish program
+#
+ $stime = strydtime(now());
+
+ if ( $problems ) {
+ elog_notify ("completed $stime\n\n");
+ $subject = "Problems - $pgm $host" ;
+ elog_die("\n$subject") ;
+ }
+
+ elog_notify ("completed successfully $stime\n\n");
+
+ $subject = sprintf("Success $pgm $host ");
+ elog_notify ($subject);
+
+ exit( 0 );
+}
+
+sub get_last_ev_dir { # $dir = &get_last_ev_dir( ) ;
+ my ( $dir ) ;
+ my ( @dirs ) ;
+
+ @dirs = () ;
+
+ elog_debug ( "$pf{evdirbase}" ) if $opt_V ;
+ opendir( DIR, "$pf{evdirbase}" ) ;
+ @dirs = sort { $b cmp $a } ( grep { /^20[0-9][0-9]_[0-2][0-9]$/ } readdir( DIR ) ) ;
+ closedir( DIR ) ;
+
+ elog_debug ( "dirs @dirs" ) if $opt_V ;
+
+ return ( $dirs[0] ) ;
+}
+

0 comments on commit 0bf29ad

Please sign in to comment.