IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 31, 2011, 2:51:48 PM (15 years ago)
Author:
eugene
Message:

merging changes from trunk

File:
1 edited

Legend:

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

    r30102 r30446  
    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
    3440
    35 $czarDb->setDateFormat("%Y%m%d-%H%i%s");
    36 
    3741my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
    3842
    3943
    4044timePoll($period);
     45
     46###########################################################################
     47#
     48# Updates the dates from pantasks for all interested servers
     49#
     50###########################################################################
     51sub updateDates {
     52
     53    print "* Updating dates\n";
     54    my @servers = ("stdscience", "registration");
     55
     56    my $server = undef;
     57    $czarDb->emptyServerDates();
     58    foreach $server (@servers) {
     59
     60        my @dates = @{$pantasks->getDates($server)};
     61        if (@dates) {
     62
     63            $czarDb->updateServerDates($server, \@dates);
     64        }
     65        else {
     66
     67            print "WARNING: No dates to update for '$server'\n";
     68        }
     69    }
     70}
    4171
    4272###########################################################################
     
    5585        my @labels = @{$pantasks->getLabels($server)};
    5686        if (@labels) {
    57        
     87
    5888            $czarDb->updateCurrentLabels($server, \@labels);
    5989        }
    6090        else {
    61        
    62              print "WARNING: No labels to update for '$server'\n";
     91
     92            print "WARNING: No labels to update for '$server'\n";
    6393        }
    6494    }
     
    110140    my $today = undef;
    111141    my $yesterday = undef;
    112     my $newDayTime = "18:00";
     142    my $newDayTime = $config->getMetricsStartTime();
    113143    my $lastDayDailyTasks = "2010-01-01";
    114144
     
    125155        # if after 18:00 today, then perform some daily tasks and start plots from 18:00 today
    126156        else {
    127            
     157
    128158            $begin = "$today $newDayTime";
    129159
    130160            # check whether yesterday was cleaned. if not, cleanup tables and optimize
    131161            if ($lastDayDailyTasks ne $yesterday) {
    132    
     162
    133163                print "* performing daily tasks (clean-up, metrics)";
    134164
    135165                # create metrics for last 24 hours
    136166                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);
     167                my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $today);
    142168                $dayMetrics->writeHTML();
    143169
    144170                # now update metrics index page
    145                 my $metricsIndex = new czartool::MetricsIndex($gpc1Db,
    146                         $czarDb,
    147                         "/data/ipp004.0/ipp/ippMetrics/",
    148                         1, 0);
     171                my $metricsIndex = new czartool::MetricsIndex($config, 1, 0);
    149172                $metricsIndex->writeHTML();
    150173
    151174                # now cleanup tables from yesterday and optimize
    152175                print "* New day - performing cleanup\n";
    153                 $czarDb->cleanupDateRange($yesterday, $yesterday, "30 MINUTE");
     176                $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
    154177                $czarDb->optimize();
    155178                $lastDayDailyTasks = $yesterday;
     
    167190        $plotter->plotDiskUsageHistogram();
    168191        updateServerStatus();
     192
     193        # check pantasks dates
     194        updateDates();
    169195
    170196        # check labels
Note: See TracChangeset for help on using the changeset viewer.