IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30250


Ignore:
Timestamp:
Jan 12, 2011, 2:52:40 PM (15 years ago)
Author:
rhenders
Message:

Long overdue introduction of XML config file for czartool

Location:
trunk/tools
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czarmetrics.pl

    r29868 r30250  
    88use CGI::Pretty qw[:standard];
    99
     10use czartool::Config;
    1011use czartool::DayMetrics;
    1112use czartool::MultiDayMetrics;
    1213use czartool::MetricsIndex;
    13 use czartool::CzarDb;
    14 use czartool::Gpc1Db;
    1514
    1615my $czarDbName = "czardb";
     
    6059if ($quit) {exit;}
    6160
    62 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser");
    63 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", $verbose, $save_temps);
    64 $czarDb->setDateFormat("%Y%m%d-%H%i%s");
     61my $config = new czartool::Config();
    6562
    6663if ($index) {
    6764
    68     my $metricsIndex = new czartool::MetricsIndex($gpc1Db, $czarDb, "/data/ipp004.0/ipp/ippMetrics/", 1, 0);
     65    my $metricsIndex = new czartool::MetricsIndex($config, 1, 0);
    6966    $metricsIndex->writeHTML();
    7067    exit;
     
    8279if ($cumulative) {
    8380
    84         my $multiDayMetrics = new czartool::MultiDayMetrics($gpc1Db, $czarDb, "/data/ipp004.0/ipp/ippMetrics/", 1, 0, $begin, $end);
     81        my $multiDayMetrics = new czartool::MultiDayMetrics($config, 1, 0, $begin, $end);
    8582        $multiDayMetrics->writeHTML();
    8683}
    8784else {
    8885
     86    my $czarDb = $config->getCzarDbInstance();
     87
    8988    while (1) {
    9089
    91         my $dayMetrics = new czartool::DayMetrics($gpc1Db, $czarDb, "/data/ipp004.0/ipp/ippMetrics/", 1, 0, $thisDay);
     90        my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $thisDay);
    9291        $dayMetrics->writeHTML();
    9392
  • trunk/tools/czarplot.pl

    r29952 r30250  
    77use POSIX qw/strftime/;
    88
    9 use czartool::CzarDb;
    10 use czartool::Gpc1Db;
     9use czartool::Config;
    1110use czartool::Plotter;
    1211use czartool::StageMetrics;
    1312
    14 my $czarDbName = "czardb";
    1513my $label = undef;
    1614my $stage = undef;
     
    3634
    3735GetOptions (
    38         "dbname=s" => \$czarDbName,
    3936        "label|l=s" => \$label,
    4037        "stage|s=s" => \$stage,
     
    114111if ($quit) { exit; }
    115112
     113my $config = new czartool::Config();
     114
    116115# default values
    117116if (!$rate && !$magicMask && !$nebulous && !$histogram && !$analysis && !$timeSeries) {$timeSeries = 1;}
     
    121120else {$savingToFile = 1;}
    122121
    123 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser");
    124 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", $verbose, $save_temps);
    125 $czarDb->setDateFormat("%Y%m%d-%H%i%s");
     122my $czarDb = $config->getCzarDbInstance();
    126123
    127124
     
    129126if ($savingToFile) {
    130127
    131     $plotter = czartool::Plotter->new_file(
    132             $gpc1Db,
    133             $czarDb,
    134             $path,
    135             $save_temps);
     128    $plotter = czartool::Plotter->new_file($config, $path, $save_temps);
    136129}
    137130else {
    138131
    139     $plotter = czartool::Plotter->new_display(
    140             $gpc1Db,
    141             $czarDb,
    142             $save_temps);
     132    $plotter = czartool::Plotter->new_display($config, $save_temps);
    143133}
    144134
     
    148138    if ($magicMask) {
    149139
    150         $begin =  $day;
     140        $begin = $day;
    151141        $end = $day;
    152142    }
     
    167157    }
    168158}
     159
     160print "B $begin E $end";
     161
    169162if ($rate) {
    170163
  • trunk/tools/czarpoll.pl

    r30100 r30250  
    11#!/usr/bin/perl -w
     2
     3###########################################################################
     4#
     5# Main polling program for czartool. Grabs stuff from various sources every few minutes.
     6#
     7###########################################################################
    28
    39use warnings;
     
    713
    814# local classes
     15use czartool::Config;
    916use czartool::CzarDb;
    1017use czartool::Gpc1Db;
     
    1724
    1825my $period = 60;
    19 my $czarDbName = "czardb"; # TODO variables for other Db stuff, host etc
    2026my $save_temps = 0;
    2127
    2228GetOptions (
    2329        "period|p=s" => \$period, # TODO more Db args
    24         "dbname|d=s" => \$czarDbName,
    2530        );
    2631
    27 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", 0, $save_temps); # TODO last arg here is save_temps, should get as arg
    28 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser");
     32my $config = new czartool::Config();
     33my $czarDb = $config->getCzarDbInstance();
     34my $gpc1Db = $config->getGpc1Instance;
    2935my $nebulous = new czartool::Nebulous($czarDb);
    3036my $pantasks = new czartool::Pantasks();
    31 my $plotter = czartool::Plotter->new_file($gpc1Db, $czarDb, "/tmp", $save_temps);
     37my $plotter = czartool::Plotter->new_file($config, "/tmp", $save_temps);
    3238my $burntool = new czartool::Burntool();
    3339
    34 
    35 $czarDb->setDateFormat("%Y%m%d-%H%i%s");
    3640
    3741my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
     
    110114    my $today = undef;
    111115    my $yesterday = undef;
    112     my $newDayTime = "18:00";
     116    my $newDayTime = $config->getMetricsStartTime();
    113117    my $lastDayDailyTasks = "2010-01-01";
    114118
     
    136140                print "* Creating metrics for last 24 hours\n";
    137141                # 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                my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $today);
    142143                $dayMetrics->writeHTML();
    143144
    144145                # now update metrics index page
    145                 my $metricsIndex = new czartool::MetricsIndex($gpc1Db,
    146                         $czarDb,
    147                         "/data/ipp004.0/ipp/ippMetrics/",
    148                         1, 0);
     146                my $metricsIndex = new czartool::MetricsIndex($config, 1, 0);
    149147                $metricsIndex->writeHTML();
    150148
  • trunk/tools/czartool.pl

    r28925 r30250  
    66
    77# local classes
     8use czartool::Config;
    89use czartool::CzarDb;
    910use czartool::Gpc1Db;
     
    2223
    2324my @states = ("full", "new", "drop", "wait");
    24 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp");
    25 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser");
     25my $config = new czartool::Config();
     26my $czarDb = $config->getCzarDbInstance();
     27my $gpc1Db = $config->getGpc1Instance();
    2628my $pantasks = new czartool::Pantasks();
    27 $czarDb->setDateFormat("%Y%m%d-%H%i%s");
    2829
    2930my @stdscienceLabels = undef;
  • trunk/tools/czartool/DayMetrics.pm

    r30099 r30250  
    2828    # Call the constructor of the parent class
    2929    my $self = $class->SUPER::new(
    30             $_[1],  # gpc1Db
    31             $_[2],  # czarDb
    32             $_[3],  # baseDir
    33             $_[4],  # verbose
    34             $_[5]   # save_temps
     30            $_[1],  # config object
     31            $_[2],  # verbose
     32            $_[3]   # save_temps
    3533            );
    3634
    37     $self->{day} = $_[6];
     35    $self->{day} = $_[4];
    3836
    3937    my $yesterday =  $self->{czarDb}->subtractInterval($self->{day}, "1 DAY");
    4038
    4139    # sort out times
    42     $self->{begin} =  "$yesterday 18:00";
     40    $self->{begin} =  "$yesterday " . $self->{config}->getMetricsStartTime();
    4341    $self->{end} = $self->{czarDb}->addInterval($self->{begin}, "1 DAY");
    4442    $self->{burntoolEnd} = $self->{czarDb}->addInterval($self->{begin}, "12 HOUR");
  • trunk/tools/czartool/Metrics.pm

    r29964 r30250  
    2424    my $class = shift;
    2525    my $self = {
    26         gpc1Db => shift,
    27         czarDb => shift,
    28         baseDir => shift,
     26        config => shift,
    2927        verbose => shift,
    3028        save_temps => shift,
    3129    };
     30
     31    $self->{gpc1Db} = $self->{config}->getGpc1Instance();
     32    $self->{czarDb} = $self->{config}->getCzarDbInstance();
     33    $self->{baseDir} = $self->{config}->getMetricsSaveLocation();
    3234
    3335    # create path, dir
     
    3638    # instantiate a plotter object
    3739    $self->{plotter} = czartool::Plotter->new_file(
    38             $self->{gpc1Db},
    39             $self->{czarDb},
     40            $self->{config},
    4041            ".",
    4142            $self->{save_temps});
  • trunk/tools/czartool/MetricsIndex.pm

    r29859 r30250  
    2828    # Call the constructor of the parent class
    2929    my $self = $class->SUPER::new(
    30             $_[1],  # gpc1Db
    31             $_[2],  # czarDb
    32             $_[3],  # baseDir
    33             $_[4],  # verbose
    34             $_[5]   # save_temps
     30            $_[1],  # config object
     31            $_[2],  # verbose
     32            $_[3]   # save_temps
    3533            );
    3634
  • trunk/tools/czartool/MultiDayMetrics.pm

    r29860 r30250  
    2828    # Call the constructor of the parent class
    2929    my $self = $class->SUPER::new(
    30             $_[1],  # gpc1Db
    31             $_[2],  # czarDb
    32             $_[3],  # baseDir
    33             $_[4],  # verbose
    34             $_[5]   # save_temps
     30            $_[1],  # config object
     31            $_[2],  # verbose
     32            $_[3]   # save_temps
    3533            );
    3634
    37     $self->{startDay} = $_[6];
    38     $self->{endDay} = $_[7];
     35    $self->{startDay} = $_[4];
     36    $self->{endDay} = $_[5];
    3937
    4038    # sort out times
    41     $self->{begin} =  "$self->{startDay} 06:00";
    42     $self->{end} =  "$self->{endDay} 06:00";
     39    $self->{begin} =  "$self->{startDay} " . $self->{config}->getMetricsStartTime();
     40    $self->{end} =  "$self->{endDay} " . $self->{config}->getMetricsStartTime();
    4341
    4442    # create path, dir and html file
  • trunk/tools/czartool/Plotter.pm

    r29951 r30250  
    77
    88use File::Temp;
     9
     10use czartool::Config;
    911
    1012my @allStages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
     
    1820    my $class = shift;
    1921    my $self = {
    20         _gpc1Db => shift,
    21         _czarDb => shift,
     22        _config => shift,
    2223        _dateFormat => shift,
    2324        _outputFormat => shift,
     
    2728
    2829    bless $self, $class;
     30    $self->init();
    2931    return $self;
    3032}
     
    3840    my $class = shift;
    3941    my $self = {
    40         _gpc1Db => shift,
    41         _czarDb => shift,
     42        _config => shift,
    4243        _outputPath => shift,
    4344        _save_temps => shift,
    4445                                                    };
    45 
    4646    $self->{_dateFormat} = "%Y%m%d-%H%M%S";
    47     $self->{_outputFormat} = "png font \"/usr/share/fonts/corefonts/arial.ttf\" 8"; # TODO path needs to be in config
    48 
    49         bless $self, $class;
     47    $self->{_outputFormat} = "png font \"".$self->{_config}->getGnuplotFont()."\" ".$self->{_config}->getGnuplotFontSize();
     48
     49    bless $self, $class;
     50    $self->init();
    5051    return $self;
    5152}
     
    5960    my $class = shift;
    6061    my $self = {
    61         _gpc1Db => shift,
    62         _czarDb => shift,
     62        _config => shift,
    6363        _save_temps => shift,
    6464    };
     
    6969
    7070    bless $self, $class;
     71    $self->init();
    7172    return $self;
    7273}
    7374
    74 
     75###########################################################################
     76#
     77# Some initialisation code common to all constructors
     78#
     79###########################################################################
     80sub init {
     81    my ($self) = @_;
     82
     83    $self->{_gpc1Db} = $self->{_config}->getGpc1Instance();
     84    $self->{_czarDb} = $self->{_config}->getCzarDbInstance();
     85}
    7586
    7687###########################################################################
  • trunk/tools/czartool/czarconfig.xml

    r30244 r30250  
    1010  <metrics>
    1111    <savelocation>/data/ipp004.0/ipp/ippMetrics</savelocation>
    12     <starttime>06:00</starttime>
     12    <starttime>18:00</starttime>
    1313  </metrics>
    1414
     
    2727  </czardatabase>
    2828
     29  <roboczar>
     30    <email>ps-ipp-ops@ifa.hawaii.edu</email>
     31    <serverinterval>20 MINUTE</serverinterval>
     32  </roboczar>
    2933</czarconfig>
  • trunk/tools/roboczar.pl

    r29804 r30250  
    77
    88# local classes
     9use czartool::Config;
    910use czartool::CzarDb;
    1011use czartool::Gpc1Db;
     
    1516use czartool::StageMetrics;
    1617
    17 my $czarDbName = "czardb"; # TODO variables for other Db stuff, host etc
    1818my $save_temps = 0;
    1919
    20 GetOptions (
    21         "dbname|d=s" => \$czarDbName,
    22         );
    23 
    24 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", 0, $save_temps); # TODO last arg here is save_temps, should get as arg
    25 
    26 $czarDb->setDateFormat("%Y%m%d-%H%i%s");
     20my $config = new czartool::Config();
     21my $czarDb = $config->getCzarDbInstance();
    2722
    2823my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); # TODO get from Pantasks
     
    4136    $message = "";
    4237
    43     if (anyStoppedServers("20 MINUTE", \$serversMessage)) {
     38    if (anyStoppedServers($config->getRoboczarServerInterval(), \$serversMessage)) {
    4439
    4540        $message .= "\n\n" . $serversMessage;
    4641        $anythingToReport = 1;
    4742    }
    48     if (anyStuckStages("2 HOUR", \$stuckMessage)) {
     43#    if (anyStuckStages("2 HOUR", \$stuckMessage)) {
    4944
    50         $message .= "\n\n" . $stuckMessage;
    51         $anythingToReport = 1;
    52     }
     45 #       $message .= "\n\n" . $stuckMessage;
     46  #      $anythingToReport = 1;
     47   # }
    5348
    5449    if ($anythingToReport && $message ne $lastMessage) {
     
    5651print "\n\n$message\n\n";
    5752
    58         sendEmail(
    59                 "ps-ipp-ops\@ifa.hawaii.edu",
     53        sendEmail($config->getRoboczarEmail(),
    6054                "Roboczar warnings",
    6155                "$message\n");
     
    8276    my $anyStuckStages = 0;
    8377
    84     # exception - we don't care if burntool is stalled before 6:30am
     78    # exception - we don't care if burntool is stalled before 6:30am TODO we do now
    8579    my $burntime = strftime('%Y-%m-%d 06:35', localtime);
    8680    my $worryAboutBurntool = $czarDb->isBefore($burntime, $end);
Note: See TracChangeset for help on using the changeset viewer.