]>
Commit | Line | Data |
---|---|---|
457c0713 | 1 | /// \file PlotSys.C |
2 | /// \author marian.ivanov@cern.ch | |
3 | /// \brief Make sys watch default plots | |
4 | /// | |
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 | |
9 | /// | |
10 | /// Default histogram: | |
11 | /// | |
12 | /// TOP violateors - CPU and Virtual memory usage | |
13 | /// Detector reports - CPU and Virtual memory usage per detector | |
14 | /// | |
15 | /// | |
16 | /// | |
17 | /// | |
18 | /// | |
19 | /// Usage example: | |
20 | /// ~~~{.cpp} | |
21 | /// .x ~/rootlogon.C | |
22 | /// gROOT->LoadMacro("$ALICE_ROOT/macros/PlotSys.C+"); | |
23 | /// MakePlots("syswatch.log","syswatch.root",10); | |
24 | /// TFile f("syswatch.root"); | |
25 | /// TBrowser b; | |
26 | /// ~~~ | |
551dd3d4 | 27 | |
28 | #include "TMath.h" | |
29 | #include "TH1F.h" | |
30 | #include "TH2F.h" | |
31 | #include "TTree.h" | |
32 | #include "TFile.h" | |
33 | #include "TCut.h" | |
34 | #include "TStyle.h" | |
35 | #include "AliSysInfo.h" | |
36 | ||
37 | TObject * htemp; | |
38 | TTree *tree=0; | |
39 | TFile *fout=0; | |
40 | TCut cutVM("cutVM","deltaVM>10"); | |
41 | TCut cutDT("cutDT","deltaT>2"); | |
42 | Int_t ctop=10; | |
43 | ||
44 | ||
45 | Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order); | |
46 | void TopVM(); | |
47 | void TopCPU(); | |
48 | void TopVMDetector(); | |
49 | void TopCPUDetector(); | |
50 | ||
51 | void PInit(const char *log="syswatch.log", const char *out="syswatch.root"){ | |
457c0713 | 52 | /// Set Input output |
53 | ||
551dd3d4 | 54 | tree = AliSysInfo::MakeTree(log); |
55 | fout = new TFile(out,"recreate"); | |
56 | } | |
57 | ||
58 | ||
59 | ||
60 | void MakePlots(const char *log="syswatch.log", const char *out="syswatch.root", Int_t top=10){ | |
457c0713 | 61 | /// |
62 | ||
551dd3d4 | 63 | ctop=top; |
64 | PInit(log,out); | |
65 | gStyle->SetOptStat(0); | |
66 | // | |
67 | // Top users | |
68 | // | |
69 | TopVM(); | |
70 | TopCPU(); | |
71 | // | |
72 | // Reports per detector | |
73 | // | |
74 | fout->mkdir("cpuDetector"); | |
75 | fout->mkdir("VMDetector"); | |
76 | // | |
77 | fout->cd("VMDetector"); | |
78 | TopVMDetector(); | |
79 | // | |
80 | fout->cd(); | |
81 | fout->cd("cpuDetector"); | |
82 | TopCPUDetector(); | |
83 | ||
84 | // | |
85 | fout->Close(); | |
86 | ctop=top; | |
87 | delete fout; | |
88 | } | |
89 | ||
90 | void TopVM(){ | |
457c0713 | 91 | /// select top user of virtual Memory |
92 | /// MakeReport - ASCII and histogram | |
93 | ||
551dd3d4 | 94 | TH1 * his=0; |
95 | TH2 * his2=0; | |
96 | Float_t thVM = TopUsage(tree,"deltaVM","",ctop); | |
97 | cutVM = TCut("cutDT",Form("deltaVM>%f",thVM)); | |
98 | // | |
99 | // | |
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"); | |
104 | // | |
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); | |
111 | his2->Draw("l*"); | |
112 | his2->Write("DVMvsName"); | |
113 | delete his2; | |
114 | // | |
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); | |
121 | his2->Draw("l*"); | |
122 | his2->Write("VMvsName"); | |
123 | delete his2; | |
124 | // | |
125 | // | |
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); | |
134 | his->Draw(); | |
135 | his->Write("VMvsTime"); | |
136 | delete his; | |
137 | } | |
138 | ||
139 | void TopCPU(){ | |
457c0713 | 140 | /// select top user of CPU |
141 | /// MakeReport - ASCII and histogram | |
142 | ||
551dd3d4 | 143 | TH2 * his2=0; |
144 | Float_t thDT = TopUsage(tree,"deltaT","id2<3",ctop); | |
145 | cutDT = TCut("cutDT",Form("deltaT>%f",thDT)); | |
146 | // | |
147 | printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); | |
148 | printf("/n/n/nTOP CPU user\n"); | |
149 | tree->Scan("deltaT:sname",cutDT,"colsize=20"); | |
150 | printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); | |
151 | // | |
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); | |
160 | his2->Draw("l*"); | |
161 | his2->Write("CPUvsName"); | |
162 | delete his2; | |
163 | } | |
164 | ||
165 | ||
166 | void TopVMDetector(){ | |
457c0713 | 167 | /// Draw usage of VM |
168 | ||
551dd3d4 | 169 | TH2 * his2=0; |
170 | // | |
171 | // | |
172 | //detector part | |
173 | // | |
174 | for (Int_t idet=0; idet<12; idet++){ | |
175 | char cdet[100]; | |
176 | char cdvm[100]; | |
177 | sprintf(cdet,"id0==%d",idet); | |
178 | char expr[100]; | |
179 | sprintf(expr,"deltaVM:sname>>hhh"); | |
180 | // | |
181 | Float_t thDVM = TopUsage(tree,"deltaVM",cdet,ctop); | |
182 | sprintf(cdvm,"%s&&deltaT>%f",cdet, thDVM); | |
183 | ||
184 | ||
185 | // | |
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); | |
192 | his2->Draw("l*"); | |
193 | his2->Write(Form("DVMvsName_%d",idet)); | |
194 | delete his2; | |
195 | // | |
196 | // | |
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); | |
204 | his2->Draw("l*"); | |
205 | his2->Write(Form("VMvsName_%d",idet)); | |
206 | delete his2; | |
207 | } | |
208 | } | |
209 | ||
210 | ||
211 | ||
212 | void TopCPUDetector(){ | |
457c0713 | 213 | /// Draw usage of CPU |
214 | ||
551dd3d4 | 215 | TH2 * his2=0; |
216 | // | |
217 | // | |
218 | // CPU | |
219 | // | |
220 | for (Int_t idet=0; idet<12; idet++){ | |
221 | char cdet[100]; | |
222 | char cdtime[100]; | |
223 | sprintf(cdet,"id0==%d",idet); | |
224 | char expr[100]; | |
225 | sprintf(expr,"deltaT:sname>>hhh"); | |
226 | // | |
227 | Float_t thDT = TopUsage(tree,"deltaT",cdet,ctop); | |
228 | sprintf(cdtime,"%s&&deltaT>%f",cdet, thDT); | |
229 | // | |
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); | |
237 | his2->Draw("l*"); | |
238 | his2->Write(Form("CPUvsName_%d",idet)); | |
239 | delete his2; | |
240 | } | |
241 | } | |
242 | ||
243 | ||
244 | ||
245 | ||
246 | ||
247 | ||
248 | Float_t TopUsage(TTree* tree, const char *exp, const char*cut, Int_t order){ | |
457c0713 | 249 | /// Find value for given order |
250 | /// Used to select top violator | |
251 | ||
551dd3d4 | 252 | Int_t entries = tree->Draw(Form("%s>>hhh1",exp),cut,"goff"); |
253 | if (entries<=1) { | |
254 | if (tree->GetHistogram()) delete tree->GetHistogram(); | |
255 | printf("%s\t No entries\n",cut); | |
256 | return -10000; | |
257 | } | |
258 | if (!tree->GetV1()) { | |
259 | printf("%s\t No entries\n",cut); | |
260 | return -10000; | |
261 | } | |
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(); | |
267 | delete [] index; | |
268 | return val; | |
269 | } |