/* This reads in data from file and makes 4 gif plots for display via Web page. Gifs are 24hr, 48hr, 7day and 30day plots of running job counts. */ #include "Riostream.h" #include #include void plotJobs_MP8( void ) { gROOT->Reset(); gROOT->SetStyle("Plain"); TDatime da(2000,01,01,00,00,00); int plotOff = da.Convert(); char out[] = "temp.txt"; ofstream outFile; outFile.open(out); ifstream in1; long iTime[30000], year[30000], mon[30000], day[30000], hour[30000], min[30000]; long offsetTime; long lastReadTime; long firstYear, firstMon, firstDay, firstHour, firstMin; double maxTime; double firstTime24, firstTime48, firstTime7d, firstTime30d; double firstTime02, firstTime06, firstTime12; double fTime[30000]; double T2TotalRun[30000], T2TotalIdle[30000]; long counter; int n; double maxY24, maxY48, maxY7d, globalMaxY; double maxYI24, maxYI48, maxYI7d, globalMaxYI; double maxY02, maxY06, maxY12; double maxYI02, maxYI06, maxYI12; in1.open("MPmon_count.log"); n = 0; maxY24 = 0.; maxY48 = 0.; maxY7d = 0.; globalMaxY = 0.; maxY02 = 0.; maxY06 = 0.; maxY12 = 0.; maxYI24 = 0.; maxYI48 = 0.; maxYI7d = 0.; globalMaxYI = 0.; maxYI02 = 0.; maxYI06 = 0.; maxYI12 = 0.; /* Data Input is 1 $runCount running MP8 jobs on gate01 2 $idleCount idle MP8 jobs on gate01 */ while(1) { in1 >> iTime[n] >> year[n] >> mon[n] >> day[n] >> hour[n] >> min[n] >> T2TotalRun[n] >> T2TotalIdle[n]; if( !in1.good() ) break; iTime[n] -= plotOff; if( n==0 ) { offsetTime=0; // offsetTime=6*3600; // Take care of GMT vs EST5/EDT firstYear=year[n]; firstMon=mon[n]; firstDay=day[n]; firstHour=hour[n]; firstMin=min[n]; lastReadTime = iTime[n]; fTime[n] = iTime[n]+offsetTime; maxTime = iTime[n]+offsetTime; // Offset is 14418, with this "test" conversion that much larger. // This is almost exactly 4 hours (14400), or GMT to EST5/EDT. // ======> Close holes in the cron records. A typical gap is 5min <======= } else { fTime[n] = iTime[n]+offsetTime; maxTime = iTime[n]+offsetTime; if( (iTime[n]-lastReadTime) > 420 ) { // cout << "Found time hole at " << mon[n] << " " << day[n] << " " // << hour[n] << " " << min[n] << "\n"; // Move just-read times out 2 slots iTime[n+2] = iTime[n]; year[n+2] = year[n]; mon[n+2] = mon[n]; day[n+2] = day[n]; hour[n+2] = hour[n]; min[n+2] = min[n]; T2TotalRun[n+2] = 0; T2TotalIdle[n+2] = 0; fTime[n+2] = fTime[n]; // Insert zero counters 1 minute after the previous slot // Adjust hours, minutes and days, but don't check for month/year issues iTime[n] = iTime[n-1]+60; year[n] = year[n-1]; mon[n] = mon[n-1]; day[n] = day[n-1]; hour[n] = hour[n-1]; if( min[n-1] == 59 ) { min[n] = 0; if( hour[n-1] == 23 ) { hour[n] = 0; day[n]++; } else { hour[n]++; } } else { min[n] = min[n-1]+1; } T2TotalRun[n] = 0; T2TotalIdle[n] = 0; fTime[n] = iTime[n]+offsetTime; // Insert zero counters 1 minute before the moved slot // Adjust hours, minutes and days, but don't check for month/year issues iTime[n+1] = iTime[n+2]-60; year[n+1] = year[n+2]; mon[n+1] = mon[n+2]; day[n+1] = day[n+2]; hour[n+1] = hour[n+2]; if( min[n+2] == 0 ) { min[n+1] = 59; if( hour[n+1] == 0 ) { hour[n+1] = 23; day[n+1] = day[n+1] - 1; } else { hour[n+1] = hour[n+1] - 1; } } else { min[n+1] = min[n+2]-1; } T2TotalRun[n+1] = 0; T2TotalIdle[n+1] = 0; fTime[n+1] = iTime[n+1]+offsetTime; n = n+2; } lastReadTime = iTime[n]; } n++; } in1.close(); firstTime24 = maxTime - 86400.; // One day firstTime48 = maxTime - 2.*86400.; // Two days firstTime7d = maxTime - 7.*86400.; // Seven days firstTime30d = maxTime - 30.*86400.; // Thirty days firstTime02 = maxTime - 2.*3600.; // Two hours firstTime06 = maxTime - 6.*3600.; // Six hours firstTime12 = maxTime - 12.*3600.; // Twelve hours for( counter=0; counter= firstTime02) { if( T2TotalRun[counter] > maxY02 ) maxY02 = T2TotalRun[counter]; if( T2TotalIdle[counter] > maxYI02 ) maxYI02 = T2TotalIdle[counter]; } if (fTime[counter] >= firstTime06) { if( T2TotalRun[counter] > maxY06 ) maxY06 = T2TotalRun[counter]; if( T2TotalIdle[counter] > maxYI06 ) maxYI06 = T2TotalIdle[counter]; } if (fTime[counter] >= firstTime12) { if( T2TotalRun[counter] > maxY12 ) maxY12 = T2TotalRun[counter]; if( T2TotalIdle[counter] > maxYI12 ) maxYI12 = T2TotalIdle[counter]; } if (fTime[counter] >= firstTime24) { if( T2TotalRun[counter] > maxY24 ) maxY24 = T2TotalRun[counter]; if( T2TotalIdle[counter] > maxYI24 ) maxYI24 = T2TotalIdle[counter]; } if (fTime[counter] > firstTime48) { if( T2TotalRun[counter] > maxY48 ) maxY48 = T2TotalRun[counter]; if( T2TotalIdle[counter] > maxYI48 ) maxYI48 = T2TotalIdle[counter]; } if (fTime[counter] > firstTime7d) { if( T2TotalRun[counter] > maxY7d ) maxY7d = T2TotalRun[counter]; if( T2TotalIdle[counter] > maxYI7d ) maxYI7d = T2TotalIdle[counter]; } if( T2TotalRun[counter] > globalMaxY ) globalMaxY = T2TotalRun[counter]; if( T2TotalIdle[counter] > globalMaxYI ) globalMaxYI = T2TotalIdle[counter]; } maxY24 = ((long)(maxY24/10.) + 2)*10.; maxY48 = ((long)(maxY48/10.) + 2)*10.; maxY7d = ((long)(maxY7d/10.) + 2)*10.; globalMaxY = ((long)(globalMaxY/10.) + 2)*10.; maxY02 = ((long)(maxY02/10.) + 2)*10.; maxY06 = ((long)(maxY06/10.) + 2)*10.; maxY12 = ((long)(maxY12/10.) + 2)*10.; maxYI24 = ((long)(maxYI24/10.) + 1)*10.; maxYI48 = ((long)(maxYI48/10.) + 1)*10.; maxYI7d = ((long)(maxYI7d/10.) + 1)*10.; globalMaxYI = ((long)(globalMaxYI/10.) + 1)*10.; maxYI02 = ((long)(maxYI02/10.) + 1)*10.; maxYI06 = ((long)(maxYI06/10.) + 1)*10.; maxYI12 = ((long)(maxYI12/10.) + 1)*10.; // TDatime da(firstYear, firstMon, firstDay, firstHour, firstMin, 00); // gStyle->SetTimeOffset(da.Convert()); TGraph *d_1 = new TGraph( n, fTime, T2TotalRun ); TGraph *d_2 = new TGraph( n, fTime, T2TotalIdle ); // Create a canvas. topx topy width height TCanvas *c1 = new TCanvas("c1","AGLT2 Job Mix",800,800); // 200, 10, 600, 400 c1->SetFillColor(kWhite); c1->Divide(1,2); c1->cd(1); d_1->SetLineColor(1); d_1->SetLineWidth(3); // d_1->GetXaxis()->SetTitle("Time"); d_1->GetYaxis()->SetTitle("Running Jobs"); d_1->GetYaxis()->CenterTitle(); d_1->GetXaxis()->SetTimeDisplay(1); d_1->GetXaxis()->SetTimeFormat("#splitline{%m/%d}{%H:%M}"); d_1->GetXaxis()->SetLabelOffset(0.02); // d_1->GetXaxis()->SetTitleOffset(1.4); // d_1->GetXaxis()->SetTextAngle(12); d_1->GetXaxis()->SetRangeUser(firstTime24, maxTime); d_1->GetXaxis()->SetTimeOffset(plotOff); d_1->GetYaxis()->SetRangeUser(0., maxY24); d_1->SetTitle("Job Count History 24Hr"); d_1->SetMinimum(0.); d_1->Draw("LA1"); c1->cd(2); d_2->SetLineColor(1); d_2->SetLineWidth(3); // d_2->GetXaxis()->SetTitle("Time"); d_2->GetYaxis()->SetTitle("Queued Jobs"); d_2->GetYaxis()->CenterTitle(); d_2->GetXaxis()->SetTimeDisplay(1); d_2->GetXaxis()->SetTimeFormat("#splitline{%m/%d}{%H:%M}"); d_2->GetXaxis()->SetLabelOffset(0.02); // d_2->GetXaxis()->Print(); // d_2->GetXaxis()->SetTitleOffset(1.6); // d_2->GetXaxis()->SetTextAngle(12); d_2->GetXaxis()->SetRangeUser(firstTime24, maxTime); d_2->GetXaxis()->SetTimeOffset(plotOff); d_2->GetYaxis()->SetRangeUser(0., maxYI24); d_2->SetTitle("Job Count History 24Hr"); d_2->SetMinimum(0.); d_2->Draw("LA1"); TPaveText *Info = new TPaveText(0.35, 0.93, 0.5, 1.0, "NDCUL"); TText *t1=Info->AddText(0.5, 0.5, "MCORE-8 Jobs"); t1->SetTextColor(1); t1->SetTextSize(0.03); Info->Draw(); c1->Update(); // See TPaveText for adding a text box // TGaxis may be useful for the date/time on the x-axis c1->Print("plotMP8Jobs24.gif"); // Now do the 48 hour plot c1->cd(1); d_1->GetXaxis()->SetRangeUser(firstTime48, maxTime); d_1->GetYaxis()->SetRangeUser(0., maxY48); d_2->GetYaxis()->SetRangeUser(0., maxYI48); d_1->SetTitle("Job Count History 48Hr"); d_2->GetXaxis()->SetRangeUser(firstTime48, maxTime); d_2->SetTitle("Job Count History 48Hr"); d_1->Draw("LA1"); c1->cd(2); d_2->Draw("LA1"); Info->Draw("L1"); c1->Update(); c1->Print("plotMP8Jobs48.gif"); // Now do the 7-day plot // For this and the 30-day plot, use a smaller line width d_1->SetLineWidth(2); d_2->SetLineWidth(2); c1->cd(1); d_1->GetXaxis()->SetRangeUser(firstTime7d, maxTime); d_1->GetYaxis()->SetRangeUser(0., maxY7d); d_2->GetYaxis()->SetRangeUser(0., maxYI7d); d_1->SetTitle("Job Count History 7Day"); d_2->GetXaxis()->SetRangeUser(firstTime7d, maxTime); d_2->SetTitle("Job Count History 7Day"); d_1->Draw("LA1"); c1->cd(2); d_2->Draw("LA1"); Info->Draw("L1"); c1->Update(); c1->Print("plotMP8Jobs7d.gif"); // Now do the 30-day plot c1->cd(1); d_1->GetXaxis()->SetRangeUser(firstTime30d, maxTime); d_1->SetTitle("Job Count History 30Day"); d_2->GetXaxis()->SetRangeUser(firstTime30d, maxTime); d_1->GetYaxis()->SetRangeUser(0., globalMaxY); d_2->GetYaxis()->SetRangeUser(0., globalMaxYI); d_2->SetTitle("Job Count History 30Day"); d_1->Draw("LA1"); c1->cd(2); d_2->Draw("LA1"); Info->Draw("L1"); c1->Update(); c1->Print("plotMP8Jobs30d.gif"); // Now do the 2-hour plot c1->cd(1); d_1->GetXaxis()->SetRangeUser(firstTime02, maxTime); d_1->SetTitle("Job Count History 2 Hours"); d_2->GetXaxis()->SetRangeUser(firstTime02, maxTime); d_1->GetYaxis()->SetRangeUser(0., maxY02); d_2->GetYaxis()->SetRangeUser(0., maxYI02); d_2->SetTitle("Job Count History 2 Hours"); d_1->Draw("LA1"); c1->cd(2); d_2->Draw("LA1"); Info->Draw("L1"); c1->Update(); c1->Print("plotMP8Jobs02.gif"); // Now do the 6 hour plot c1->cd(1); d_1->GetXaxis()->SetRangeUser(firstTime06, maxTime); d_1->SetTitle("Job Count History 6 Hours"); d_2->GetXaxis()->SetRangeUser(firstTime06, maxTime); d_1->GetYaxis()->SetRangeUser(0., maxY06); d_2->GetYaxis()->SetRangeUser(0., maxYI06); d_2->SetTitle("Job Count History 6 Hours"); d_1->Draw("LA1"); c1->cd(2); d_2->Draw("LA1"); Info->Draw("L1"); c1->Update(); c1->Print("plotMP8Jobs06.gif"); // Now do the 12 Hour plot c1->cd(1); d_1->GetXaxis()->SetRangeUser(firstTime12, maxTime); d_1->SetTitle("Job Count History 12 Hours"); d_2->GetXaxis()->SetRangeUser(firstTime12, maxTime); d_1->GetYaxis()->SetRangeUser(0., maxY12); d_2->GetYaxis()->SetRangeUser(0., maxYI12); d_2->SetTitle("Job Count History 12 Hours"); d_1->Draw("LA1"); c1->cd(2); d_2->Draw("LA1"); Info->Draw("L1"); c1->Update(); c1->Print("plotMP8Jobs12.gif"); } //end read_rt