IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40879


Ignore:
Timestamp:
Aug 29, 2019, 12:02:53 PM (7 years ago)
Author:
tdeboer
Message:

better parsing of database update responsibility in between mutliple running czarpoll instances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/czartool/czarpoll.pl

    r40877 r40879  
    128128###########################################################################
    129129sub updateLabels {
     130    my ($dbupdate) = @_;
    130131
    131132    # this used to have a concept of labels grouped by pantasks server, but we
     
    200201
    201202    # store them all in stdscience:
    202     $server = "stdscience";
    203     if (@allLabels) {
    204         $czarDb->updateCurrentLabels($server, \@allLabels,'gpc1', \@priorities);
    205     } else {
    206         print "WARNING: No labels to update for gpc1 for '$server'\n";
    207     }
    208 
    209     if (@allLabels2) {
    210         $czarDb->updateCurrentLabels($server, \@allLabels2,'gpc2', \@priorities2);
    211     } else {
    212         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        }
    213216    }
    214217    return(\@allLabels,\@allLabels2);
     
    244247    my ($period) = @_;
    245248
     249    my $dbupdate;
    246250    my $polldate;
    247251    my $datenow;
     
    271275    # main polling loop
    272276    while (1) {
     277        my $iterationStartTime = time();
     278
    273279        #get the time of last czarpoll update
    274280        $polldate = $czarDb->getPollDate();
     
    279285        $datenow=DateTime->now;
    280286        $timediff = ($datenow->epoch) - ($date->epoch);
    281         if($timediff < 300.) {
     287        if($timediff > 120.) {
     288            print "There is no recent Czarpoll iteration\n";
     289            print "*Updating database entries*\n";
     290            $dbupdate = 1;
     291        } else {
    282292            print "There is a recent Czarpoll iteration already made ($timediff sec ago)\n";
    283             print "* Going to sleep\n";
    284             sleep($period);
    285             print "* Waking up\n";
    286 
    287             next;
    288         }
    289 
    290         my $iterationStartTime = time();
     293            print "*Skipping database queries and entries*\n";
     294            $dbupdate = 0;
     295        }
     296
    291297
    292298        # sort out times
     
    318324
    319325                # now cleanup tables from yesterday and optimize
    320                 print "* Performing database cleanup\n";
    321                 $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
    322                 print "* Optimizing the database\n";
    323                 $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();
    324332                $lastDayDailyTasks = $yesterday;
    325333            }
     
    327335
    328336        # check nightly science status
    329         print "* Checking nightly science status\n";
    330         if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc1')) {$nsStatus = "Unknown";}
    331         $czarDb->updateNightlyScience($nsStatus,'gpc1');
    332         if (!$pantasks->getNightlyScienceStatus(\$nsStatus,'gpc2')) {$nsStatus = "Unknown";}
    333         $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        }
    334344
    335345        # check nebulous
    336346        print "* Checking Nebulous\n";
    337         $nebulous->updateClusterSpaceInfo();
     347        if($dbupdate == 1) {$nebulous->updateClusterSpaceInfo();}
    338348        $plotter0->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
    339349        $plotter0->plotDiskUsageHistogram();
    340350        $plotter0->plotDiskUsageHistogramLarge();
    341         updateServerStatus();
     351        if($dbupdate == 1) {updateServerStatus();}
    342352
    343353        # check pantasks dates
    344         updateDates();
     354        if($dbupdate == 1) {updateDates();}
    345355
    346356        # check labels
    347         my ($labels, $labels2) = updateLabels();
     357        my ($labels, $labels2) = updateLabels($dbupdate);
    348358        my @labels = @$labels;
    349359        my @labels2 = @$labels2;
     
    362372            my $size = @{$labels};
    363373            if($size > 0) {
    364                 updateAllStages($thisServer, $newState, $labels,$labels2, $begin, $end);
     374                if($dbupdate == 1) {updateAllStages($thisServer, $newState, $labels,$labels2, $begin, $end);}
    365375                if ($thisServer eq "stdscience") {
    366376                    createPlots($thisServer, $plotter1, $labels, $begin, $end);
Note: See TracChangeset for help on using the changeset viewer.