Changeset 38258 for trunk/ippMonitor/czartool/czarpoll.pl
- Timestamp:
- May 13, 2015, 9:19:19 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/ippMonitor/czartool/czarpoll.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippMonitor/czartool/czarpoll.pl
r38251 r38258 26 26 27 27 GetOptions ( 28 "period|p=s" => \$period, # TODO more Db args28 "period|p=s" => \$period, 29 29 ); 30 30 … … 35 35 my $nebulous = new czartool::Nebulous($czarDb); 36 36 my $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 39 my $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 42 my $plotter1 = czartool::Plotter->new_file($config, $gpc1Db, $config->getGnuplotPath() . "/gpc1", $save_temps); 43 my $plotter2 = czartool::Plotter->new_file($config, $gpc2Db, $config->getGnuplotPath() . "/gpc2", $save_temps); 39 44 40 45 my @stages = ( … … 59 64 "merged", 60 65 "deleted_local"); 66 67 # The ippToPsps pages are no longer operational 68 @ippToPspsStages = (); 61 69 62 70 my @allStages = (@stages, @ippToPspsStages); … … 167 175 while (1) { 168 176 177 my $iterationStartTime = time(); 178 169 179 # sort out times 170 180 $today = strftime('%Y-%m-%d', localtime); … … 172 182 $end = $czarDb->getNowTimestamp(); 173 183 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 178 189 179 190 $begin = "$today $newDayTime"; … … 186 197 # create metrics for last 24 hours 187 198 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); 189 200 $dayMetrics->writeHTML(); 190 201 191 202 # now update metrics index page 192 my $metricsIndex = new czartool::MetricsIndex($config, 1, 0);203 my $metricsIndex = new czartool::MetricsIndex($config, $gpc1Db, 1, 0); 193 204 $metricsIndex->writeHTML(); 194 205 … … 210 221 print "* Checking Nebulous\n"; 211 222 $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(); 215 226 updateServerStatus(); 216 227 … … 239 250 foreach $row ( @{$labels} ) { 240 251 my ($label) = @{$row}; 252 # for now use priorities from gpc1 database 241 253 $priority = $gpc1Db->getPriority($label); 242 254 $czarDb->setLabelPriority($label, $priority); … … 244 256 245 257 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 } 247 262 } 248 263 else { print "* WARNING: no $thisServer labels found in Db\n";} 249 264 } 250 265 266 my $iterationTime = time() - $iterationStartTime; 267 268 print "done with czarpoll iteration after $iterationTime seconds\n"; 269 251 270 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 } 255 276 }; 256 277 } … … 262 283 ########################################################################### 263 284 sub createPlots { 264 my ($server, $ rows, $begin, $end) = @_;285 my ($server, $plotter, $rows, $begin, $end) = @_; 265 286 266 287 my $stage = undef; 267 288 my $row = undef; 268 289 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 278 312 foreach $row ( @{$ippToPspsLabels} ) { 279 313 my ($label) = @{$row}; 280 314 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 } 293 318 294 319 # create plots for each label for each stage 295 320 $plotter->setStandardMode(); 321 296 322 foreach $stage (@stages) { 297 323 foreach $row ( @{$rows} ) { 298 324 my ($label) = @{$row}; 299 325 326 # skip update labels for now. The plots are not relevant. 327 next if $label =~ 'ps_ud'; 328 300 329 chomp($label); 301 330 $plotter->createTimeSeries($label, $stage, $begin, $end, 1, 0, 1); … … 308 337 foreach $row ( @{$rows} ) { 309 338 my ($label) = @{$row}; 339 340 # skip update labels for now. The plots are not relevant. 341 next if $label =~ 'ps_ud'; 310 342 311 343 $plotter->createTimeSeries($label, undef, $begin, $end, 1, 1, 1); … … 362 394 chomp($label); 363 395 396 # Move this to a function and pass in the database 364 397 $new = $gpc1Db->countExposures($label, $stage, $newState); 365 398 $full = $gpc1Db->countExposures($label, $stage, "full");
Note:
See TracChangeset
for help on using the changeset viewer.
