Input - syswatch.log - text log file created by process to be monitored
Output - syswatch.root - root files with default histograms
Number of top violators - only top consumer displayed
-
Default histogram:
-
- TOP violateors - CPU and Virtual memory usage
+ TOP violators - CPU and Virtual memory usage
Detector reports - CPU and Virtual memory usage per detector
-
-
-
-
-
- Usage example:
- .x ~/rootlogon.C
+ //
+
+ Example usage:
+ // 1. Initialize
gROOT->LoadMacro("$ALICE_ROOT/macros/PlotSys.C+");
- MakePlots("syswatch.log","syswatch.root",10);
+ PInit("syswatch.log","syswatch.root","syswatch.sum");
+ // 2. Make ascii report.
+ SumDetector()
+ // 3. Make histos of top violators
+ MakePlots(20);
+ // 4. Browse the results
TFile f("syswatch.root");
TBrowser b;
-*/
+ */
+#include <stdio.h>
+#include "AliReconstruction.h"
#include "TMath.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TStyle.h"
#include "AliSysInfo.h"
+const Int_t kNDetectors=AliReconstruction::kNDetectors;
+const char* fgkDetectorName[kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
+
+
+
TObject * htemp;
TTree *tree=0;
TFile *fout=0;
+TString sumFile;
TCut cutVM("cutVM","deltaVM>10");
TCut cutDT("cutDT","deltaT>2");
-Int_t ctop=10;
+Int_t ctop=20;
Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order);
+Double_t SumUsage(TTree* tree, const char *exp, const char*cut);
void TopVM();
void TopCPU();
void TopVMDetector();
void TopCPUDetector();
+void SumDetector();
-void PInit(const char *log="syswatch.log", const char *out="syswatch.root"){
+void PInit(const char *log="syswatch.log", const char *out="syswatch.root", const char * sumName="syswatch.sum"){
//
// Set Input output
//
tree = AliSysInfo::MakeTree(log);
fout = new TFile(out,"recreate");
+ sumFile=sumName;
}
-void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", Int_t top=10){
+void MakePlots(Int_t top=20){
//
//
//
ctop=top;
- PInit(log,out);
gStyle->SetOptStat(0);
//
// Top users
//
// Reports per detector
//
- fout->mkdir("cpuDetector");
- fout->mkdir("VMDetector");
- //
- fout->cd("VMDetector");
- TopVMDetector();
- //
fout->cd();
- fout->cd("cpuDetector");
+ for (Int_t idet=0; idet<kNDetectors;idet++){
+ fout->cd();
+ fout->mkdir(fgkDetectorName[idet]);
+ }
+ TopVMDetector();
TopCPUDetector();
-
//
fout->Close();
ctop=top;
//
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
printf("TOP Virtual memory user\n");
- tree->Scan("deltaVM:sname",cutVM,"colsize=20");
+ //tree->Scan("deltaVM:sname",cutVM,"colsize=20");
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
//
tree->Draw("deltaVM:sname>>hhh","1"+cutVM,"*");
//
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
printf("/n/n/nTOP CPU user\n");
- tree->Scan("deltaT:sname",cutDT,"colsize=20");
+ //tree->Scan("deltaT:sname",cutDT,"colsize=20");
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
//
tree->Draw("deltaT:sname>>hhh","id2<3"+cutDT,"*");
//
//detector part
//
- for (Int_t idet=0; idet<12; idet++){
+ for (Int_t idet=0; idet<kNDetectors; idet++){
+ fout->cd();
+ fout->cd(fgkDetectorName[idet]);
char cdet[100];
char cdvm[100];
sprintf(cdet,"id0==%d",idet);
sprintf(expr,"deltaVM:sname>>hhh");
//
Float_t thDVM = TopUsage(tree,"deltaVM",cdet,ctop);
- sprintf(cdvm,"%s&&deltaT>%f",cdet, thDVM);
-
-
+ sprintf(cdvm,"%s&&deltaVM>%f",cdet, thDVM);
//
- tree->Draw(expr,cdvm,"*");
+ tree->Draw(expr,cdvm,"GOFF");
his2 = (TH2F*)(tree->GetHistogram())->Clone("xxx");
delete tree->GetHistogram();
his2->SetYTitle("Delta Virtual Memory (MBy)");
his2->SetMarkerStyle(22);
his2->SetMarkerSize(1);
- his2->Draw("l*");
+ //his2->Draw("l*");
his2->Write(Form("DVMvsName_%d",idet));
delete his2;
//
//
sprintf(expr,"VM:sname>>hhh");
- tree->Draw(expr,cdvm,"*");
+ tree->Draw(expr,cdvm,"goff");
his2 = (TH2F*)(tree->GetHistogram())->Clone("yyy");
delete tree->GetHistogram();
his2->SetYTitle("Delta Virtual Memory (MBy)");
his2->SetMarkerStyle(22);
his2->SetMarkerSize(1);
- his2->Draw("l*");
+ //his2->Draw("l*");
his2->Write(Form("VMvsName_%d",idet));
delete his2;
}
+ fout->cd();
}
//
// CPU
//
- for (Int_t idet=0; idet<12; idet++){
+ for (Int_t idet=0; idet<kNDetectors; idet++){
+ fout->cd();
+ fout->cd(fgkDetectorName[idet]);
char cdet[100];
char cdtime[100];
sprintf(cdet,"id0==%d",idet);
Float_t thDT = TopUsage(tree,"deltaT",cdet,ctop);
sprintf(cdtime,"%s&&deltaT>%f",cdet, thDT);
//
- tree->Draw(expr,cdtime,"*");
+ tree->Draw(expr,cdtime,"goff");
his2 = (TH2F*)(tree->GetHistogram())->Clone("dtsname");
delete tree->GetHistogram();
his2->SetYTitle("Delta CPU time(sec)");
his2->SetMarkerStyle(22);
his2->SetMarkerSize(1);
his2->GetXaxis()->SetLabelSize(0.03);
- his2->Draw("l*");
+ //his2->Draw("l*");
his2->Write(Form("CPUvsName_%d",idet));
delete his2;
}
+ fout->cd();
+}
+
+void SumDetector(){
+ //
+ // Sum - detector information
+ //
+ FILE * pFile;
+ pFile = fopen (sumFile,"w");
+ char cdet[100];
+ char expr[100];
+ sprintf(cdet,"id0>=0&&id2>=0");
+ Double_t sumdTAll = SumUsage(tree,"deltaT",cdet);
+ Double_t sumdVMAll = SumUsage(tree,"deltaVM",cdet);
+ printf("%s%s%s%s%s\n","Det/C:","sumDt/F:","sumDvm/F:","fracDt/F:","fracDvm/F");
+ printf("%s\t%f\t%f\t%f\t%f\t\n","all", sumdTAll,sumdVMAll,100.,100.);
+ fprintf(pFile,"%s%s%s%s%s\n","Det/C:","sumDt/F:","sumDvm/F:","fracDt/F:","fracDvm/F");
+ fprintf(pFile,"%s\t%f\t%f\t%f\t%f\t\n","all", sumdTAll,sumdVMAll,100.,100.);
+ for (Int_t idet=0; idet<kNDetectors; idet++){
+ sprintf(cdet,"id0==%d&&id2>=0",idet);
+ sprintf(expr,"deltaT:sname>>hhh");
+ Double_t sumdT = SumUsage(tree,"deltaT",cdet);
+ Double_t sumdVM = SumUsage(tree,"deltaVM",cdet);
+ printf("%s\t%f\t%f\t%f\t%f\t\n",fgkDetectorName[idet], sumdT,sumdVM,100.*sumdT/sumdTAll, 100.*sumdVM/sumdVMAll);
+ fprintf(pFile,"%s\t%f\t%f\t%f\t%f\t\n",fgkDetectorName[idet], sumdT,sumdVM,100.*sumdT/sumdTAll, 100.*sumdVM/sumdVMAll);
+ }
+ fclose (pFile);
}
-
+
delete [] index;
return val;
}
+
+
+Double_t SumUsage(TTree* tree, const char *exp, const char*cut){
+ //
+ // return sum of usage
+ //
+ Int_t entries = tree->Draw(Form("%s",exp),cut,"goff");
+ if (entries==0) return 0;
+ Double_t mean = TMath::Mean(entries, tree->GetV1());
+ return entries*mean;
+}