IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30274


Ignore:
Timestamp:
Jan 13, 2011, 1:08:55 PM (15 years ago)
Author:
rhenders
Message:

Added czar-database clean-up interval to config file, and changed relevant code in czartool (interval is 30 minutes)

Location:
trunk/tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czarclean.pl

    r29278 r30274  
    66
    77# local classes
     8use czartool::Config;
    89use czartool::CzarDb;
    910
    1011my $czarDbName = undef;
    11 my $from = undef;
    12 my $to = undef;
     12my $begin = undef;
     13my $end = undef;
    1314my $interval = undef;
    1415my $verbose = undef;
    1516my $optimize = undef;
     17my $config = new czartool::Config();
    1618
    1719GetOptions (
    1820        "dbname|d=s" => \$czarDbName,
    1921        "interval|i=s" => \$interval,
    20         "from|f=s" => \$from,
    21         "to|t=s" => \$to,
     22        "begin|b=s" => \$begin,
     23        "end|e=s" => \$end,
    2224        "optimize|o" => \$optimize,
    2325        "verbose|v" => \$verbose,
     
    3234    print "* UNKNKOWN: option                          @ARGV\n";
    3335}
    34 if (!$from) {
     36if (!$begin) {
    3537    $quit=1;
    36     print "* REQUIRED: choose a from date                 -b <datetime>\n";
     38    print "* REQUIRED: choose a begin date                -b <datetime>\n";
    3739}
    38 if (!$to) {
    39     if($from) {$to=$from;} else {$to="NULL";}
    40     print "* OPTIONAL: choose a to date                   -e <datetime>                   (default=$to)\n";
     40if (!$end) {
     41    if($begin) {$end=$begin;} else {$end="NULL";}
     42    print "* OPTIONAL: choose an end date date            -e <datetime>                   (default=$end)\n";
    4143}
    4244if (!$czarDbName) {
     
    4547}
    4648if (!$interval) {
    47     $interval = "30 MINUTE";
    48     print "* OPTIONAL: choose time interval               -i <'30 MINUTE'|'1 hour'|etc>   (default=$interval)\n";
     49    print "* OPTIONAL: choose time interval               -i <'30 MINUTE'|'1 hour'|etc>   (default=".$config->getCzarCleanupInterval().")\n";
    4950}
    5051if (!$optimize) {
    5152    $optimize = 0;
    52     print "* OPTIONAL: optimize database after cleanup    -o <'30 MINUTE'|'1 hour'|etc>   (default=$interval)\n";
     53    print "* OPTIONAL: optimize database after cleanup    -o                              (default=$optimize)\n";
    5354}
    5455print "*\n*******************************************************************************\n";
     
    5657if ($quit) { exit; }
    5758
    58 
    59 my $save_temps = 0;
    60 
    61 
    62 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", 0, $save_temps); # TODO last arg here is save_temps, should get as arg
     59my $czarDb = $config->getCzarDbInstance();
    6360
    6461my $labels = undef;
    6562
    6663
    67 $czarDb->cleanupDateRange($from, $to, $interval);
     64$czarDb->cleanupDateRange($begin, $end, $config->getCzarCleanupInterval());
    6865if ($optimize) {$czarDb->optimize();}
  • trunk/tools/czarpoll.pl

    r30250 r30274  
    139139                # create metrics for last 24 hours
    140140                print "* Creating metrics for last 24 hours\n";
    141                 # TODO hardcoded path needs to be in config
    142141                my $dayMetrics = new czartool::DayMetrics($config, 1, 0, $today);
    143142                $dayMetrics->writeHTML();
     
    149148                # now cleanup tables from yesterday and optimize
    150149                print "* New day - performing cleanup\n";
    151                 $czarDb->cleanupDateRange($yesterday, $yesterday, "30 MINUTE");
     150                $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval());
    152151                $czarDb->optimize();
    153152                $lastDayDailyTasks = $yesterday;
  • trunk/tools/czartool/Config.pm

    r30250 r30274  
    6161    $self->{czaruser} = $xc->findvalue('//czardatabase/user');
    6262    $self->{czarpassword} = $xc->findvalue('//czardatabase/password');
     63    $self->{czardbcleanupinterval} = $xc->findvalue('//czardatabase/cleanupinterval');
    6364
    6465    # roboczar
     
    105106###########################################################################
    106107#
     108# Returns the interval used in czarDB cleanup
     109#
     110###########################################################################
     111sub getCzarCleanupInterval {
     112    my ($self) = @_;
     113    return $self->{czardbcleanupinterval};
     114}
     115
     116###########################################################################
     117#
    107118# Returns the interval after which we consider a server to be down/stopped
    108119#
  • trunk/tools/czartool/czarconfig.xml

    r30250 r30274  
    2525    <user>ipp</user>
    2626    <password>ipp</password>
     27    <cleanupinterval>30 MINUTE</cleanupinterval>
    2728  </czardatabase>
    2829
Note: See TracChangeset for help on using the changeset viewer.