//-------------------------------------------------------------------------------------------------- void plotSmartCacheRequests() { TDatime date; TString dateTime = date.AsSQLString(); TString text; TString save; long int durationHour = 3600; long int durationDay = 24 * 3600; long int durationWeek = 7 * 24 * 3600; long int durationMonth = 4 * 7 * 24 * 3600; long int xStart, xStop; time_t t; time(&t); long int time = (long int) t; // Access the database just once TString timeSeriesFile("requests.txt"); TString dbAccess("/home/cmsprod/DynamicData/SmartCache/Client/dumpSmartCacheHistoryDb.py"); // remove potentially existing old file TString rmDbInfo = TString(".! rm -f ")+timeSeriesFile; gROOT->ProcessLine(rmDbInfo.Data()); // create fresh input file TString getDbInfo = TString(".! ") + dbAccess + TString(" -q"); gROOT->ProcessLine(getDbInfo.Data()); // All time xStart = 0; xStop = time; plot(xStart, xStop, "All time at "+dateTime, "AllTime"); // Month xStart = time - durationMonth; xStop = time; plot(xStart, xStop, "Last month at "+dateTime, "LastMonth"); // Week xStart = time - durationWeek; xStop = time; plot(xStart, xStop, "Last week at "+dateTime, "LastWeek"); // Day xStart = time - durationDay; xStop = time; plot(xStart, xStop, "Last day at "+dateTime, "LastDay"); // Hour xStart = time - durationHour; xStop = time; plot(xStart, xStop, "Last hour at "+dateTime, "LastHour"); return; }
//-------------------------------------------------------------------------------------------------- void plotSmartCacheTransferRate() { TDatime date; TString dateTime = date.AsSQLString(); TString text; long int durationHour = 3600; long int durationDay = 24 * 3600; long int durationWeek = 7 * 24 * 3600; long int durationMonth = 4 * 7 * 24 * 3600; long int xStart, xEnd; // Plot SmartCache tranfers during the last hour, day, week, month time_t t; time(&t); long int time = (long int) t; // Access the database just once TString timeSeriesFile("timeSeriesOfRates.txt"); TString dbAccess("/home/cmsprod/DynamicData/SmartCache/Client/snapshotSmartCacheHistoryDb.py"); // remove potentially existing old file TString rmDbInfo = TString(".! rm -f ")+timeSeriesFile; gROOT->ProcessLine(rmDbInfo.Data()); // create fresh input file TString getDbInfo = TString(".! ") + dbAccess + TString(" -q"); gROOT->ProcessLine(getDbInfo.Data()); // hour text = TString("Last Hour at ") + dateTime; xStart = time-durationHour; xEnd = time; plot(xStart,xEnd,text,"transferRateLastHour.png"); // day text = TString("Last Day at ") + dateTime; xStart = time-durationDay; xEnd = time; plot(xStart,xEnd,text,"transferRateLastDay.png"); // week text = TString("Last Week at ") + dateTime; xStart = time-durationWeek; xEnd = time; plot(xStart,xEnd,text,"transferRateLastWeek.png"); // week text = TString("Last Month at ") + dateTime; xStart = time-durationMonth; xEnd = time; plot(xStart,xEnd,text,"transferRateLastMonth.png"); }
//-------------------------------------------------------------------------------------------------- void plotSiteStatus() { TString fileName = gSystem->Getenv("SITE_MONITOR_FILE"); TString monitorDB = gSystem->Getenv("MONITOR_DB"); TDatime date; TString dateTime = date.AsSQLString(); TString pngFileName = fileName + TString(".png"); TString inputFile = fileName; // Make sure we have the right styles MitRootStyle::Init(); // Now open our database output printf(" Input file: %s\n",inputFile.Data()); ifstream input; input.open(inputFile.Data()); TString siteName; Int_t nLines=0; Double_t total=0, used=0, toDelete=0, lastCp=0; Double_t xMin=0, xMaxTb=0, xMax=0; // Loop over the file to determine our boundaries //----------------------------------------------- while (1) { // read in input >> siteName >> total >> used >> toDelete >> lastCp; // check it worked if (! input.good()) break; // show what we are reading if (nLines < 5) printf(" site=%s, total=%8f used=%f toDelete=%f lastCp=%f\n", siteName.Data(), total, used, toDelete, lastCp); if (used>xMax) xMax = used; nLines++; } input.close(); printf(" \n"); printf(" Found %d entries.\n",nLines); printf(" Found %.3f as maximum.\n",xMax); printf(" \n"); // book our histogram xMaxTb = 999.; xMax = 1.2; TString titles; titles = TString(); TH1D *hTotal = new TH1D("Total", "Total Space", 1000./20,xMin,xMaxTb); MitRootStyle::InitHist(hTotal,"","",kBlack); hTotal->SetTitle("; Total Storage [TB]; Number of Sites"); TH1D *hUsed = new TH1D("Used", "Used Space", 1000./20,xMin,xMaxTb); MitRootStyle::InitHist(hUsed, "","",kBlack); hUsed ->SetTitle("; Used Storage [TB]; Number of Sites"); TH1D *hToDelete = new TH1D("ToDelete","Space to Release", 1000./20,xMin,xMaxTb); MitRootStyle::InitHist(hToDelete,"","",kBlack); hToDelete->SetTitle("; Space to Release [TB]; Number of Sites"); TH1D *hLastCp = new TH1D("LastCp", "Last Copy space", 1000./20,xMin,xMaxTb); MitRootStyle::InitHist(hLastCp, "","",kBlack); hLastCp ->SetTitle("; Last Copy Size [TB]; Number of Sites"); TH1D *hLastCpFr = new TH1D("LastCpFr","Last CP fraction",20, xMin,xMax); MitRootStyle::InitHist(hLastCpFr,"","",kBlack); hLastCpFr->SetTitle("; Last Copy Filling Fraction; Number of Sites"); input.open(inputFile.Data()); while (1) { // read in input >> siteName >> total >> used >> toDelete >> lastCp; // check it worked if (! input.good()) break; hTotal ->Fill(total); hUsed ->Fill(used); hToDelete->Fill(toDelete); hLastCp ->Fill(lastCp); hLastCpFr->Fill(lastCp/total); // print some warnings if (lastCp/total > 0.7) { printf(" WARNING - Last copy space too large: %3.0f%% at %s\n", lastCp/total*100.,siteName.Data()); } nLines++; } input.close(); // draw the plots TCanvas *cv = 0; cv = new TCanvas(); cv->Draw(); hTotal->Draw("hist"); MitRootStyle::OverlayFrame(); MitRootStyle::AddText(TString("Date: ") + dateTime); cv->SaveAs(monitorDB+"/Total.png"); cv = new TCanvas(); cv->Draw(); hUsed->Draw("hist"); MitRootStyle::OverlayFrame(); MitRootStyle::AddText(TString("Date: ") + dateTime); cv->SaveAs(monitorDB+"/Used.png"); cv = new TCanvas(); cv->Draw(); hToDelete->Draw("hist"); MitRootStyle::OverlayFrame(); MitRootStyle::AddText(TString("Date: ") + dateTime); cv->SaveAs(monitorDB+"/ToDelete.png"); cv = new TCanvas(); cv->Draw(); hLastCp->Draw("hist"); MitRootStyle::OverlayFrame(); MitRootStyle::AddText(TString("Date: ") + dateTime); cv->SaveAs(monitorDB+"/LastCp.png"); cv = new TCanvas(); cv->Draw(); hLastCpFr->Draw("hist"); MitRootStyle::OverlayFrame(); MitRootStyle::AddText(TString("Date: ") + dateTime); cv->SaveAs(monitorDB+"/LastCpFraction.png"); }