IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 16, 2010, 2:08:26 PM (16 years ago)
Author:
rhenders
Message:

Changes to incorporate addition of update labels to czartool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/roboczar.pl

    r28870 r28926  
    4242
    4343    print "* Updating labels\n";
    44     my @servers = ("stdscience", "distribution", "publishing");
     44    my @servers = ("stdscience", "distribution", "publishing", "update");
    4545
    4646    my $server = undef;
     
    9292    my $faults;
    9393    my $stage;
    94     my ($totalNew,$totalFull,$totalFaults);
    9594    my $query = undef;
    9695    my $str = undef;
    97     my $reverting = 0;
    98     my $server = undef;
    99     my $rows = undef;
     96    my $labels = undef;
     97    my $updateLabels = undef;
    10098    my $row = undef;
    10199    my $begin = undef;
    102100    my $end = undef;
    103101    my $priority = undef;
     102    my $newState = undef;
     103
    104104    while (1) {
    105105
     106        # sort out times
     107        $begin =  strftime('%Y-%m-%d 07:00',localtime);
     108        $end = $czarDb->getNowTimestamp();
     109
     110        if ($czarDb->isBefore($end, $begin)) {
     111
     112            $begin = $czarDb->subtractInterval($begin, "1 DAY");
     113        }
     114
     115        # check nebulous
    106116        print "* Checking Nebulous\n";
    107117        $nebulous->updateClusterSpaceInfo();
    108118        $czarplot->plotDiskUsageHistogram();
    109119        updateServerStatus();
     120
     121        # check labels
    110122        updateLabels();
    111         if (!$czarDb->getCurrentLabels("stdscience", \$rows)) {next;}
    112 
    113         my $size = @{$rows};
    114         if($size < 1) {
    115            
    116             print "* WARNING: no stdscience labels found in Db\n";
    117             next;
    118         }
    119 
    120         # get priority
    121         foreach $row ( @{$rows} ) {
    122             my ($label) = @{$row};
    123             $priority = $gpc1Db->getPriority($label);
    124             $czarDb->setLabelPriority($label, $priority);
    125         }
    126 
    127         # sort out times
    128         $begin =  strftime('%Y-%m-%d 07:00',localtime);
    129         $end = $czarDb->getNowTimestamp();
    130 
    131         if ($czarDb->isBefore($end, $begin)) {
    132 
    133             $begin = $czarDb->subtractInterval($begin, "1 DAY");
    134         }
    135 
    136         foreach $stage (@stages) {
    137 
    138             $server = $pantasks->getServerForThisStage($stage);
    139             $pantasks->getRevertStatus($stage, \$reverting);
    140             $czarDb->updateRevertStatus($stage, $reverting);
    141 
    142             print "* Checking labels for $stage stage\n";
    143 
    144             $totalNew=$totalFaults=$totalFull=0;
    145             foreach $row ( @{$rows} ) {
    146                 my ($label) = @{$row};
    147 
    148                 chomp($label);
    149 
    150                 $new = $gpc1Db->countExposures($label, $stage, "new");
    151                 $full = $gpc1Db->countExposures($label, $stage, "full");
    152                 $faults = $gpc1Db->countFaults($label, $stage);
    153 
    154                 #printf("%ld, %s, %s, %d, %d\n", $currentTime, $label, $stage, $new, $faults);
    155                 $totalNew += $new;
    156                 $totalFull += $full;
    157                 $totalFaults += $faults;
    158 
    159                 $czarDb->insertNewTimeData($stage, $label, $new, $full, $faults);
    160                 $czarplot->createTimeSeries($label,  $stage, $begin, $end);
     123
     124        # servers to check
     125        my @serversToCheck = ("stdscience", "update");
     126
     127        my $thisServer = undef;
     128        foreach $thisServer (@serversToCheck) {
     129
     130            if ($thisServer eq "update") {$newState = "update";}
     131            else {$newState = "new";}
     132
     133            # deal with stdscience labels
     134            if (!$czarDb->getCurrentLabels($thisServer, \$labels)) {next;}
     135            my $size = @{$labels};
     136            if($size > 0) {
     137
     138                # get priority
     139                foreach $row ( @{$labels} ) {
     140                    my ($label) = @{$row};
     141                    $priority = $gpc1Db->getPriority($label);
     142                    $czarDb->setLabelPriority($label, $priority);
     143                }
     144
     145                updateAllStages($thisServer, $newState, $labels, $begin, $end);
     146                createPlots($thisServer, $labels, $begin, $end);
    161147            }
    162 
    163             $czarDb->insertNewTimeData($stage, "all_labels", $totalNew, $totalFull, $totalFaults);
    164         }
    165 
    166         print "* Generating plots\n";
    167         foreach $row ( @{$rows} ) {
    168             my ($label) = @{$row};
    169 
    170             $czarplot->createTimeSeries($label, undef, $begin, $end);
    171             $czarplot->createHistogram($label, $begin, $end);
    172 
    173             #routineChecks($label, "1 HOUR");
    174         }
    175         $czarplot->createTimeSeries("all_labels", undef, $begin, $end);
    176         $czarplot->createHistogram("all_labels", $begin, $end);
    177         foreach $stage (@stages) {
    178 
    179             $czarplot->createTimeSeries("all_labels",  $stage, $begin, $end); # TODO must be a neater way...
    180         }
     148            else { print "* WARNING: no $thisServer labels found in Db\n";}
     149        }
     150
    181151        print "--------------------------------------------------------------------------\n";
    182152        print "* Going to sleep\n";
     
    186156        #sendEmail("roydhenderson\@gmail.com", "roboczar\@ipp.com", "Roboczar update", "Some content");
    187157    };
     158}
     159
     160###########################################################################
     161#
     162# Loops through labels and creates time series and histogram plots
     163#
     164###########################################################################
     165sub createPlots {
     166    my ($server, $rows, $begin, $end) = @_;
     167
     168    my $stage = undef;
     169    my $row = undef;
     170
     171    print "* Generating plots\n";
     172
     173    # create plots for each label for each stage
     174    foreach $stage (@stages) {
     175        foreach $row ( @{$rows} ) {
     176            my ($label) = @{$row};
     177
     178            chomp($label);
     179            $czarplot->createTimeSeries($label,  $stage, $begin, $end);
     180        }
     181    }
     182
     183    # create plots for each label for all stages
     184    foreach $row ( @{$rows} ) {
     185        my ($label) = @{$row};
     186
     187        $czarplot->createTimeSeries($label, undef, $begin, $end);
     188        $czarplot->createHistogram($label, $begin, $end);
     189
     190        #routineChecks($label, "1 HOUR");
     191    }
     192    $czarplot->createTimeSeries("all_".$server."_labels", undef, $begin, $end);
     193    $czarplot->createHistogram("all_".$server."_labels", $begin, $end);
     194    foreach $stage (@stages) {
     195
     196        $czarplot->createTimeSeries("all_".$server."_labels",  $stage, $begin, $end); # TODO must be a neater way...
     197    }
     198}
     199
     200###########################################################################
     201#
     202# Loops through some labels and updates processed/pending/faults in the Db
     203#
     204###########################################################################
     205sub updateAllStages {
     206    my ($labelServer, $newState, $rows, $begin, $end) = @_;
     207
     208    print "* Updating stage data\n";
     209    my $totalNew = undef;
     210    my $totalFaults = undef;
     211    my $totalFull = undef;
     212    my $stage = undef;
     213    my $reverting = 0;
     214    my $row = undef;
     215    my $new = undef;
     216    my $full = undef;
     217    my $faults = undef;
     218    my $server = undef;
     219    my $state = undef;
     220   
     221    foreach $stage (@stages) {
     222
     223        $server = $pantasks->getServerForThisStage($stage);
     224        $pantasks->getRevertStatus($stage, \$reverting);
     225        $czarDb->updateRevertStatus($stage, $reverting);
     226
     227        print "* Checking labels for $stage stage\n";
     228
     229        $totalNew=$totalFaults=$totalFull=0;
     230        foreach $row ( @{$rows} ) {
     231            my ($label) = @{$row};
     232
     233            chomp($label);
     234
     235            $new = $gpc1Db->countExposures($label, $stage, $newState);
     236            $full = $gpc1Db->countExposures($label, $stage, "full");
     237            $faults = $gpc1Db->countFaults($label, $stage, $newState);
     238
     239            #printf("%s  %s, %s, %d, %d\n", $labelServer, $label, $stage, $new, $faults);
     240            $totalNew += $new;
     241            $totalFull += $full;
     242            $totalFaults += $faults;
     243
     244            $czarDb->insertNewTimeData($stage, $label, $new, $full, $faults);
     245        }
     246
     247        $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", $totalNew, $totalFull, $totalFaults);
     248    }
    188249}
    189250
Note: See TracChangeset for help on using the changeset viewer.