--- loncom/loncron 2021/01/30 22:25:53 1.103.2.9 +++ loncom/loncron 2024/07/01 12:02:42 1.103.2.13 @@ -2,7 +2,7 @@ # Housekeeping program, started by cron, loncontrol and loncron.pl # -# $Id: loncron,v 1.103.2.9 2021/01/30 22:25:53 raeburn Exp $ +# $Id: loncron,v 1.103.2.13 2024/07/01 12:02:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,6 +43,8 @@ use IO::File; use IO::Socket; use HTML::Entities; use Getopt::Long; +use GDBM_File qw(GDBM_READER); +use Storable qw(thaw); use File::ReadBackwards; use File::Copy; use Sys::Hostname::FQDN(); @@ -227,6 +229,21 @@ sub log_machine_info { &log($fh,'

Machine Information

'); &log($fh,"

loadavg

"); + my $cpucount; + if (open(PIPE,"lscpu |grep '^CPU(s)' 2>&1 |")) { + my $info = ; + chomp($info); + ($cpucount) = ($info =~ /^\QCPU(s):\E\s+(\d+)$/); + close(PIPE); + } + if (!$cpucount) { + $cpucount = 1; + } + my %loadtarget = ( + error => 4.0*$cpucount, + warn => 2.0*$cpucount, + note => 1.0*$cpucount, + ); open (LOADAVGH,"/proc/loadavg"); my $loadavg=; close (LOADAVGH); @@ -234,11 +251,11 @@ sub log_machine_info { &log($fh,"$loadavg"); my @parts=split(/\s+/,$loadavg); - if ($parts[1]>4.0) { + if ($parts[1]>$loadtarget{'error'}) { $errors++; - } elsif ($parts[1]>2.0) { + } elsif ($parts[1]>$loadtarget{'warn'}) { $warnings++; - } elsif ($parts[1]>1.0) { + } elsif ($parts[1]>$loadtarget{'note'}) { $notices++; } @@ -1350,7 +1367,7 @@ sub main () { my $wwwid=getpwnam('www'); if ($wwwid!=$<) { print("User ID mismatch. This program must be run as user 'www'.\n"); - my $emailto="$perlvar{'lonAdmEMail'},$perlvar{'lonSysEMail'}"; + my $emailto="$perlvar{'lonAdmEMail'} $perlvar{'lonSysEMail'}"; my $subj="LON: $perlvar{'lonHostID'} User ID mismatch"; system("echo 'User ID mismatch. loncron must be run as user www.' |". " mail -s '$subj' $emailto > /dev/null");