IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 13, 2015, 9:19:19 AM (11 years ago)
Author:
bills
Message:

Working version of czartool with plots.
raw/ipp.czar.dat

Remove 'czartool - ipptopsps link' from Czar left panel menu

raw/ipp.php

Get czardb name and host from site.php

raw/czartool_getplot.php

czartool plots are now in project specific directory
get base directory from

raw/czartool_labels.php

XXX: a couple of testing hacks to remove
Include proj in arguments to links to czartool_getplot.php

czartool/czarpoll.pl

Support for gathering data from multiple project databases.
czartool::Plotter now has an optional project database member. 3 Plotter
instances now.

plotter0 is for non project specific plots.
plotter1 is for gpc1
plotter1 is for gpc2

Keep track and print out how long each poll iteration takes. If it takes
less than the supplied period, sleep for the remainder. Currently takes
about 140 seconds which is larger than the default 60 second period.

Turn off the ippToPsps data gathering by nulling out the stage list.

czartool/czarplot.pl

Support for multiple projects

czartool/czartool/Metrics.pm

Metrics has a projectDb pass to Plotter constructor.
hardcoded member gpc1Db is deleted

czartool/czartool/DayMetrics.pm

projectDb isntead of hard coded gpc1Db
pass dbname to StageMetrics and CzarDb methods.

czartool/czartool/Config.pm

Added support for 2 project databases

czartool/czartool/CzarDb.pm

Operations on the stage tables now take "dbname" parameter.
This is passed to StageMetrics constructor.
XXX: should we split query for getTimeMinMaxDiff by project.

czartool/czartool/Plotter.pm

Add _projectDb member. Save dbname to _project for use in many method
invocations

czartool/czartool/StageMetrics.pm

Add dbname parameter.
XXX: Actually I'm not sure this is used any longer. This may have been
from a previous iteration. I've since moved the DB info to Plotter and Metrics.
Leaving in for now since this version is fully tested.

czartool/czartool/MySQLDb.pm

Add method to get _dbName

czartool/czartool/MetricsIndex.pm

