2 /// \author marian.ivanov@cern.ch
3 /// \brief Make sys watch default plots
5 /// See `$ALICE_ROOT/STEER/AliSysInfo.cxx`.
6 /// Input - syswatch.log - text log file created by process to be monitored
7 /// Output - syswatch.root - root files with default histograms
8 /// Number of top violators - only top consumer displayed
10 /// Default histogram:
12 /// TOP violateors - CPU and Virtual memory usage
13 /// Detector reports - CPU and Virtual memory usage per detector
22 /// gROOT->LoadMacro("$ALICE_ROOT/macros/PlotSys.C+");
23 /// MakePlots("syswatch.log","syswatch.root",10);
24 /// TFile f("syswatch.root");
35 #include "AliSysInfo.h"
40 TCut cutVM("cutVM","deltaVM>10");
41 TCut cutDT("cutDT","deltaT>2");
45 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order);
49 void TopCPUDetector();
51 void PInit(const char *log="syswatch.log", const char *out="syswatch.root"){
54 tree = AliSysInfo::MakeTree(log);
55 fout = new TFile(out,"recreate");
60 void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", Int_t top=10){
65 gStyle->SetOptStat(0);
72 // Reports per detector
74 fout->mkdir("cpuDetector");
75 fout->mkdir("VMDetector");
77 fout->cd("VMDetector");
81 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");
140 /// select top user of CPU
141 /// MakeReport - ASCII and histogram
144 Float_t thDT = TopUsage(tree,"deltaT","id2<3",ctop);
145 cutDT = TCut("cutDT",Form("deltaT>%f",thDT));
147 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
148 printf("/n/n/nTOP CPU user\n");
149 tree->Scan("deltaT:sname",cutDT,"colsize=20");
150 printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
152 tree->Draw("deltaT:sname>>hhh","id2<3"+cutDT,"*");
153 his2 = (TH2F*)(tree->GetHistogram())->Clone("tsname");
154 delete tree->GetHistogram();
155 his2->SetName("VMsanme");
156 his2->SetYTitle("Delta CPU time(sec)");
157 his2->SetMarkerStyle(22);
158 his2->SetMarkerSize(1);
159 his2->GetXaxis()->SetLabelSize(0.03);
161 his2->Write("CPUvsName");
166 void TopVMDetector(){
174 for (Int_t idet=0; idet<12; idet++){
177 sprintf(cdet,"id0==%d",idet);
179 sprintf(expr,"deltaVM:sname>>hhh");
181 Float_t thDVM = TopUsage(tree,"deltaVM",cdet,ctop);
182 sprintf(cdvm,"%s&&deltaT>%f",cdet, thDVM);
186 tree->Draw(expr,cdvm,"*");
187 his2 = (TH2F*)(tree->GetHistogram())->Clone("xxx");
188 delete tree->GetHistogram();
189 his2->SetYTitle("Delta Virtual Memory (MBy)");
190 his2->SetMarkerStyle(22);
191 his2->SetMarkerSize(1);
193 his2->Write(Form("DVMvsName_%d",idet));
197 sprintf(expr,"VM:sname>>hhh");
198 tree->Draw(expr,cdvm,"*");
199 his2 = (TH2F*)(tree->GetHistogram())->Clone("yyy");
200 delete tree->GetHistogram();
201 his2->SetYTitle("Delta Virtual Memory (MBy)");
202 his2->SetMarkerStyle(22);
203 his2->SetMarkerSize(1);
205 his2->Write(Form("VMvsName_%d",idet));
212 void TopCPUDetector(){
213 /// Draw usage of CPU
220 for (Int_t idet=0; idet<12; idet++){
223 sprintf(cdet,"id0==%d",idet);
225 sprintf(expr,"deltaT:sname>>hhh");
227 Float_t thDT = TopUsage(tree,"deltaT",cdet,ctop);
228 sprintf(cdtime,"%s&&deltaT>%f",cdet, thDT);
230 tree->Draw(expr,cdtime,"*");
231 his2 = (TH2F*)(tree->GetHistogram())->Clone("dtsname");
232 delete tree->GetHistogram();
233 his2->SetYTitle("Delta CPU time(sec)");
234 his2->SetMarkerStyle(22);
235 his2->SetMarkerSize(1);
236 his2->GetXaxis()->SetLabelSize(0.03);
238 his2->Write(Form("CPUvsName_%d",idet));
248 Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order){
249 /// Find value for given order
250 /// Used to select top violator
252 Int_t entries = tree->Draw(Form("%s>>hhh1",exp),cut,"goff");
254 if (tree->GetHistogram()) delete tree->GetHistogram();
255 printf("%s\t No entries\n",cut);
258 if (!tree->GetV1()) {
259 printf("%s\t No entries\n",cut);
262 Int_t *index = new Int_t[entries];
263 TMath::Sort(entries, tree->GetV1(), index);
264 Int_t oindex = TMath::Min(order, entries);
265 Float_t val = tree->GetV1()[index[oindex-1]];
266 if (tree->GetHistogram()) delete tree->GetHistogram();