[LON-CAPA-cvs] cvs: loncom / loncron lonsql /build CHECKRPMS /metadata_database searchcat.pl

www lon-capa-cvs@mail.lon-capa.org
Wed, 30 Jul 2003 16:49:27 -0000


www		Wed Jul 30 12:49:27 2003 EDT

  Modified files:              
    /loncom	loncron lonsql 
    /loncom/build	CHECKRPMS 
    /loncom/metadata_database	searchcat.pl 
  Log:
  Simple one-line status for cluster-wide automated reporting
  
  
Index: loncom/loncron
diff -u loncom/loncron:1.40 loncom/loncron:1.41
--- loncom/loncron:1.40	Tue Jul 29 17:00:21 2003
+++ loncom/loncron	Wed Jul 30 12:49:27 2003
@@ -131,6 +131,7 @@
 
 {
 my $fh=IO::File->new(">$statusdir/newstatus.html");
+my %simplestatus=();
 
 print $fh (<<ENDHEADERS);
 <html>
@@ -216,7 +217,7 @@
    } elsif ($usage>60) {
       $notices++;
    }
-   if ($usage>95) { $warnings++; $warnings++ }
+   if ($usage>95) { $warnings++; $warnings++; $simplestatus{'diskfull'}++; }
 }
 close (DFH);
 print $fh "</pre>";
