IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 17, 2010, 10:05:43 AM (16 years ago)
Author:
eugene
Message:

merge from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/tools/czarpoll.pl

    r29953 r30102  
    108108    my $newState = undef;
    109109    my $nsStatus = undef;
    110     my $lastDay = strftime('%Y-%m-%d', localtime);
    111110    my $today = undef;
    112     my $doneMetricsToday = 1;
    113 
     111    my $yesterday = undef;
     112    my $newDayTime = "18:00";
     113    my $lastDayDailyTasks = "2010-01-01";
     114
     115    # main polling loop
    114116    while (1) {
    115117
    116         # check whether day has changed. if so, cleanup tables from previous day and optimize
     118        # sort out times
    117119        $today = strftime('%Y-%m-%d', localtime);
    118         if ($czarDb->isBefore($lastDay, $today)) {
    119        
     120        $yesterday = $czarDb->subtractInterval($today, "1 DAY");
     121        $end = $czarDb->getNowTimestamp();
     122
     123        # if before 18:00 today, then start plots from 18:00 yesterday
     124        if ($czarDb->isBefore($end, "$today $newDayTime")) {$begin = "$yesterday $newDayTime";}
     125        # if after 18:00 today, then perform some daily tasks and start plots from 18:00 today
     126        else {
     127           
     128            $begin = "$today $newDayTime";
     129
     130            # check whether yesterday was cleaned. if not, cleanup tables and optimize
     131            if ($lastDayDailyTasks ne $yesterday) {
     132   
     133                print "* performing daily tasks (clean-up, metrics)";
     134
     135                # create metrics for last 24 hours
     136                print "* Creating metrics for last 24 hours\n";
     137                # TODO hardcoded path needs to be in config
     138                my $dayMetrics = new czartool::DayMetrics($gpc1Db,
     139                        $czarDb,
     140                        "/data/ipp004.0/ipp/ippMetrics/",
     141                        1, 0, $today);
     142                $dayMetrics->writeHTML();
     143
     144                # now update metrics index page
     145                my $metricsIndex = new czartool::MetricsIndex($gpc1Db,
     146                        $czarDb,
     147                        "/data/ipp004.0/ipp/ippMetrics/",
     148                        1, 0);
     149                $metricsIndex->writeHTML();
     150
     151                # now cleanup tables from yesterday and optimize
    120152                print "* New day - performing cleanup\n";
    121                 $czarDb->cleanupDateRange($lastDay, $lastDay, "30 MINUTE");
     153                $czarDb->cleanupDateRange($yesterday, $yesterday, "30 MINUTE");
    122154                $czarDb->optimize();
    123                 $lastDay = $today;
    124                 $doneMetricsToday = 0;
    125         }
    126 
    127         # sort out times
    128         $begin = strftime('%Y-%m-%d 06:30', localtime);
    129         $end = $czarDb->getNowTimestamp();
    130 
    131         # if time now is after 06:35am, then create metrics for past 24 hours
    132         if (!$doneMetricsToday && $czarDb->isBefore($begin, $end)) {
    133        
    134             # create metrics for last 24 hours
    135             print "* Creating metrics for last 24 hours\n";
    136             my $yesterday = $czarDb->subtractInterval($today, "1 DAY");
    137             # TODO hardcoded path needs to be in config
    138             my $dayMetrics = new czartool::DayMetrics($gpc1Db,
    139                     $czarDb,
    140                     "/data/ipp004.0/ipp/ippMetrics/",
    141                     1, 0, $yesterday);
    142             $dayMetrics->writeHTML();
    143             $doneMetricsToday = 1;
    144 
    145             # now update metrics index page
    146             my $metricsIndex = new czartool::MetricsIndex($gpc1Db,
    147                     $czarDb,
    148                     "/data/ipp004.0/ipp/ippMetrics/",
    149                     1, 0);
    150         }
    151 
    152         # if time now is before 06:35am, include data from previous day
    153         if ($czarDb->isBefore($end, $begin)) {
    154 
    155             $begin = $czarDb->subtractInterval($begin, "1 DAY");
     155                $lastDayDailyTasks = $yesterday;
     156            }
    156157        }
    157158
     
    247248
    248249        $plotter->createLogAndLinearTimeSeries($allServerLabels,  $stage, $begin, $end); # TODO must be a neater way...
    249         $plotter->createRateTimeSeries($allServerLabels, $stage, $begin, $end, undef, 0);
     250            $plotter->createRateTimeSeries($allServerLabels, $stage, $begin, $end, undef, 0);
    250251    }
    251252}
     
    271272    my $server = undef;
    272273    my $state = undef;
    273    
     274
    274275    foreach $stage (@stages) {
    275276
Note: See TracChangeset for help on using the changeset viewer.