2 Origin: marian.ivanov@cern.ch
3 Make sys watch default plots (see $ALICE_ROOT/STEER/AliSysInfo.cxx):
4 Input - syswatch.log - text log file created by process to be monitored
5 Output - syswatch.root - root files with default histograms
6 Number of top violators - only top consumer displayed
10 TOP violateors - CPU and Virtual memory usage
11 Detector reports - CPU and Virtual memory usage per detector
19 gROOT->LoadMacro("$ALICE_ROOT/macros/PlotSys.C+");
20 MakePlots("syswatch.log","syswatch.root",10);
21 TFile f("syswatch.root");
32 #include "AliSysInfo.h"
37 TCut cutVM("cutVM","deltaVM>10");
38 TCut cutDT("cutDT","deltaT>2");
42 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order);
46 void TopCPUDetector();
48 void PInit(const char *log="syswatch.log", const char *out="syswatch.root"){
52 tree = AliSysInfo::MakeTree(log);
53 fout = new TFile(out,"recreate");
58 void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", Int_t top=10){
64 gStyle->SetOptStat(0);
71 // Reports per detector
73 fout->mkdir("cpuDetector");
74 fout->mkdir("VMDetector");
76 fout->cd("VMDetector");
80 fout->cd("cpuDetector");
91 // select top user of virtual Memory
92 // MakeReport - ASCII and histogram
96 Float_t thVM = TopUsage(tree,"deltaVM","",ctop);
97 cutVM = TCut("cutDT",Form("deltaVM>%f",thVM));
100 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
101 printf("TOP Virtual memory user\n");
102 tree->Scan("deltaVM:sname",cutVM,"colsize=20");
103 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n");
105 tree->Draw("deltaVM:sname>>hhh","1"+cutVM,"*");
106 his2 = (TH2F*)(tree->GetHistogram())->Clone("dvmsname");
107 delete tree->GetHistogram();
108 his2->SetYTitle("Delta Virtual Memory (MBy)");
109 his2->SetMarkerStyle(22);
110 his2->SetMarkerSize(1);
112 his2->Write("DVMvsName");
115 tree->Draw("VM:sname>>hhh","id2<3"+cutVM,"*");
116 his2 = (TH2F*)(tree->GetHistogram())->Clone("vmsname");
117 delete tree->GetHistogram();
118 his2->SetYTitle("Delta Virtual Memory (MBy)");
119 his2->SetMarkerStyle(22);
120 his2->SetMarkerSize(1);
122 his2->Write("VMvsName");
126 tree->Draw("VM:T>>hhh","deltaVM>1","line*");
127 his = (TH1*)tree->GetHistogram()->Clone("vmt");
128 delete tree->GetHistogram();
129 his->SetXTitle("Time (sec)");
130 his->SetYTitle("Virtual Memory (MBy)");
131 his->GetYaxis()->SetTitleOffset(1.2);
132 his->SetMarkerStyle(22);
133 his->SetMarkerSize(1);
135 his->Write("VMvsTime");
141 // select top user of CPU
142 // MakeReport - ASCII and histogram
145 Float_t thDT = TopUsage(tree,"deltaT","id2<3",ctop);
146 cutDT = TCut("cutDT",Form("deltaT>%f",thDT));
148 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
149 printf("/n/n/nTOP CPU user\n");
150 tree->Scan("deltaT:sname",cutDT,"colsize=20");
151 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
153 tree->Draw("deltaT:sname>>hhh","id2<3"+cutDT,"*");
154 his2 = (TH2F*)(tree->GetHistogram())->Clone("tsname");
155 delete tree->GetHistogram();
156 his2->SetName("VMsanme");
157 his2->SetYTitle("Delta CPU time(sec)");
158 his2->SetMarkerStyle(22);
159 his2->SetMarkerSize(1);
160 his2->GetXaxis()->SetLabelSize(0.03);
162 his2->Write("CPUvsName");
167 void TopVMDetector(){
176 for (Int_t idet=0; idet<12; idet++){
179 sprintf(cdet,"id0==%d",idet);
181 sprintf(expr,"deltaVM:sname>>hhh");
183 Float_t thDVM = TopUsage(tree,"deltaVM",cdet,ctop);
184 sprintf(cdvm,"%s&&deltaT>%f",cdet, thDVM);
188 tree->Draw(expr,cdvm,"*");
189 his2 = (TH2F*)(tree->GetHistogram())->Clone("xxx");
190 delete tree->GetHistogram();
191 his2->SetYTitle("Delta Virtual Memory (MBy)");
192 his2->SetMarkerStyle(22);
193 his2->SetMarkerSize(1);
195 his2->Write(Form("DVMvsName_%d",idet));
199 sprintf(expr,"VM:sname>>hhh");
200 tree->Draw(expr,cdvm,"*");
201 his2 = (TH2F*)(tree->GetHistogram())->Clone("yyy");
202 delete tree->GetHistogram();
203 his2->SetYTitle("Delta Virtual Memory (MBy)");
204 his2->SetMarkerStyle(22);
205 his2->SetMarkerSize(1);
207 his2->Write(Form("VMvsName_%d",idet));
214 void TopCPUDetector(){
223 for (Int_t idet=0; idet<12; idet++){
226 sprintf(cdet,"id0==%d",idet);
228 sprintf(expr,"deltaT:sname>>hhh");
230 Float_t thDT = TopUsage(tree,"deltaT",cdet,ctop);
231 sprintf(cdtime,"%s&&deltaT>%f",cdet, thDT);
233 tree->Draw(expr,cdtime,"*");
234 his2 = (TH2F*)(tree->GetHistogram())->Clone("dtsname");
235 delete tree->GetHistogram();
236 his2->SetYTitle("Delta CPU time(sec)");
237 his2->SetMarkerStyle(22);
238 his2->SetMarkerSize(1);
239 his2->GetXaxis()->SetLabelSize(0.03);
241 his2->Write(Form("CPUvsName_%d",idet));
251 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order){
254 // Find value for given order
255 // Used to select top violator
257 Int_t entries = tree->Draw(Form("%s>>hhh1",exp),cut,"goff");
259 if (tree->GetHistogram()) delete tree->GetHistogram();
260 printf("%s\t No entries\n",cut);
263 if (!tree->GetV1()) {
264 printf("%s\t No entries\n",cut);
267 Int_t *index = new Int_t[entries];
268 TMath::Sort(entries, tree->GetV1(), index);
269 Int_t oindex = TMath::Min(order, entries);
270 Float_t val = tree->GetV1()[index[oindex-1]];
271 if (tree->GetHistogram()) delete tree->GetHistogram();