@@ -350,6 +351,7 @@
 	}
     }
     if ($restartflag==1) {
+	$simplestatus{'lonsql'}='off';
 	$errors++;
 	         print $fh '<br><font color="red">Killall lonsql: '.
                     system('killall lonsql').' - ';
@@ -369,6 +371,7 @@
 	    sleep 2;
 	    if (kill 0 => $lonsqlpid) {
 		print $fh "<h3>lonsql at pid $lonsqlpid responding</h3>";
+		$simplestatus{'lonsql'}='restarted';
 	    } else {
 		$errors++; $errors++;
 		print $fh "<h3>lonsql at pid $lonsqlpid not responding</h3>";
@@ -446,6 +449,7 @@
    }
 } 
 if ($restartflag==1) {
+    $simplestatus{'lond'}='off';
    $errors++;
 	  print $fh '<br><font color="red">Killall lond: '.
                     system('killall lond').' - ';
@@ -464,6 +468,7 @@
        sleep 2;
        if (kill 0 => $londpid) {
           print $fh "<h3>lond at pid $londpid responding</h3>";
+	  $simplestatus{'lond'}='restarted';
        } else {
           $errors++; $errors++;
           print $fh "<h3>lond at pid $londpid not responding</h3>";
@@ -542,6 +547,7 @@
    }
 } 
 if ($restartflag==1) {
+    $simplestatus{'lonc'}='off';
    $errors++;
 	  print $fh '<br><font color="red">Killall lonc: '.
 	            system('killall lonc').' - ';
@@ -560,6 +566,7 @@
        sleep 2;
        if (kill 0 => $loncpid) {
           print $fh "<h3>lonc at pid $loncpid responding</h3>";
+	  $simplestatus{'lonc'}='restarted';
        } else {
           $errors++; $errors++;
           print $fh "<h3>lonc at pid $loncpid not responding</h3>";
@@ -638,6 +645,7 @@
    }
 } 
 if ($restartflag==1) {
+    $simplestatus{'lonhttpd'}='off';
    $errors++;
 	  print $fh '<br><font color="red">Killall lonhttpd: '.
 	            system('killall lonhttpd').' - ';
@@ -656,6 +664,7 @@
        sleep 2;
        if (kill 0 => $lonhttpdpid) {
           print $fh "<h3>lonhttpd at pid $lonhttpdpid responding</h3>";
+	  $simplestatus{'lonhttpd'}='restarted';
        } else {
           $errors++; $errors++;
           print $fh "<h3>lonhttpd at pid $lonhttpdpid not responding</h3>";
@@ -779,6 +788,7 @@
 print $fh "Total unsend messages: <b>$unsend</b><p>\n";
 $warnings=$warnings+5*$unsend;
 
+if ($unsend) { $simplestatus{'unsend'}=$unsend; }
 print $fh "<h3>Outgoing Buffer</h3>";
 
 open (DFH,"ls -lF $perlvar{'lonSockDir'}/delayed|");
@@ -796,10 +806,22 @@
 $date=localtime($now);
 print $fh "<hr>$date ($now)</body></html>\n";
 print "writing done\n";
+$fh->close();
 }
+if ($errors) { $simplestatus{'errors'}=$errors; }
+if ($warnings) { $simplestatus{'warnings'}=$warnings; }
+if ($notices) { $simplestatus{'notices'}=$notices; }
+$simplestatus{'time'}=time;
 
 rename ("$statusdir/newstatus.html","$statusdir/index.html");
-
+{
+my $sfh=IO::File->new(">$statusdir/loncron_simple.txt");
+foreach (keys %simplestatus) {
+    print $sfh $_.'='.$simplestatus{$_}.'&';
+}
+print $sfh "\n";
+$sfh->close();
+}
 if ($totalcount>200) {
    print "mailing\n";
    $emailto="$perlvar{'lonAdmEMail'}";
Index: loncom/lonsql
diff -u loncom/lonsql:1.56 loncom/lonsql:1.57
--- loncom/lonsql:1.56	Fri Jul 25 13:07:06 2003
+++ loncom/lonsql	Wed Jul 30 12:49:27 2003
@@ -3,7 +3,7 @@
 # The LearningOnline Network
 # lonsql - LON TCP-MySQL-Server Daemon for handling database requests.
 #
-# $Id: lonsql,v 1.56 2003/07/25 17:07:06 bowersj2 Exp $
+# $Id: lonsql,v 1.57 2003/07/30 16:49:27 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -251,6 +251,11 @@
     my $subj="LON: $perlvar{'lonHostID'} Cannot connect to database!";
     system("echo 'Cannot connect to MySQL database!' |".
            " mailto $emailto -s '$subj' > /dev/null");
+
+    open(SMP,'>/home/httpd/html/lon-status/mysql.txt');
+    print SMP 'time='.time.'&mysql=defunct'."\n";
+    close(SMP);
+
     exit 1;
 } else {
     $dbh->disconnect;
Index: loncom/build/CHECKRPMS
diff -u loncom/build/CHECKRPMS:1.16 loncom/build/CHECKRPMS:1.17
--- loncom/build/CHECKRPMS:1.16	Thu Jun 19 15:23:56 2003
+++ loncom/build/CHECKRPMS	Wed Jul 30 12:49:27 2003
@@ -119,6 +119,8 @@
 my $goodoutput; # ------------------------------------ good stuff was returned!
 my $reallygoodoutput; # ------------------------------- you are 100% up-to-date
 
+my $simplestatus='time='.time.'&';
+
 # ===================================================== Control flow of output.
 my $out = \*STDOUT; # Default: go to standard output (directly to terminal).
 
@@ -264,11 +266,13 @@
 if (!$goodoutput) # If never received any useable output, assume "no server".
   {
     print($out '**** ERROR **** Cannot find a working ftp server.'."\n");
+    $simplestatus.='status=fail';
     clean_exit($mode,$out,0);
   }
 elsif ($reallygoodoutput) # Everything is peachy keen and up-to-date already.
   {
     print($out $reallygoodoutput);
+    $simplestatus.='status=okay';
   }
 else # There are RPMs that need to be updated; show list to user.
   {
@@ -279,6 +283,7 @@
 
 END
     print($out $goodoutput); # Output the RPM list.
+    $simplestatus.='status=okay&rpmcount='.$rpmcount;
     if ($mode eq 'interactive')
       {
 	print($out <<END);
@@ -317,7 +322,15 @@
 sub clean_exit
   {
     my ($mode,$out,$code)=@_;
-
+#
+# Store simple status
+#
+    open(SMP,'>/home/httpd/html/lon-status/checkrpms.txt');
+    print SMP $simplestatus."\n";
+    close(SMP);
+#
+# Mail
+#
     if ($mode eq 'cronmail') # If cronmail mode, then mail LON-CAPA sys admin.
       {
         close(FOUT);
Index: loncom/metadata_database/searchcat.pl
diff -u loncom/metadata_database/searchcat.pl:1.35 loncom/metadata_database/searchcat.pl:1.36
--- loncom/metadata_database/searchcat.pl:1.35	Wed Jun 25 10:42:00 2003
+++ loncom/metadata_database/searchcat.pl	Wed Jul 30 12:49:27 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # searchcat.pl "Search Catalog" batch script
 #
-# $Id: searchcat.pl,v 1.35 2003/06/25 14:42:00 www Exp $
+# $Id: searchcat.pl,v 1.36 2003/07/30 16:49:27 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,6 +76,13 @@
 
 my @metalist;
 
+$simplestatus='';
+
+sub writesimple {
+    open(SMP,'>/home/httpd/html/lon-status/mysql.txt');
+    print SMP $simplestatus."\n";
+    close(SMP);
+}
 
 # ----------------------------------------------------- Un-Escape Special Chars
 
@@ -207,6 +214,7 @@
 
 open(LOG,'>'.$perlvar{'lonDaemons'}.'/logs/searchcat.log');
 print LOG '==== Searchcat Run '.localtime()."====\n\n";
+$simplestatus='time='.time.'&';
 my $dbh;
 # ------------------------------------- Make sure that database can be accessed
 {
@@ -214,8 +222,11 @@
 	    $dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0})
 	    ) { 
 	print LOG "Cannot connect to database!\n";
+	$simplestatus.='mysql=defunct';
+	&writesimple();
 	exit;
     }
+
     my $make_metadata_table = "CREATE TABLE IF NOT EXISTS metadata (".
         "title TEXT, author TEXT, subject TEXT, url TEXT, keywords TEXT, ".
         "version TEXT, notes TEXT, abstract TEXT, mime TEXT, language TEXT, ".
@@ -312,6 +323,7 @@
 $dbh->disconnect;
 print LOG "\n==== Searchcat completed ".localtime()." ====\n";
 close(LOG);
+&writesimple();
 exit 0;