IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 27, 2019, 9:47:12 PM (7 years ago)
Author:
cclin33
Message:

sync from trunk with r40973

Location:
branches/ccl_branches/ipp-20190806/ippMonitor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/ccl_branches/ipp-20190806/ippMonitor

  • branches/ccl_branches/ipp-20190806/ippMonitor/czartool/czarpoll.pl

    r40847 r40974  
    1212use POSIX qw/strftime/;
    1313use List::MoreUtils qw(uniq);
     14use DateTime;
    1415
    1516# local classes
     
    127128###########################################################################
    128129sub updateLabels {
     130    my ($dbupdate) = @_;
    129131
    130132    # this used to have a concept of labels grouped by pantasks server, but we
     
    199201
    200202    # store them all in stdscience:
    201     $server = "stdscience";
    202     if (@allLabels) {
    203         $czarDb->updateCurrentLabels($server, \@allLabels,'gpc1', \@priorities);
    204     } else {
    205         print "WARNING: No labels to update for gpc1 for '$server'\n";
    206     }
    207 
    208     if (@allLabels2) {
    209         $czarDb->updateCurrentLabels($server, \@allLabels2,'gpc2', \@priorities2);
    210     } else {
    211         print "WARNING: No labels to update for gpc2 for '$server'\n";
     203    if($dbupdate == 1) {
     204        $server = "stdscience";
     205        if (@allLabels) {
     206            $czarDb->updateCurrentLabels($server, \@allLabels,'gpc1', \@priorities);
     207        } else {
     208            print "WARNING: No labels to update for gpc1 for '$server'\n";
     209        }
     210
     211        if (@allLabels2) {
     212            $czarDb->updateCurrentLabels($server, \@allLabels2,'gpc2', \@priorities2);
     213        } else {
     214            print "WARNING: No labels to update for gpc2 for '$server'\n";
     215        }
    212216    }
    213217    return(\@allLabels,\@allLabels2);
     
    243247    my ($period) = @_;
    244248
     249    my $dbupdate;
     250    my $polldate;
     251    my $datenow;
     252    my $timediff;
    245253    my $label;
    246254    my $new;
     
    267275    # main polling loop
    268276    while (1) {
    269 
    270277        my $iterationStartTime = time();
     278
     279        #get the time of last czarpoll update
     280        $polldate = $czarDb->getPollDate();
     281        $polldate=~/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;
     282        my $date=DateTime->new(year=>$1,month=>$2,day=>$3,hour=>$4,minute=>$5,second=>$6,time_zone=>"HST");
     283        $date->set_time_zone("UTC");
     284
     285        $datenow=DateTime->now;
     286        $timediff = ($datenow->epoch) - ($date->epoch);
     287        if($timediff > 120.) {
     288            print "There is no recent Czarpoll iteration\n";
     289            print "*Updating database entries*\n";
     290            $dbupdate = 1;
     291        } else {
     292            print "There is a recent Czarpoll iteration already made ($timediff sec ago)\n";
     293            print "*Skipping database queries and entries*\n";
     294            $dbupdate = 0;
     295        }
     296
    271297
    272298        # sort out times
     
    298324
    299325                # now cleanup tables from yesterday and optimize
    300                 print "* Performing database cleanup\n";
    301                 $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
    302                 print "* Optimizing the database\n";
    303                 $czarDb->optimize();
     326                #TdB20190703: The ipp113 and ipp117 instances of czarpoll use the same stage DBs in czarDB.
     327                #Therefore, it makes no sense to run the cleanup+optimising twice
     328                #print "* Performing database cleanup\n";
     329                #$czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
     330                #print "* Optimizing the database\n";
     331                #$czarDb->optimize();
    304332                $lastDayDailyTasks = $yesterday;
    305333            }
     
    307335
    308336        # check nightly science status
    309         print "* Checking nightly science status\n";
    310         if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc1')) {$nsStatus = "Unknown";}
    311         $czarDb->updateNightlyScience($nsStatus,'gpc1');
    312         if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc2')) {$nsStatus = "Unknown";}
    313         $czarDb->updateNightlyScience($nsStatus,'gpc2');
     337        if($dbupdate == 1) {
     338            print "* Checking nightly science status\n";
     339            if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc1')) {$nsStatus = "Unknown";}
     340            $czarDb->updateNightlyScience($nsStatus,'gpc1');
     341            if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc2')) {$nsStatus = "Unknown";}
     342            $czarDb->updateNightlyScience($nsStatus,'gpc2');
     343        }
    314344
    315345        # check nebulous
    316346        print "* Checking Nebulous\n";
    317         $nebulous->updateClusterSpaceInfo();
     347        if($dbupdate == 1) {$nebulous->updateClusterSpaceInfo();}
    318348        $plotter0->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
    319349        $plotter0->plotDiskUsageHistogram();
    320350        $plotter0->plotDiskUsageHistogramLarge();
    321         updateServerStatus();
     351        if($dbupdate == 1) {updateServerStatus();}
    322352
    323353        # check pantasks dates
    324         updateDates();
     354        if($dbupdate == 1) {updateDates();}
    325355
    326356        # check labels
    327         my ($labels, $labels2) = updateLabels();
     357        my ($labels, $labels2) = updateLabels($dbupdate);
    328358        my @labels = @$labels;
    329359        my @labels2 = @$labels2;
     
    342372            my $size = @{$labels};
    343373            if($size > 0) {
    344                 updateAllStages($thisServer, $newState, $labels,$labels2, $begin, $end);
     374                if($dbupdate == 1) {updateAllStages($thisServer, $newState, $labels,$labels2, $begin, $end);}
    345375                if ($thisServer eq "stdscience") {
    346376                    createPlots($thisServer, $plotter1, $labels, $begin, $end);
Note: See TracChangeset for help on using the changeset viewer.