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