Diff for /loncom/loncron between versions 1.112 and 1.113

version 1.112, 2018/10/29 02:57:30 version 1.113, 2018/11/06 15:37:42
Line 713  sub check_delayed_msg { Line 713  sub check_delayed_msg {
 }  }
   
 sub finish_logging {  sub finish_logging {
     my ($fh)=@_;      my ($fh,%weights)=@_;
     &log($fh,"<a name='errcount' />\n");      &log($fh,"<a name='errcount' />\n");
     $totalcount=$notices+4*$warnings+100*$errors;      $totalcount=($weights{'N'}*$notices)+($weights{'W'}*$warnings)+($weights{'E'}*$errors);
     &errout($fh);      &errout($fh);
     &log($fh,"<h1>Total Error Count: $totalcount</h1>");      &log($fh,"<h1>Total Error Count: $totalcount</h1>");
     my $now=time;      my $now=time;
Line 861  sub clean_lonc_childpids { Line 861  sub clean_lonc_childpids {
 }  }
   
 sub write_connection_config {  sub write_connection_config {
     my ($isprimary,$domconf,$url,%connectssl,%changes);      my ($domconf,%connectssl,%changes);
     my $primaryLibServer = &Apache::lonnet::domain($perlvar{'lonDefDomain'},'primary');      $domconf = &get_domain_config();
     if ($primaryLibServer eq $perlvar{'lonHostID'}) {  
         $isprimary = 1;  
     } elsif ($primaryLibServer ne '') {  
         my $protocol = $Apache::lonnet::protocol{$primaryLibServer};  
         my $hostname = &Apache::lonnet::hostname($primaryLibServer);  
         unless ($protocol eq 'https') {  
             $protocol = 'http';  
         }  
         $url = $protocol.'://'.$hostname.'/cgi-bin/listdomconfig.pl';  
     }  
     my $domconf = &get_domain_config($perlvar{'lonDefDomain'},$primaryLibServer,$isprimary,  
                                      $url);  
     if (ref($domconf) eq 'HASH') {      if (ref($domconf) eq 'HASH') {
         if (ref($domconf->{'ssl'}) eq 'HASH') {          if (ref($domconf->{'ssl'}) eq 'HASH') {
             foreach my $connect ('connto','connfrom') {              foreach my $connect ('connto','connfrom') {
Line 927  sub write_connection_config { Line 915  sub write_connection_config {
 }  }
   
 sub get_domain_config {  sub get_domain_config {
     my ($dom,$primlibserv,$isprimary,$url) = @_;      my ($dom,$primlibserv,$isprimary,$url,%confhash);
     my %confhash;      $dom = $perlvar{'lonDefDomain'};
       $primlibserv = &Apache::lonnet::domain($dom,'primary');
       if ($primlibserv eq $perlvar{'lonHostID'}) {
           $isprimary = 1;
       } elsif ($primlibserv ne '') {
           my $protocol = $Apache::lonnet::protocol{$primlibserv};
           my $hostname = &Apache::lonnet::hostname($primlibserv);
           unless ($protocol eq 'https') {
               $protocol = 'http';
           }
           $url = $protocol.'://'.$hostname.'/cgi-bin/listdomconfig.pl';
       }
     if ($isprimary) {      if ($isprimary) {
         my $lonusersdir = $perlvar{'lonUsersDir'};          my $lonusersdir = $perlvar{'lonUsersDir'};
         my $fname = $lonusersdir.'/'.$dom.'/configuration.db';          my $fname = $lonusersdir.'/'.$dom.'/configuration.db';
Line 1088  sub reset_nosslverify_pids { Line 1087  sub reset_nosslverify_pids {
 }  }
   
 sub send_mail {  sub send_mail {
       my ($sysmail,$reportstatus) = @_;
     my $defdom = $perlvar{'lonDefDomain'};      my $defdom = $perlvar{'lonDefDomain'};
     my $origmail = $perlvar{'lonAdmEMail'};      my $origmail = $perlvar{'lonAdmEMail'};
     my $emailto = &Apache::loncommon::build_recipient_list(undef,      my $emailto = &Apache::loncommon::build_recipient_list(undef,
                                    'lonstatusmail',$defdom,$origmail);                                     'lonstatusmail',$defdom,$origmail);
     if ($totalcount>2500) {      if (($totalcount>$sysmail) && ($reportstatus)) {
  $emailto.=",$perlvar{'lonSysEMail'}";   $emailto.=",$perlvar{'lonSysEMail'}";
     }      }
     my $from;      my $from;
Line 1287  sub main () { Line 1287  sub main () {
             &checkon_daemon($fh,'lond',40000,'USR2');              &checkon_daemon($fh,'lond',40000,'USR2');
             &reset_nosslverify_pids($fh,%sslrem);              &reset_nosslverify_pids($fh,%sslrem);
         }          }
         &finish_logging($fh);          my $domconf = &get_domain_config();
  if ($totalcount>200 && !$noemail) { &send_mail(); }          my ($defaults,$names) = &Apache::loncommon::lon_status_items();
           my (%weights,$threshold);
           foreach my $type ('E','W','N') {
               $weights{$type} = $defaults->{$type};
           }
           my $threshold = $defaults->{'threshold'};
           my $sysmail = $defaults->{'sysmail'};
           my $reportstatus = 1;
           if (ref($domconf->{'contacts'}) eq 'HASH') {
               if ($domconf->{'contacts'}{'reportstatus'} == 0) {
                   $reportstatus = 0;
               }
               if (ref($domconf->{'contacts'}{'lonstatus'}) eq 'HASH') {
                   if (ref($domconf->{'contacts'}{'lonstatus'}{weights}) eq 'HASH') {
                       foreach my $type ('E','W','N') {
                           if (exists($domconf->{'contacts'}{'lonstatus'}{weights}{$type})) {
                               $weights{$type} = $domconf->{'contacts'}{'lonstatus'}{weights}{$type};
                           }
                       }
                   }
               }
               if (exists($domconf->{'contacts'}{'lonstatus'}{'threshold'})) {
                   $threshold = $domconf->{'contacts'}{'lonstatus'}{'threshold'};
               }
               if (exists($domconf->{'contacts'}{'lonstatus'}{'sysmail'})) {
                   $sysmail = $domconf->{'contacts'}{'lonstatus'}{'sysmail'};
               }
           }
           &finish_logging($fh,%weights);
    if ($totalcount>$threshold && !$noemail) { &send_mail($sysmail,$reportstatus); }
     }      }
 }  }
   

Removed from v.1.112  
changed lines
  Added in v.1.113


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>