Changeset 30446 for branches/eam_branches/ipp-20101205/tools/czarpoll.pl
- Timestamp:
- Jan 31, 2011, 2:51:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/tools/czarpoll.pl
r30102 r30446 1 1 #!/usr/bin/perl -w 2 3 ########################################################################### 4 # 5 # Main polling program for czartool. Grabs stuff from various sources every few minutes. 6 # 7 ########################################################################### 2 8 3 9 use warnings; … … 7 13 8 14 # local classes 15 use czartool::Config; 9 16 use czartool::CzarDb; 10 17 use czartool::Gpc1Db; … … 17 24 18 25 my $period = 60; 19 my $czarDbName = "czardb"; # TODO variables for other Db stuff, host etc20 26 my $save_temps = 0; 21 27 22 28 GetOptions ( 23 29 "period|p=s" => \$period, # TODO more Db args 24 "dbname|d=s" => \$czarDbName,25 30 ); 26 31 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"); 32 my $config = new czartool::Config(); 33 my $czarDb = $config->getCzarDbInstance(); 34 my $gpc1Db = $config->getGpc1Instance; 29 35 my $nebulous = new czartool::Nebulous($czarDb); 30 36 my $pantasks = new czartool::Pantasks(); 31 my $plotter = czartool::Plotter->new_file($ gpc1Db, $czarDb, "/tmp", $save_temps);37 my $plotter = czartool::Plotter->new_file($config, "/tmp", $save_temps); 32 38 my $burntool = new czartool::Burntool(); 33 39 34 40 35 $czarDb->setDateFormat("%Y%m%d-%H%i%s");36 37 41 my @stages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); 38 42 39 43 40 44 timePoll($period); 45 46 ########################################################################### 47 # 48 # Updates the dates from pantasks for all interested servers 49 # 50 ########################################################################### 51 sub 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 } 41 71 42 72 ########################################################################### … … 55 85 my @labels = @{$pantasks->getLabels($server)}; 56 86 if (@labels) { 57 87 58 88 $czarDb->updateCurrentLabels($server, \@labels); 59 89 } 60 90 else { 61 62 print "WARNING: No labels to update for '$server'\n";91 92 print "WARNING: No labels to update for '$server'\n"; 63 93 } 64 94 } … … 110 140 my $today = undef; 111 141 my $yesterday = undef; 112 my $newDayTime = "18:00";142 my $newDayTime = $config->getMetricsStartTime(); 113 143 my $lastDayDailyTasks = "2010-01-01"; 114 144 … … 125 155 # if after 18:00 today, then perform some daily tasks and start plots from 18:00 today 126 156 else { 127 157 128 158 $begin = "$today $newDayTime"; 129 159 130 160 # check whether yesterday was cleaned. if not, cleanup tables and optimize 131 161 if ($lastDayDailyTasks ne $yesterday) { 132 162 133 163 print "* performing daily tasks (clean-up, metrics)"; 134 164 135 165 # create metrics for last 24 hours 136 166 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); 142 168 $dayMetrics->writeHTML(); 143 169 144 170 # 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); 149 172 $metricsIndex->writeHTML(); 150 173 151 174 # now cleanup tables from yesterday and optimize 152 175 print "* New day - performing cleanup\n"; 153 $czarDb->cleanupDateRange($yesterday, $yesterday, "30 MINUTE");176 $czarDb->cleanupDateRange($yesterday, $yesterday, $config->getCzarCleanupInterval()); 154 177 $czarDb->optimize(); 155 178 $lastDayDailyTasks = $yesterday; … … 167 190 $plotter->plotDiskUsageHistogram(); 168 191 updateServerStatus(); 192 193 # check pantasks dates 194 updateDates(); 169 195 170 196 # check labels
Note:
See TracChangeset
for help on using the changeset viewer.
