IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 27, 2019, 12:06:52 PM (7 years ago)
Author:
tdeboer
Message:

Added check to only run czarpoll when no recent run already exists (prevents ipp117 and ipp113 instances from doing pointless repeats)

File:
1 edited

Legend:

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

    r40847 r40877  
    1212use POSIX qw/strftime/;
    1313use List::MoreUtils qw(uniq);
     14use DateTime;
    1415
    1516# local classes
     
    243244    my ($period) = @_;
    244245
     246    my $polldate;
     247    my $datenow;
     248    my $timediff;
    245249    my $label;
    246250    my $new;
     
    267271    # main polling loop
    268272    while (1) {
     273        #get the time of last czarpoll update
     274        $polldate = $czarDb->getPollDate();
     275        $polldate=~/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;
     276        my $date=DateTime->new(year=>$1,month=>$2,day=>$3,hour=>$4,minute=>$5,second=>$6,time_zone=>"HST");
     277        $date->set_time_zone("UTC");
     278
     279        $datenow=DateTime->now;
     280        $timediff = ($datenow->epoch) - ($date->epoch);
     281        if($timediff < 300.) {
     282            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        }
    269289
    270290        my $iterationStartTime = time();
Note: See TracChangeset for help on using the changeset viewer.