Add database paramter to constructor for superclass Metrics. (It used to
have hard coded gpc1 db

File:
1 edited

Legend:

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

    r38251 r38258  
    2626
    2727GetOptions (
    28         "period|p=s" => \$period, # TODO more Db args
     28        "period|p=s" => \$period,
    2929        );
    3030
     
    3535my $nebulous = new czartool::Nebulous($czarDb);
    3636my $pantasks = new czartool::Pantasks();
    37 my $plotter = czartool::Plotter->new_file($config, $config->getGnuplotPath(), $save_temps);
    38 
     37
     38# We have a top level directory that gets general plots and then one for each database
     39my $plotter0 = czartool::Plotter->new_file($config, undef, $config->getGnuplotPath(), $save_temps);
     40
     41# for now hardcode two databases. Later I'll look into handling a variable number
     42my $plotter1 = czartool::Plotter->new_file($config, $gpc1Db, $config->getGnuplotPath() . "/gpc1", $save_temps);
     43my $plotter2 = czartool::Plotter->new_file($config, $gpc2Db, $config->getGnuplotPath() . "/gpc2", $save_temps);
    3944
    4045my @stages = (
     
    5964        "merged",
    6065        "deleted_local");
     66
     67# The ippToPsps pages are no longer operational
     68@ippToPspsStages = ();
    6169
    6270my @allStages = (@stages, @ippToPspsStages);
     
    167175    while (1) {
    168176
     177        my $iterationStartTime = time();
     178
    169179        # sort out times
    170180        $today = strftime('%Y-%m-%d', localtime);
     
    172182        $end = $czarDb->getNowTimestamp();
    173183
    174         # if before 18:00 today, then start plots from 18:00 yesterday
    175         if ($czarDb->isBefore($end, "$today $newDayTime")) {$begin = "$yesterday $newDayTime";}
    176         # if after 18:00 today, then perform some daily tasks and start plots from 18:00 today
    177         else {
     184        if ($czarDb->isBefore($end, "$today $newDayTime")) {
     185            # if before $newDayTime today (configured to 18:00), then start plots from $newDayTime yesterday
     186            $begin = "$yesterday $newDayTime";
     187        } else {
     188            # if after $newDayTime today (configured to 18:00), then perform some daily tasks and start plots from $newDayTime  today
    178189
    179190            $begin = "$today $newDayTime";
     
    186197                # create metrics for last 24 hours
    187198                print "* Creating metrics for last 24 hours\n";
    188                 my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $today);
     199                my $dayMetrics = new czartool::DayMetrics($config, $gpc1Db, 1, 0, $today);
    189200                $dayMetrics->writeHTML();
    190201
    191202                # now update metrics index page
    192                 my $metricsIndex = new czartool::MetricsIndex($config, 1, 0);
     203                my $metricsIndex = new czartool::MetricsIndex($config, $gpc1Db, 1, 0);
    193204                $metricsIndex->writeHTML();
    194205
     
    210221        print "* Checking Nebulous\n";
    211222        $nebulous->updateClusterSpaceInfo();
    212         $plotter->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
    213         $plotter->plotDiskUsageHistogram();
    214         $plotter->plotDiskUsageHistogramLarge();
     223        $plotter0->plotStorageTimeSeries($czarDb->subtractInterval($begin, "1 WEEK") , $end);
     224        $plotter0->plotDiskUsageHistogram();
     225        $plotter0->plotDiskUsageHistogramLarge();
    215226        updateServerStatus();
    216227
     
    239250                foreach $row ( @{$labels} ) {
    240251                    my ($label) = @{$row};
     252                    # for now use priorities from gpc1 database
    241253                    $priority = $gpc1Db->getPriority($label);
    242254                    $czarDb->setLabelPriority($label, $priority);
     
    244256
    245257                updateAllStages($thisServer, $newState, $labels, $begin, $end);
    246                 if ($thisServer eq "stdscience") {createPlots($thisServer, $labels, $begin, $end);}
     258                if ($thisServer eq "stdscience") {
     259                    createPlots($thisServer, $plotter1, $labels, $begin, $end);
     260                    createPlots($thisServer, $plotter2, $labels, $begin, $end);
     261                }
    247262            }
    248263            else { print "* WARNING: no $thisServer labels found in Db\n";}
    249264        }
    250265
     266        my $iterationTime = time() - $iterationStartTime;
     267
     268        print "done with czarpoll iteration after $iterationTime seconds\n";
     269
    251270        print "--------------------------------------------------------------------------\n";
    252         #print "* Going to sleep\n";
    253         #sleep($period);
    254         #print "* Waking up\n";
     271        if ($iterationTime < $period) {
     272            print "* Going to sleep\n";
     273            sleep($period - $iterationTime);
     274            print "* Waking up\n";
     275        }
    255276    };
    256277}
     
    262283###########################################################################
    263284sub createPlots {
    264     my ($server, $rows, $begin, $end) = @_;
     285    my ($server, $plotter, $rows, $begin, $end) = @_;
    265286
    266287    my $stage = undef;
    267288    my $row = undef;
    268289
    269     print "* Generating plots\n";
    270 
    271     # get ippToPsps labels
    272     my $ippToPspsLabels = undef;
    273     $czarDb->getCurrentIppToPspsLabels($begin, $end, \$ippToPspsLabels);
    274     $plotter->setIppToPspsMode();
    275 
    276     # create ippToPsps labels
    277     foreach $stage (@ippToPspsStages) {
     290    my $project = $plotter->getProject();
     291    print "* Generating plots for $project\n";
     292
     293    # XXX The ippToPsps stuff is not project specific so it should be done somewhere
     294    # else
     295    if (scalar @ippToPspsStages) {
     296        # get ippToPsps labels
     297        my $ippToPspsLabels = undef;
     298        $czarDb->getCurrentIppToPspsLabels($begin, $end, \$ippToPspsLabels);
     299        $plotter->setIppToPspsMode();
     300
     301        # create ippToPsps labels
     302        foreach $stage (@ippToPspsStages) {
     303            foreach $row ( @{$ippToPspsLabels} ) {
     304                my ($label) = @{$row};
     305
     306                chomp($label);
     307                $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 0, 1);
     308            }
     309        }
     310
     311        # create plots for each label for all stages for ippToPsps
    278312        foreach $row ( @{$ippToPspsLabels} ) {
    279313            my ($label) = @{$row};
    280314
    281             chomp($label);
    282             $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 0, 1);
    283         }
    284     }
    285 
    286     # create plots for each label for all stages for ippToPsps
    287     foreach $row ( @{$ippToPspsLabels} ) {
    288         my ($label) = @{$row};
    289 
    290         $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
    291     }
    292 
     315            $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
     316        }
     317    }
    293318
    294319    # create plots for each label for each stage
    295320    $plotter->setStandardMode();
     321
    296322    foreach $stage (@stages) {
    297323        foreach $row ( @{$rows} ) {
    298324            my ($label) = @{$row};
    299325
     326            # skip update labels for now. The plots are not relevant.
     327            next if $label =~ 'ps_ud';
     328
    300329            chomp($label);
    301330            $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 0, 1);
     
    308337    foreach $row ( @{$rows} ) {
    309338        my ($label) = @{$row};
     339
     340        # skip update labels for now. The plots are not relevant.
     341        next if $label =~ 'ps_ud';
    310342
    311343        $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1);
     
    362394            chomp($label);
    363395
     396            # Move this to a function and pass in the database
    364397            $new = $gpc1Db->countExposures($label, $stage, $newState);
    365398            $full = $gpc1Db->countExposures($label, $stage, "full");
Note: See TracChangeset for help on using the changeset viewer.