--- loncom/build/Attic/CHECKRPMS.default 2002/11/04 02:53:07 1.10 +++ loncom/build/Attic/CHECKRPMS.default 2003/07/30 16:49:27 1.17 @@ -111,7 +111,7 @@ my @serverpaths_to_try = ); # -------------------------------------------- Use check-rpms command this way. -my $checkcommand = 'check-rpms '.$download.' --rpmuser www -ftp'; +my $checkcommand = 'check-rpms -nk '.$download.' --rpmuser www -ftp'; my $FTPSERVER; # ------------------------- the server portion of the serverpath my $FTPUPDATES; # ----------------------------- the actual update root location @@ -119,6 +119,8 @@ my @rpms; # ---------------------------- 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). @@ -195,7 +197,7 @@ SERVERLOOP: foreach my $serverpath (@ser $FTPSERVER_noauth=~s/^.*?\@//; print($out "Trying $FTPSERVER_noauth...\n"); # Notify of attempts with ip name. - `ping -c 1 $FTPSERVER_noauth 2>/dev/null`; # Ping ftp server (you there?). + `ping -c 1 -w 10 $FTPSERVER_noauth 2>/dev/null`;#Ping ftp server (u there?) if ($?==0) # If the ftp server can be pinged. { print($out "$FTPSERVER found...\n"); # Tell user ftp server is found. @@ -264,11 +266,13 @@ END 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 @@ the list below. THIS IS IMPORTANT FOR S END print($out $goodoutput); # Output the RPM list. + $simplestatus.='status=okay&rpmcount='.$rpmcount; if ($mode eq 'interactive') { print($out </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); + # Read in configuration to get e-mail addresses. my $perlvarref = read_conf('loncapa.conf'); my %perlvar = %{$perlvarref}; @@ -329,12 +343,32 @@ sub clean_exit delete $perlvar{'lonSqlAccess'}; # remove since sensitive # Set metadata for the e-mail. - my $emailto = "$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}"; -# my $emailto = "sharrison\@users.sourceforge.net"; - my $subj="LON: $perlvar{'lonHostID'}, RPMS to upgrade"; - system( - 'metasend -b -t '.$emailto.' -s '. - "'$subj' -f /tmp/CHECKRPMS.$$ -m text/plain"); + my $emailto = "$perlvar{'lonAdmEMail'}"; + + my $subj=$perlvar{'lonHostID'}.', RPMS to upgrade'; + + # Make the e-mail's subject header to describe whether up-to-date. + if ($reallygoodoutput) + { + $subj = 'happy_lon: '.$subj; # Machine is up-to-date. + } + else + { + $subj = 'ALERT_lon: '.$subj; # There are out-of-date RPMs. + } + + # Send the e-mail. + my $date = `date +"\%e"`; # Always send a day after the "Ides" or after + # the beginning of a month. (In other words, + # send an e-mail every two weeks regardless.) + if (!$reallygoodoutput or + $date == 2 or + $date == 16) + { + system( + 'metasend -b -t '.$emailto.' -s '. + "'$subj' -f /tmp/CHECKRPMS.$$ -m text/plain"); + } } print($out <