1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 no warnings ('qw');
8 use CGI;
9 use RRDs;
10 use Fcntl (qw(:flock));
11 use Carp (qw(carp cluck confess croak));
13 our $Config = read_config ();
15 our $AbsDir;
16 our $RelDir;
17 our $Type;
18 our $Inst;
19 our $TimeSpan;
21 for (qw(Red Green Blue Yellow Cyan Magenta))
22 {
23 $Config->{'Colors'}{"Half$_"} = color_calculate_transparent ($Config->{'Colors'}{'Alpha'},
24 $Config->{'Colors'}{'Canvas'}, $Config->{'Colors'}{"Full$_"});
25 }
27 $Config->{'Colors'}{'HalfBlueGreen'} = color_calculate_transparent ($Config->{'Colors'}{'Alpha'},
28 $Config->{'Colors'}{'Canvas'}, $Config->{'Colors'}{'FullGreen'}, $Config->{'Colors'}{'FullBlue'});
29 $Config->{'Colors'}{'HalfRedBlue'} = color_calculate_transparent ($Config->{'Colors'}{'Alpha'},
30 $Config->{'Colors'}{'Canvas'}, $Config->{'Colors'}{'FullBlue'}, $Config->{'Colors'}{'FullRed'});
32 our $GraphDefs;
33 {
34 my $Alpha = $Config->{'Colors'}{'Alpha'};
35 my $Canvas = $Config->{'Colors'}{'Canvas'};
37 my $FullRed = $Config->{'Colors'}{'FullRed'};
38 my $FullGreen = $Config->{'Colors'}{'FullGreen'};
39 my $FullBlue = $Config->{'Colors'}{'FullBlue'};
40 my $FullYellow = $Config->{'Colors'}{'FullYellow'};
41 my $FullCyan = $Config->{'Colors'}{'FullCyan'};
42 my $FullMagenta= $Config->{'Colors'}{'FullMagenta'};
44 my $HalfRed = $Config->{'Colors'}{'HalfRed'};
45 my $HalfGreen = $Config->{'Colors'}{'HalfGreen'};
46 my $HalfBlue = $Config->{'Colors'}{'HalfBlue'};
47 my $HalfYellow = $Config->{'Colors'}{'HalfYellow'};
48 my $HalfCyan = $Config->{'Colors'}{'HalfCyan'};
49 my $HalfMagenta= $Config->{'Colors'}{'HalfMagenta'};
51 my $HalfBlueGreen = $Config->{'Colors'}{'HalfBlueGreen'};
52 my $HalfRedBlue = $Config->{'Colors'}{'HalfRedBlue'};
54 $GraphDefs =
55 {
56 apache_bytes => ['DEF:min_raw={file}:count:MIN',
57 'DEF:avg_raw={file}:count:AVERAGE',
58 'DEF:max_raw={file}:count:MAX',
59 'CDEF:min=min_raw,8,*',
60 'CDEF:avg=avg_raw,8,*',
61 'CDEF:max=max_raw,8,*',
62 'CDEF:mytime=avg_raw,TIME,TIME,IF',
63 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
64 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
65 'CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*',
66 'CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+',
67 "AREA:avg#$HalfBlue",
68 "LINE1:avg#$FullBlue:Bit/s",
69 'GPRINT:min:MIN:%5.1lf%s Min,',
70 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
71 'GPRINT:max:MAX:%5.1lf%s Max,',
72 'GPRINT:avg:LAST:%5.1lf%s Last',
73 'GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
74 ],
75 apache_requests => ['DEF:min={file}:count:MIN',
76 'DEF:avg={file}:count:AVERAGE',
77 'DEF:max={file}:count:MAX',
78 "AREA:max#$HalfBlue",
79 "AREA:min#$Canvas",
80 "LINE1:avg#$FullBlue:Requests/s",
81 'GPRINT:min:MIN:%6.2lf Min,',
82 'GPRINT:avg:AVERAGE:%6.2lf Avg,',
83 'GPRINT:max:MAX:%6.2lf Max,',
84 'GPRINT:avg:LAST:%6.2lf Last'
85 ],
86 apache_scoreboard => ['DEF:min={file}:count:MIN',
87 'DEF:avg={file}:count:AVERAGE',
88 'DEF:max={file}:count:MAX',
89 "AREA:max#$HalfBlue",
90 "AREA:min#$Canvas",
91 "LINE1:avg#$FullBlue:Processes",
92 'GPRINT:min:MIN:%6.2lf Min,',
93 'GPRINT:avg:AVERAGE:%6.2lf Avg,',
94 'GPRINT:max:MAX:%6.2lf Max,',
95 'GPRINT:avg:LAST:%6.2lf Last'
96 ],
97 charge => [
98 'DEF:avg={file}:charge:AVERAGE',
99 'DEF:min={file}:charge:MIN',
100 'DEF:max={file}:charge:MAX',
101 "AREA:max#$HalfBlue",
102 "AREA:min#$Canvas",
103 "LINE1:avg#$FullBlue:Charge",
104 'GPRINT:min:MIN:%5.1lf%sAh Min,',
105 'GPRINT:avg:AVERAGE:%5.1lf%sAh Avg,',
106 'GPRINT:max:MAX:%5.1lf%sAh Max,',
107 'GPRINT:avg:LAST:%5.1lf%sAh Last\l'
108 ],
109 charge_percent => [
110 'DEF:avg={file}:percent:AVERAGE',
111 'DEF:min={file}:percent:MIN',
112 'DEF:max={file}:percent:MAX',
113 "AREA:max#$HalfBlue",
114 "AREA:min#$Canvas",
115 "LINE1:avg#$FullBlue:Charge",
116 'GPRINT:min:MIN:%5.1lf%s%% Min,',
117 'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
118 'GPRINT:max:MAX:%5.1lf%s%% Max,',
119 'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
120 ],
121 cpu => ['DEF:user_avg={file}:user:AVERAGE',
122 'DEF:user_min={file}:user:MIN',
123 'DEF:user_max={file}:user:MAX',
124 'DEF:nice_avg={file}:nice:AVERAGE',
125 'DEF:nice_min={file}:nice:MIN',
126 'DEF:nice_max={file}:nice:MAX',
127 'DEF:syst_avg={file}:syst:AVERAGE',
128 'DEF:syst_min={file}:syst:MIN',
129 'DEF:syst_max={file}:syst:MAX',
130 'DEF:idle_avg={file}:idle:AVERAGE',
131 'DEF:idle_min={file}:idle:MIN',
132 'DEF:idle_max={file}:idle:MAX',
133 'DEF:wait_avg={file}:wait:AVERAGE',
134 'DEF:wait_min={file}:wait:MIN',
135 'DEF:wait_max={file}:wait:MAX',
136 'CDEF:user_avg_notnull=user_avg,UN,0,user_avg,IF',
137 'CDEF:nice_avg_notnull=nice_avg,UN,0,nice_avg,IF',
138 'CDEF:syst_avg_notnull=syst_avg,UN,0,syst_avg,IF',
139 'CDEF:idle_avg_notnull=idle_avg,UN,0,idle_avg,IF',
140 'CDEF:wait_avg_notnull=wait_avg,UN,0,wait_avg,IF',
141 'CDEF:totl_avg_notnull=user_avg_notnull,nice_avg_notnull,+,syst_avg_notnull,+,idle_avg_notnull,+,wait_avg_notnull,+',
142 'CDEF:user_avg_pct=user_avg_notnull,100,*,totl_avg_notnull,/',
143 'CDEF:nice_avg_pct=nice_avg_notnull,100,*,totl_avg_notnull,/',
144 'CDEF:syst_avg_pct=syst_avg_notnull,100,*,totl_avg_notnull,/',
145 'CDEF:wait_avg_pct=wait_avg_notnull,100,*,totl_avg_notnull,/',
146 'CDEF:nice_acc=syst_avg_pct,wait_avg_pct,user_avg_pct,nice_avg_pct,+,+,+',
147 'CDEF:user_acc=syst_avg_pct,wait_avg_pct,user_avg_pct,+,+',
148 'CDEF:wait_acc=syst_avg_pct,wait_avg_pct,+',
149 'CDEF:syst_acc=syst_avg_pct',
150 # 'CDEF:nice_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,nice_avg_notnull,+,+,+',
151 # 'CDEF:user_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,+,+',
152 # 'CDEF:wait_acc=syst_avg_notnull,wait_avg_notnull,+',
153 # 'CDEF:syst_acc=syst_avg_notnull',
154 "AREA:nice_acc#$HalfGreen",
155 "AREA:user_acc#$HalfBlue",
156 "AREA:wait_acc#$HalfYellow",
157 "AREA:syst_acc#$HalfRed",
158 "LINE1:nice_acc#$FullGreen:Nice ",
159 'GPRINT:nice_min:MIN:%5.1lf%% Min,',
160 'GPRINT:nice_avg:AVERAGE:%5.1lf%% Avg,',
161 'GPRINT:nice_max:MAX:%5.1lf%% Max,',
162 'GPRINT:nice_avg:LAST:%5.1lf%% Last\l',
163 "LINE1:user_acc#$FullBlue:User ",
164 'GPRINT:user_min:MIN:%5.1lf%% Min,',
165 'GPRINT:user_avg:AVERAGE:%5.1lf%% Avg,',
166 'GPRINT:user_max:MAX:%5.1lf%% Max,',
167 'GPRINT:user_avg:LAST:%5.1lf%% Last\l',
168 "LINE1:wait_acc#$FullYellow:Wait-IO",
169 'GPRINT:wait_min:MIN:%5.1lf%% Min,',
170 'GPRINT:wait_avg:AVERAGE:%5.1lf%% Avg,',
171 'GPRINT:wait_max:MAX:%5.1lf%% Max,',
172 'GPRINT:wait_avg:LAST:%5.1lf%% Last\l',
173 "LINE1:syst_acc#$FullRed:System ",
174 'GPRINT:syst_min:MIN:%5.1lf%% Min,',
175 'GPRINT:syst_avg:AVERAGE:%5.1lf%% Avg,',
176 'GPRINT:syst_max:MAX:%5.1lf%% Max,',
177 'GPRINT:syst_avg:LAST:%5.1lf%% Last\l'
178 ],
179 current => [
180 'DEF:avg={file}:current:AVERAGE',
181 'DEF:min={file}:current:MIN',
182 'DEF:max={file}:current:MAX',
183 "AREA:max#$HalfBlue",
184 "AREA:min#$Canvas",
185 "LINE1:avg#$FullBlue:Current",
186 'GPRINT:min:MIN:%5.1lf%sA Min,',
187 'GPRINT:avg:AVERAGE:%5.1lf%sA Avg,',
188 'GPRINT:max:MAX:%5.1lf%sA Max,',
189 'GPRINT:avg:LAST:%5.1lf%sA Last\l'
190 ],
191 df => [
192 'DEF:free_avg={file}:free:AVERAGE',
193 'DEF:free_min={file}:free:MIN',
194 'DEF:free_max={file}:free:MAX',
195 'DEF:used_avg={file}:used:AVERAGE',
196 'DEF:used_min={file}:used:MIN',
197 'DEF:used_max={file}:used:MAX',
198 'CDEF:total=free_avg,used_avg,+',
199 'CDEF:free_pct=100,free_avg,*,total,/',
200 'CDEF:used_pct=100,used_avg,*,total,/',
201 'CDEF:free_acc=free_pct,used_pct,+',
202 'CDEF:used_acc=used_pct',
203 "AREA:free_acc#$HalfGreen",
204 "AREA:used_acc#$HalfRed",
205 "LINE1:free_acc#$FullGreen:Free",
206 'GPRINT:free_min:MIN:%5.1lf%sB Min,',
207 'GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,',
208 'GPRINT:free_max:MAX:%5.1lf%sB Max,',
209 'GPRINT:free_avg:LAST:%5.1lf%sB Last\l',
210 "LINE1:used_acc#$FullRed:Used",
211 'GPRINT:used_min:MIN:%5.1lf%sB Min,',
212 'GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,',
213 'GPRINT:used_max:MAX:%5.1lf%sB Max,',
214 'GPRINT:used_avg:LAST:%5.1lf%sB Last\l'
215 ],
216 disk => [
217 'DEF:rtime_avg={file}:rtime:AVERAGE',
218 'DEF:rtime_min={file}:rtime:MIN',
219 'DEF:rtime_max={file}:rtime:MAX',
220 'DEF:wtime_avg={file}:wtime:AVERAGE',
221 'DEF:wtime_min={file}:wtime:MIN',
222 'DEF:wtime_max={file}:wtime:MAX',
223 'CDEF:rtime_avg_ms=rtime_avg,1000,/',
224 'CDEF:rtime_min_ms=rtime_min,1000,/',
225 'CDEF:rtime_max_ms=rtime_max,1000,/',
226 'CDEF:wtime_avg_ms=wtime_avg,1000,/',
227 'CDEF:wtime_min_ms=wtime_min,1000,/',
228 'CDEF:wtime_max_ms=wtime_max,1000,/',
229 'CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+',
230 'CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+',
231 'CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+',
232 "AREA:total_max_ms#$HalfRed",
233 "AREA:total_min_ms#$Canvas",
234 "LINE1:wtime_avg_ms#$FullGreen:Write",
235 'GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,',
236 'GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
237 'GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,',
238 'GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n',
239 "LINE1:rtime_avg_ms#$FullBlue:Read ",
240 'GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,',
241 'GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
242 'GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,',
243 'GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n',
244 "LINE1:total_avg_ms#$FullRed:Total",
245 'GPRINT:total_min_ms:MIN:%5.1lf%s Min,',
246 'GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,',
247 'GPRINT:total_max_ms:MAX:%5.1lf%s Max,',
248 'GPRINT:total_avg_ms:LAST:%5.1lf%s Last'
249 ],
250 dns_traffic => ['DEF:rsp_min_raw={file}:responses:MIN',
251 'DEF:rsp_avg_raw={file}:responses:AVERAGE',
252 'DEF:rsp_max_raw={file}:responses:MAX',
253 'DEF:qry_min_raw={file}:queries:MIN',
254 'DEF:qry_avg_raw={file}:queries:AVERAGE',
255 'DEF:qry_max_raw={file}:queries:MAX',
256 'CDEF:rsp_min=rsp_min_raw,8,*',
257 'CDEF:rsp_avg=rsp_avg_raw,8,*',
258 'CDEF:rsp_max=rsp_max_raw,8,*',
259 'CDEF:qry_min=qry_min_raw,8,*',
260 'CDEF:qry_avg=qry_avg_raw,8,*',
261 'CDEF:qry_max=qry_max_raw,8,*',
262 'CDEF:overlap=rsp_avg,qry_avg,GT,qry_avg,rsp_avg,IF',
263 'CDEF:mytime=rsp_avg_raw,TIME,TIME,IF',
264 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
265 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
266 'CDEF:rsp_avg_sample=rsp_avg_raw,UN,0,rsp_avg_raw,IF,sample_len,*',
267 'CDEF:rsp_avg_sum=PREV,UN,0,PREV,IF,rsp_avg_sample,+',
268 'CDEF:qry_avg_sample=qry_avg_raw,UN,0,qry_avg_raw,IF,sample_len,*',
269 'CDEF:qry_avg_sum=PREV,UN,0,PREV,IF,qry_avg_sample,+',
270 "AREA:rsp_avg#$HalfGreen",
271 "AREA:qry_avg#$HalfBlue",
272 "AREA:overlap#$HalfBlueGreen",
273 "LINE1:rsp_avg#$FullGreen:Responses",
274 'GPRINT:rsp_avg:AVERAGE:%5.1lf%s Avg,',
275 'GPRINT:rsp_max:MAX:%5.1lf%s Max,',
276 'GPRINT:rsp_avg:LAST:%5.1lf%s Last',
277 'GPRINT:rsp_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
278 "LINE1:qry_avg#$FullBlue:Queries ",
279 #'GPRINT:qry_min:MIN:%5.1lf %s Min,',
280 'GPRINT:qry_avg:AVERAGE:%5.1lf%s Avg,',
281 'GPRINT:qry_max:MAX:%5.1lf%s Max,',
282 'GPRINT:qry_avg:LAST:%5.1lf%s Last',
283 'GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
284 ],
285 email => [
286 'DEF:avg={file}:count:AVERAGE',
287 'DEF:min={file}:count:MIN',
288 'DEF:max={file}:count:MAX',
289 "AREA:max#$HalfMagenta",
290 "AREA:min#$Canvas",
291 "LINE1:avg#$FullMagenta:Count ",
292 'GPRINT:min:MIN:%4.1lf Min,',
293 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
294 'GPRINT:max:MAX:%4.1lf Max,',
295 'GPRINT:avg:LAST:%4.1lf Last\l'
296 ],
297 email_size => [
298 'DEF:avg={file}:size:AVERAGE',
299 'DEF:min={file}:size:MIN',
300 'DEF:max={file}:size:MAX',
301 "AREA:max#$HalfMagenta",
302 "AREA:min#$Canvas",
303 "LINE1:avg#$FullMagenta:Count ",
304 'GPRINT:min:MIN:%4.1lf Min,',
305 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
306 'GPRINT:max:MAX:%4.1lf Max,',
307 'GPRINT:avg:LAST:%4.1lf Last\l'
308 ],
309 spam_score => [
310 'DEF:avg={file}:score:AVERAGE',
311 'DEF:min={file}:score:MIN',
312 'DEF:max={file}:score:MAX',
313 "AREA:max#$HalfMagenta",
314 "AREA:min#$Canvas",
315 "LINE1:avg#$FullMagenta:Count ",
316 'GPRINT:min:MIN:%4.1lf Min,',
317 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
318 'GPRINT:max:MAX:%4.1lf Max,',
319 'GPRINT:avg:LAST:%4.1lf Last\l'
320 ],
321 spam_check => [
322 'DEF:avg={file}:hits:AVERAGE',
323 'DEF:min={file}:hits:MIN',
324 'DEF:max={file}:hits:MAX',
325 "AREA:max#$HalfMagenta",
326 "AREA:min#$Canvas",
327 "LINE1:avg#$FullMagenta:Count ",
328 'GPRINT:min:MIN:%4.1lf Min,',
329 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
330 'GPRINT:max:MAX:%4.1lf Max,',
331 'GPRINT:avg:LAST:%4.1lf Last\l'
332 ],
333 fanspeed => [
334 'DEF:temp_avg={file}:value:AVERAGE',
335 'DEF:temp_min={file}:value:MIN',
336 'DEF:temp_max={file}:value:MAX',
337 "AREA:temp_max#$HalfMagenta",
338 "AREA:temp_min#$Canvas",
339 "LINE1:temp_avg#$FullMagenta:RPM",
340 'GPRINT:temp_min:MIN:%4.1lf Min,',
341 'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
342 'GPRINT:temp_max:MAX:%4.1lf Max,',
343 'GPRINT:temp_avg:LAST:%4.1lf Last\l'
344 ],
345 frequency_offset => [ # NTPd
346 'DEF:ppm_avg={file}:ppm:AVERAGE',
347 'DEF:ppm_min={file}:ppm:MIN',
348 'DEF:ppm_max={file}:ppm:MAX',
349 "AREA:ppm_max#$HalfBlue",
350 "AREA:ppm_min#$Canvas",
351 "LINE1:ppm_avg#$FullBlue:{inst}",
352 'GPRINT:ppm_min:MIN:%5.2lf Min,',
353 'GPRINT:ppm_avg:AVERAGE:%5.2lf Avg,',
354 'GPRINT:ppm_max:MAX:%5.2lf Max,',
355 'GPRINT:ppm_avg:LAST:%5.2lf Last'
356 ],
357 hddtemp => [
358 'DEF:temp_avg={file}:value:AVERAGE',
359 'DEF:temp_min={file}:value:MIN',
360 'DEF:temp_max={file}:value:MAX',
361 "AREA:temp_max#$HalfRed",
362 "AREA:temp_min#$Canvas",
363 "LINE1:temp_avg#$FullRed:Temperature",
364 'GPRINT:temp_min:MIN:%4.1lf Min,',
365 'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
366 'GPRINT:temp_max:MAX:%4.1lf Max,',
367 'GPRINT:temp_avg:LAST:%4.1lf Last\l'
368 ],
369 if_packets => ['DEF:tx_min={file}:tx:MIN',
370 'DEF:tx_avg={file}:tx:AVERAGE',
371 'DEF:tx_max={file}:tx:MAX',
372 'DEF:rx_min={file}:rx:MIN',
373 'DEF:rx_avg={file}:rx:AVERAGE',
374 'DEF:rx_max={file}:rx:MAX',
375 'CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF',
376 'CDEF:mytime=tx_avg,TIME,TIME,IF',
377 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
378 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
379 'CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*',
380 'CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+',
381 'CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*',
382 'CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+',
383 "AREA:tx_avg#$HalfGreen",
384 "AREA:rx_avg#$HalfBlue",
385 "AREA:overlap#$HalfBlueGreen",
386 "LINE1:tx_avg#$FullGreen:TX",
387 'GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,',
388 'GPRINT:tx_max:MAX:%5.1lf%s Max,',
389 'GPRINT:tx_avg:LAST:%5.1lf%s Last',
390 'GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)\l',
391 "LINE1:rx_avg#$FullBlue:RX",
392 #'GPRINT:rx_min:MIN:%5.1lf %s Min,',
393 'GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,',
394 'GPRINT:rx_max:MAX:%5.1lf%s Max,',
395 'GPRINT:rx_avg:LAST:%5.1lf%s Last',
396 'GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)\l'
397 ],
398 load => ['DEF:s_avg={file}:shortterm:AVERAGE',
399 'DEF:s_min={file}:shortterm:MIN',
400 'DEF:s_max={file}:shortterm:MAX',
401 'DEF:m_avg={file}:midterm:AVERAGE',
402 'DEF:m_min={file}:midterm:MIN',
403 'DEF:m_max={file}:midterm:MAX',
404 'DEF:l_avg={file}:longterm:AVERAGE',
405 'DEF:l_min={file}:longterm:MIN',
406 'DEF:l_max={file}:longterm:MAX',
407 "AREA:s_max#$HalfGreen",
408 "AREA:s_min#$Canvas",
409 "LINE1:s_avg#$FullGreen: 1m average",
410 'GPRINT:s_min:MIN:%4.2lf Min,',
411 'GPRINT:s_avg:AVERAGE:%4.2lf Avg,',
412 'GPRINT:s_max:MAX:%4.2lf Max,',
413 'GPRINT:s_avg:LAST:%4.2lf Last\n',
414 "LINE1:m_avg#$FullBlue: 5m average",
415 'GPRINT:m_min:MIN:%4.2lf Min,',
416 'GPRINT:m_avg:AVERAGE:%4.2lf Avg,',
417 'GPRINT:m_max:MAX:%4.2lf Max,',
418 'GPRINT:m_avg:LAST:%4.2lf Last\n',
419 "LINE1:l_avg#$FullRed:15m average",
420 'GPRINT:l_min:MIN:%4.2lf Min,',
421 'GPRINT:l_avg:AVERAGE:%4.2lf Avg,',
422 'GPRINT:l_max:MAX:%4.2lf Max,',
423 'GPRINT:l_avg:LAST:%4.2lf Last'
424 ],
425 load_percent => [
426 'DEF:avg={file}:percent:AVERAGE',
427 'DEF:min={file}:percent:MIN',
428 'DEF:max={file}:percent:MAX',
429 "AREA:max#$HalfBlue",
430 "AREA:min#$Canvas",
431 "LINE1:avg#$FullBlue:Load",
432 'GPRINT:min:MIN:%5.1lf%s%% Min,',
433 'GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,',
434 'GPRINT:max:MAX:%5.1lf%s%% Max,',
435 'GPRINT:avg:LAST:%5.1lf%s%% Last\l'
436 ],
437 mails => ['DEF:rawgood={file}:good:AVERAGE',
438 'DEF:rawspam={file}:spam:AVERAGE',
439 'CDEF:good=rawgood,UN,0,rawgood,IF',
440 'CDEF:spam=rawspam,UN,0,rawspam,IF',
441 'CDEF:negspam=spam,-1,*',
442 "AREA:good#$HalfGreen",
443 "LINE1:good#$FullGreen:Good mails",
444 'GPRINT:good:AVERAGE:%4.1lf Avg,',
445 'GPRINT:good:MAX:%4.1lf Max,',
446 'GPRINT:good:LAST:%4.1lf Last\n',
447 "AREA:negspam#$HalfRed",
448 "LINE1:negspam#$FullRed:Spam mails",
449 'GPRINT:spam:AVERAGE:%4.1lf Avg,',
450 'GPRINT:spam:MAX:%4.1lf Max,',
451 'GPRINT:spam:LAST:%4.1lf Last',
452 'HRULE:0#000000'],
453 memory => [
454 'DEF:used_avg={file}:used:AVERAGE',
455 'DEF:free_avg={file}:free:AVERAGE',
456 'DEF:buffers_avg={file}:buffers:AVERAGE',
457 'DEF:cached_avg={file}:cached:AVERAGE',
458 'DEF:used_min={file}:used:MIN',
459 'DEF:free_min={file}:free:MIN',
460 'DEF:buffers_min={file}:buffers:MIN',
461 'DEF:cached_min={file}:cached:MIN',
462 'DEF:used_max={file}:used:MAX',
463 'DEF:free_max={file}:free:MAX',
464 'DEF:buffers_max={file}:buffers:MAX',
465 'DEF:cached_max={file}:cached:MAX',
466 'CDEF:cached_avg_nn=cached_avg,UN,0,cached_avg,IF',
467 'CDEF:buffers_avg_nn=buffers_avg,UN,0,buffers_avg,IF',
468 'CDEF:free_cached_buffers_used=free_avg,cached_avg_nn,+,buffers_avg_nn,+,used_avg,+',
469 'CDEF:cached_buffers_used=cached_avg,buffers_avg_nn,+,used_avg,+',
470 'CDEF:buffers_used=buffers_avg,used_avg,+',
471 "AREA:free_cached_buffers_used#$HalfGreen",
472 "AREA:cached_buffers_used#$HalfBlue",
473 "AREA:buffers_used#$HalfYellow",
474 "AREA:used_avg#$HalfRed",
475 "LINE1:free_cached_buffers_used#$FullGreen:Free ",
476 'GPRINT:free_min:MIN:%5.1lf%s Min,',
477 'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
478 'GPRINT:free_max:MAX:%5.1lf%s Max,',
479 'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
480 "LINE1:cached_buffers_used#$FullBlue:Page cache ",
481 'GPRINT:cached_min:MIN:%5.1lf%s Min,',
482 'GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,',
483 'GPRINT:cached_max:MAX:%5.1lf%s Max,',
484 'GPRINT:cached_avg:LAST:%5.1lf%s Last\n',
485 "LINE1:buffers_used#$FullYellow:Buffer cache",
486 'GPRINT:buffers_min:MIN:%5.1lf%s Min,',
487 'GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,',
488 'GPRINT:buffers_max:MAX:%5.1lf%s Max,',
489 'GPRINT:buffers_avg:LAST:%5.1lf%s Last\n',
490 "LINE1:used_avg#$FullRed:Used ",
491 'GPRINT:used_min:MIN:%5.1lf%s Min,',
492 'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
493 'GPRINT:used_max:MAX:%5.1lf%s Max,',
494 'GPRINT:used_avg:LAST:%5.1lf%s Last'
495 ],
496 mysql_commands => [
497 "DEF:val_avg={file}:value:AVERAGE",
498 "DEF:val_min={file}:value:MIN",
499 "DEF:val_max={file}:value:MAX",
500 "AREA:val_max#$HalfBlue",
501 "AREA:val_min#$Canvas",
502 "LINE1:val_avg#$FullBlue:{inst}",
503 'GPRINT:val_min:MIN:%5.2lf Min,',
504 'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
505 'GPRINT:val_max:MAX:%5.2lf Max,',
506 'GPRINT:val_avg:LAST:%5.2lf Last'
507 ],
508 mysql_handler => [
509 "DEF:val_avg={file}:value:AVERAGE",
510 "DEF:val_min={file}:value:MIN",
511 "DEF:val_max={file}:value:MAX",
512 "AREA:val_max#$HalfBlue",
513 "AREA:val_min#$Canvas",
514 "LINE1:val_avg#$FullBlue:{inst}",
515 'GPRINT:val_min:MIN:%5.2lf Min,',
516 'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
517 'GPRINT:val_max:MAX:%5.2lf Max,',
518 'GPRINT:val_avg:LAST:%5.2lf Last'
519 ],
520 mysql_qcache => [
521 "DEF:hits_min={file}:hits:MIN",
522 "DEF:hits_avg={file}:hits:AVERAGE",
523 "DEF:hits_max={file}:hits:MAX",
524 "DEF:inserts_min={file}:inserts:MIN",
525 "DEF:inserts_avg={file}:inserts:AVERAGE",
526 "DEF:inserts_max={file}:inserts:MAX",
527 "DEF:not_cached_min={file}:not_cached:MIN",
528 "DEF:not_cached_avg={file}:not_cached:AVERAGE",
529 "DEF:not_cached_max={file}:not_cached:MAX",
530 "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN",
531 "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE",
532 "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX",
533 "DEF:queries_min={file}:queries_in_cache:MIN",
534 "DEF:queries_avg={file}:queries_in_cache:AVERAGE",
535 "DEF:queries_max={file}:queries_in_cache:MAX",
536 "CDEF:unknown=queries_avg,UNKN,+",
537 "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+",
538 "CDEF:inserts_agg=hits_avg,inserts_avg,+",
539 "CDEF:hits_agg=hits_avg",
540 "AREA:not_cached_agg#$HalfYellow",
541 "AREA:inserts_agg#$HalfBlue",
542 "AREA:hits_agg#$HalfGreen",
543 "LINE1:not_cached_agg#$FullYellow:Not Cached ",
544 'GPRINT:not_cached_min:MIN:%5.2lf Min,',
545 'GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,',
546 'GPRINT:not_cached_max:MAX:%5.2lf Max,',
547 'GPRINT:not_cached_avg:LAST:%5.2lf Last\l',
548 "LINE1:inserts_agg#$FullBlue:Inserts ",
549 'GPRINT:inserts_min:MIN:%5.2lf Min,',
550 'GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,',
551 'GPRINT:inserts_max:MAX:%5.2lf Max,',
552 'GPRINT:inserts_avg:LAST:%5.2lf Last\l',
553 "LINE1:hits_agg#$FullGreen:Hits ",
554 'GPRINT:hits_min:MIN:%5.2lf Min,',
555 'GPRINT:hits_avg:AVERAGE:%5.2lf Avg,',
556 'GPRINT:hits_max:MAX:%5.2lf Max,',
557 'GPRINT:hits_avg:LAST:%5.2lf Last\l',
558 "LINE1:lowmem_prunes_avg#$FullRed:Lowmem Prunes ",
559 'GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,',
560 'GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,',
561 'GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,',
562 'GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\l',
563 "LINE1:unknown#$Canvas:Queries in cache",
564 'GPRINT:queries_min:MIN:%5.0lf Min,',
565 'GPRINT:queries_avg:AVERAGE:%5.0lf Avg,',
566 'GPRINT:queries_max:MAX:%5.0lf Max,',
567 'GPRINT:queries_avg:LAST:%5.0lf Last\l'
568 ],
569 mysql_threads => [
570 "DEF:running_min={file}:running:MIN",
571 "DEF:running_avg={file}:running:AVERAGE",
572 "DEF:running_max={file}:running:MAX",
573 "DEF:connected_min={file}:connected:MIN",
574 "DEF:connected_avg={file}:connected:AVERAGE",
575 "DEF:connected_max={file}:connected:MAX",
576 "DEF:cached_min={file}:cached:MIN",
577 "DEF:cached_avg={file}:cached:AVERAGE",
578 "DEF:cached_max={file}:cached:MAX",
579 "DEF:created_min={file}:created:MIN",
580 "DEF:created_avg={file}:created:AVERAGE",
581 "DEF:created_max={file}:created:MAX",
582 "CDEF:unknown=created_avg,UNKN,+",
583 "CDEF:cached_agg=connected_avg,cached_avg,+",
584 "AREA:cached_agg#$HalfGreen",
585 "AREA:connected_avg#$HalfBlue",
586 "AREA:running_avg#$HalfRed",
587 "LINE1:cached_agg#$FullGreen:Cached ",
588 'GPRINT:cached_min:MIN:%5.1lf Min,',
589 'GPRINT:cached_avg:AVERAGE:%5.1lf Avg,',
590 'GPRINT:cached_max:MAX:%5.1lf Max,',
591 'GPRINT:cached_avg:LAST:%5.1lf Last\l',
592 "LINE1:connected_avg#$FullBlue:Connected",
593 'GPRINT:connected_min:MIN:%5.1lf Min,',
594 'GPRINT:connected_avg:AVERAGE:%5.1lf Avg,',
595 'GPRINT:connected_max:MAX:%5.1lf Max,',
596 'GPRINT:connected_avg:LAST:%5.1lf Last\l',
597 "LINE1:running_avg#$FullRed:Running ",
598 'GPRINT:running_min:MIN:%5.1lf Min,',
599 'GPRINT:running_avg:AVERAGE:%5.1lf Avg,',
600 'GPRINT:running_max:MAX:%5.1lf Max,',
601 'GPRINT:running_avg:LAST:%5.1lf Last\l',
602 "LINE1:unknown#$Canvas:Created ",
603 'GPRINT:created_min:MIN:%5.0lf Min,',
604 'GPRINT:created_avg:AVERAGE:%5.0lf Avg,',
605 'GPRINT:created_max:MAX:%5.0lf Max,',
606 'GPRINT:created_avg:LAST:%5.0lf Last\l'
607 ],
608 nfs3_procedures => [
609 "DEF:null_avg={file}:null:AVERAGE",
610 "DEF:getattr_avg={file}:getattr:AVERAGE",
611 "DEF:setattr_avg={file}:setattr:AVERAGE",
612 "DEF:lookup_avg={file}:lookup:AVERAGE",
613 "DEF:access_avg={file}:access:AVERAGE",
614 "DEF:readlink_avg={file}:readlink:AVERAGE",
615 "DEF:read_avg={file}:read:AVERAGE",
616 "DEF:write_avg={file}:write:AVERAGE",
617 "DEF:create_avg={file}:create:AVERAGE",
618 "DEF:mkdir_avg={file}:mkdir:AVERAGE",
619 "DEF:symlink_avg={file}:symlink:AVERAGE",
620 "DEF:mknod_avg={file}:mknod:AVERAGE",
621 "DEF:remove_avg={file}:remove:AVERAGE",
622 "DEF:rmdir_avg={file}:rmdir:AVERAGE",
623 "DEF:rename_avg={file}:rename:AVERAGE",
624 "DEF:link_avg={file}:link:AVERAGE",
625 "DEF:readdir_avg={file}:readdir:AVERAGE",
626 "DEF:readdirplus_avg={file}:readdirplus:AVERAGE",
627 "DEF:fsstat_avg={file}:fsstat:AVERAGE",
628 "DEF:fsinfo_avg={file}:fsinfo:AVERAGE",
629 "DEF:pathconf_avg={file}:pathconf:AVERAGE",
630 "DEF:commit_avg={file}:commit:AVERAGE",
631 "DEF:null_max={file}:null:MAX",
632 "DEF:getattr_max={file}:getattr:MAX",
633 "DEF:setattr_max={file}:setattr:MAX",
634 "DEF:lookup_max={file}:lookup:MAX",
635 "DEF:access_max={file}:access:MAX",
636 "DEF:readlink_max={file}:readlink:MAX",
637 "DEF:read_max={file}:read:MAX",
638 "DEF:write_max={file}:write:MAX",
639 "DEF:create_max={file}:create:MAX",
640 "DEF:mkdir_max={file}:mkdir:MAX",
641 "DEF:symlink_max={file}:symlink:MAX",
642 "DEF:mknod_max={file}:mknod:MAX",
643 "DEF:remove_max={file}:remove:MAX",
644 "DEF:rmdir_max={file}:rmdir:MAX",
645 "DEF:rename_max={file}:rename:MAX",
646 "DEF:link_max={file}:link:MAX",
647 "DEF:readdir_max={file}:readdir:MAX",
648 "DEF:readdirplus_max={file}:readdirplus:MAX",
649 "DEF:fsstat_max={file}:fsstat:MAX",
650 "DEF:fsinfo_max={file}:fsinfo:MAX",
651 "DEF:pathconf_max={file}:pathconf:MAX",
652 "DEF:commit_max={file}:commit:MAX",
653 "CDEF:other_avg=null_avg,readlink_avg,create_avg,mkdir_avg,symlink_avg,mknod_avg,remove_avg,rmdir_avg,rename_avg,link_avg,readdir_avg,readdirplus_avg,fsstat_avg,fsinfo_avg,pathconf_avg,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
654 "CDEF:other_max=null_max,readlink_max,create_max,mkdir_max,symlink_max,mknod_max,remove_max,rmdir_max,rename_max,link_max,readdir_max,readdirplus_max,fsstat_max,fsinfo_max,pathconf_max,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
655 "CDEF:stack_read=read_avg",
656 "CDEF:stack_getattr=stack_read,getattr_avg,+",
657 "CDEF:stack_access=stack_getattr,access_avg,+",
658 "CDEF:stack_lookup=stack_access,lookup_avg,+",
659 "CDEF:stack_write=stack_lookup,write_avg,+",
660 "CDEF:stack_commit=stack_write,commit_avg,+",
661 "CDEF:stack_setattr=stack_commit,setattr_avg,+",
662 "CDEF:stack_other=stack_setattr,other_avg,+",
663 "AREA:stack_other#$HalfRed",
664 "AREA:stack_setattr#$HalfGreen",
665 "AREA:stack_commit#$HalfYellow",
666 "AREA:stack_write#$HalfGreen",
667 "AREA:stack_lookup#$HalfBlue",
668 "AREA:stack_access#$HalfMagenta",
669 "AREA:stack_getattr#$HalfCyan",
670 "AREA:stack_read#$HalfBlue",
671 "LINE1:stack_other#$FullRed:Other ",
672 'GPRINT:other_max:MAX:%5.1lf Max,',
673 'GPRINT:other_avg:AVERAGE:%5.1lf Avg,',
674 'GPRINT:other_avg:LAST:%5.1lf Last\l',
675 "LINE1:stack_setattr#$FullGreen:setattr",
676 'GPRINT:setattr_max:MAX:%5.1lf Max,',
677 'GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,',
678 'GPRINT:setattr_avg:LAST:%5.1lf Last\l',
679 "LINE1:stack_commit#$FullYellow:commit ",
680 'GPRINT:commit_max:MAX:%5.1lf Max,',
681 'GPRINT:commit_avg:AVERAGE:%5.1lf Avg,',
682 'GPRINT:commit_avg:LAST:%5.1lf Last\l',
683 "LINE1:stack_write#$FullGreen:write ",
684 'GPRINT:write_max:MAX:%5.1lf Max,',
685 'GPRINT:write_avg:AVERAGE:%5.1lf Avg,',
686 'GPRINT:write_avg:LAST:%5.1lf Last\l',
687 "LINE1:stack_lookup#$FullBlue:lookup ",
688 'GPRINT:lookup_max:MAX:%5.1lf Max,',
689 'GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,',
690 'GPRINT:lookup_avg:LAST:%5.1lf Last\l',
691 "LINE1:stack_access#$FullMagenta:access ",
692 'GPRINT:access_max:MAX:%5.1lf Max,',
693 'GPRINT:access_avg:AVERAGE:%5.1lf Avg,',
694 'GPRINT:access_avg:LAST:%5.1lf Last\l',
695 "LINE1:stack_getattr#$FullCyan:getattr",
696 'GPRINT:getattr_max:MAX:%5.1lf Max,',
697 'GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,',
698 'GPRINT:getattr_avg:LAST:%5.1lf Last\l',
699 "LINE1:stack_read#$FullBlue:read ",
700 'GPRINT:read_max:MAX:%5.1lf Max,',
701 'GPRINT:read_avg:AVERAGE:%5.1lf Avg,',
702 'GPRINT:read_avg:LAST:%5.1lf Last\l'
703 ],
704 opcode => [
705 'DEF:avg={file}:value:AVERAGE',
706 'DEF:min={file}:value:MIN',
707 'DEF:max={file}:value:MAX',
708 "AREA:max#$HalfBlue",
709 "AREA:min#$Canvas",
710 "LINE1:avg#$FullBlue:Queries/s",
711 'GPRINT:min:MIN:%9.3lf Min,',
712 'GPRINT:avg:AVERAGE:%9.3lf Average,',
713 'GPRINT:max:MAX:%9.3lf Max,',
714 'GPRINT:avg:LAST:%9.3lf Last\l'
715 ],
716 partition => [
717 "DEF:rbyte_avg={file}:rbytes:AVERAGE",
718 "DEF:rbyte_min={file}:rbytes:MIN",
719 "DEF:rbyte_max={file}:rbytes:MAX",
720 "DEF:wbyte_avg={file}:wbytes:AVERAGE",
721 "DEF:wbyte_min={file}:wbytes:MIN",
722 "DEF:wbyte_max={file}:wbytes:MAX",
723 'CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF',
724 "AREA:wbyte_avg#$HalfGreen",
725 "AREA:rbyte_avg#$HalfBlue",
726 "AREA:overlap#$HalfBlueGreen",
727 "LINE1:wbyte_avg#$FullGreen:Write",
728 'GPRINT:wbyte_min:MIN:%5.1lf%s Min,',
729 'GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,',
730 'GPRINT:wbyte_max:MAX:%5.1lf%s Max,',
731 'GPRINT:wbyte_avg:LAST:%5.1lf%s Last\l',
732 "LINE1:rbyte_avg#$FullBlue:Read ",
733 'GPRINT:rbyte_min:MIN:%5.1lf%s Min,',
734 'GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,',
735 'GPRINT:rbyte_max:MAX:%5.1lf%s Max,',
736 'GPRINT:rbyte_avg:LAST:%5.1lf%s Last\l'
737 ],
738 ping => ['DEF:ping_avg={file}:ping:AVERAGE',
739 'DEF:ping_min={file}:ping:MIN',
740 'DEF:ping_max={file}:ping:MAX',
741 "AREA:ping_max#$HalfBlue",
742 "AREA:ping_min#$Canvas",
743 "LINE1:ping_avg#$FullBlue:Ping",
744 'GPRINT:ping_min:MIN:%4.1lf ms Min,',
745 'GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,',
746 'GPRINT:ping_max:MAX:%4.1lf ms Max,',
747 'GPRINT:ping_avg:LAST:%4.1lf ms Last'],
748 processes => [
749 "DEF:running_avg={file}:running:AVERAGE",
750 "DEF:running_min={file}:running:MIN",
751 "DEF:running_max={file}:running:MAX",
752 "DEF:sleeping_avg={file}:sleeping:AVERAGE",
753 "DEF:sleeping_min={file}:sleeping:MIN",
754 "DEF:sleeping_max={file}:sleeping:MAX",
755 "DEF:zombies_avg={file}:zombies:AVERAGE",
756 "DEF:zombies_min={file}:zombies:MIN",
757 "DEF:zombies_max={file}:zombies:MAX",
758 "DEF:stopped_avg={file}:stopped:AVERAGE",
759 "DEF:stopped_min={file}:stopped:MIN",
760 "DEF:stopped_max={file}:stopped:MAX",
761 "DEF:paging_avg={file}:paging:AVERAGE",
762 "DEF:paging_min={file}:paging:MIN",
763 "DEF:paging_max={file}:paging:MAX",
764 "DEF:blocked_avg={file}:blocked:AVERAGE",
765 "DEF:blocked_min={file}:blocked:MIN",
766 "DEF:blocked_max={file}:blocked:MAX",
767 'CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+',
768 'CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+',
769 'CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+',
770 'CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+',
771 'CDEF:running_acc=sleeping_avg,running_avg,+',
772 'CDEF:sleeping_acc=sleeping_avg',
773 "AREA:paging_acc#$HalfYellow",
774 "AREA:blocked_acc#$HalfCyan",
775 "AREA:zombies_acc#$HalfRed",
776 "AREA:stopped_acc#$HalfMagenta",
777 "AREA:running_acc#$HalfGreen",
778 "AREA:sleeping_acc#$HalfBlue",
779 "LINE1:paging_acc#$FullYellow:Paging ",
780 'GPRINT:paging_min:MIN:%5.1lf Min,',
781 'GPRINT:paging_avg:AVERAGE:%5.1lf Average,',
782 'GPRINT:paging_max:MAX:%5.1lf Max,',
783 'GPRINT:paging_avg:LAST:%5.1lf Last\l',
784 "LINE1:blocked_acc#$FullCyan:Blocked ",
785 'GPRINT:blocked_min:MIN:%5.1lf Min,',
786 'GPRINT:blocked_avg:AVERAGE:%5.1lf Average,',
787 'GPRINT:blocked_max:MAX:%5.1lf Max,',
788 'GPRINT:blocked_avg:LAST:%5.1lf Last\l',
789 "LINE1:zombies_acc#$FullRed:Zombies ",
790 'GPRINT:zombies_min:MIN:%5.1lf Min,',
791 'GPRINT:zombies_avg:AVERAGE:%5.1lf Average,',
792 'GPRINT:zombies_max:MAX:%5.1lf Max,',
793 'GPRINT:zombies_avg:LAST:%5.1lf Last\l',
794 "LINE1:stopped_acc#$FullMagenta:Stopped ",
795 'GPRINT:stopped_min:MIN:%5.1lf Min,',
796 'GPRINT:stopped_avg:AVERAGE:%5.1lf Average,',
797 'GPRINT:stopped_max:MAX:%5.1lf Max,',
798 'GPRINT:stopped_avg:LAST:%5.1lf Last\l',
799 "LINE1:running_acc#$FullGreen:Running ",
800 'GPRINT:running_min:MIN:%5.1lf Min,',
801 'GPRINT:running_avg:AVERAGE:%5.1lf Average,',
802 'GPRINT:running_max:MAX:%5.1lf Max,',
803 'GPRINT:running_avg:LAST:%5.1lf Last\l',
804 "LINE1:sleeping_acc#$FullBlue:Sleeping",
805 'GPRINT:sleeping_min:MIN:%5.1lf Min,',
806 'GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,',
807 'GPRINT:sleeping_max:MAX:%5.1lf Max,',
808 'GPRINT:sleeping_avg:LAST:%5.1lf Last\l'
809 ],
810 ps_rss => [
811 'DEF:avg={file}:byte:AVERAGE',
812 'DEF:min={file}:byte:MIN',
813 'DEF:max={file}:byte:MAX',
814 "AREA:avg#$HalfBlue",
815 "LINE1:avg#$FullBlue:RSS",
816 'GPRINT:min:MIN:%5.1lf%s Min,',
817 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
818 'GPRINT:max:MAX:%5.1lf%s Max,',
819 'GPRINT:avg:LAST:%5.1lf%s Last\l'
820 ],
821 ps_cputime => [
822 'DEF:user_avg_raw={file}:user:AVERAGE',
823 'DEF:user_min_raw={file}:user:MIN',
824 'DEF:user_max_raw={file}:user:MAX',
825 'DEF:syst_avg_raw={file}:syst:AVERAGE',
826 'DEF:syst_min_raw={file}:syst:MIN',
827 'DEF:syst_max_raw={file}:syst:MAX',
828 'CDEF:user_avg=user_avg_raw,1000000,/',
829 'CDEF:user_min=user_min_raw,1000000,/',
830 'CDEF:user_max=user_max_raw,1000000,/',
831 'CDEF:syst_avg=syst_avg_raw,1000000,/',
832 'CDEF:syst_min=syst_min_raw,1000000,/',
833 'CDEF:syst_max=syst_max_raw,1000000,/',
834 'CDEF:user_syst=syst_avg,UN,0,syst_avg,IF,user_avg,+',
835 "AREA:user_syst#$HalfBlue",
836 "AREA:syst_avg#$HalfRed",
837 "LINE1:user_syst#$FullBlue:User ",
838 'GPRINT:user_min:MIN:%5.1lf%s Min,',
839 'GPRINT:user_avg:AVERAGE:%5.1lf%s Avg,',
840 'GPRINT:user_max:MAX:%5.1lf%s Max,',
841 'GPRINT:user_avg:LAST:%5.1lf%s Last\l',
842 "LINE1:syst_avg#$FullRed:System",
843 'GPRINT:syst_min:MIN:%5.1lf%s Min,',
844 'GPRINT:syst_avg:AVERAGE:%5.1lf%s Avg,',
845 'GPRINT:syst_max:MAX:%5.1lf%s Max,',
846 'GPRINT:syst_avg:LAST:%5.1lf%s Last\l'
847 ],
848 ps_count => [
849 'DEF:procs_avg={file}:processes:AVERAGE',
850 'DEF:procs_min={file}:processes:MIN',
851 'DEF:procs_max={file}:processes:MAX',
852 'DEF:thrds_avg={file}:threads:AVERAGE',
853 'DEF:thrds_min={file}:threads:MIN',
854 'DEF:thrds_max={file}:threads:MAX',
855 "AREA:thrds_avg#$HalfBlue",
856 "AREA:procs_avg#$HalfRed",
857 "LINE1:thrds_avg#$FullBlue:Threads ",
858 'GPRINT:thrds_min:MIN:%5.1lf Min,',
859 'GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,',
860 'GPRINT:thrds_max:MAX:%5.1lf Max,',
861 'GPRINT:thrds_avg:LAST:%5.1lf Last\l',
862 "LINE1:procs_avg#$FullRed:Processes",
863 'GPRINT:procs_min:MIN:%5.1lf Min,',
864 'GPRINT:procs_avg:AVERAGE:%5.1lf Avg,',
865 'GPRINT:procs_max:MAX:%5.1lf Max,',
866 'GPRINT:procs_avg:LAST:%5.1lf Last\l'
867 ],
868 ps_pagefaults => [
869 'DEF:minor_avg={file}:minflt:AVERAGE',
870 'DEF:minor_min={file}:minflt:MIN',
871 'DEF:minor_max={file}:minflt:MAX',
872 'DEF:major_avg={file}:majflt:AVERAGE',
873 'DEF:major_min={file}:majflt:MIN',
874 'DEF:major_max={file}:majflt:MAX',
875 'CDEF:minor_major=major_avg,UN,0,major_avg,IF,minor_avg,+',
876 "AREA:minor_major#$HalfBlue",
877 "AREA:major_avg#$HalfRed",
878 "LINE1:minor_major#$FullBlue:Minor",
879 'GPRINT:minor_min:MIN:%5.1lf%s Min,',
880 'GPRINT:minor_avg:AVERAGE:%5.1lf%s Avg,',
881 'GPRINT:minor_max:MAX:%5.1lf%s Max,',
882 'GPRINT:minor_avg:LAST:%5.1lf%s Last\l',
883 "LINE1:major_avg#$FullRed:Major",
884 'GPRINT:major_min:MIN:%5.1lf%s Min,',
885 'GPRINT:major_avg:AVERAGE:%5.1lf%s Avg,',
886 'GPRINT:major_max:MAX:%5.1lf%s Max,',
887 'GPRINT:major_avg:LAST:%5.1lf%s Last\l'
888 ],
889 qtype => [
890 'DEF:avg={file}:value:AVERAGE',
891 'DEF:min={file}:value:MIN',
892 'DEF:max={file}:value:MAX',
893 "AREA:max#$HalfBlue",
894 "AREA:min#$Canvas",
895 "LINE1:avg#$FullBlue:Queries/s",
896 'GPRINT:min:MIN:%9.3lf Min,',
897 'GPRINT:avg:AVERAGE:%9.3lf Average,',
898 'GPRINT:max:MAX:%9.3lf Max,',
899 'GPRINT:avg:LAST:%9.3lf Last\l'
900 ],
901 rcode => [
902 'DEF:avg={file}:value:AVERAGE',
903 'DEF:min={file}:value:MIN',
904 'DEF:max={file}:value:MAX',
905 "AREA:max#$HalfBlue",
906 "AREA:min#$Canvas",
907 "LINE1:avg#$FullBlue:Queries/s",
908 'GPRINT:min:MIN:%9.3lf Min,',
909 'GPRINT:avg:AVERAGE:%9.3lf Average,',
910 'GPRINT:max:MAX:%9.3lf Max,',
911 'GPRINT:avg:LAST:%9.3lf Last\l'
912 ],
913 swap => [
914 'DEF:used_avg={file}:used:AVERAGE',
915 'DEF:used_min={file}:used:MIN',
916 'DEF:used_max={file}:used:MAX',
917 'DEF:free_avg={file}:free:AVERAGE',
918 'DEF:free_min={file}:free:MIN',
919 'DEF:free_max={file}:free:MAX',
920 'DEF:cach_avg={file}:cached:AVERAGE',
921 'DEF:cach_min={file}:cached:MIN',
922 'DEF:cach_max={file}:cached:MAX',
923 'DEF:resv_avg={file}:resv:AVERAGE',
924 'DEF:resv_min={file}:resv:MIN',
925 'DEF:resv_max={file}:resv:MAX',
926 'CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF',
927 'CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF',
928 'CDEF:used_acc=used_avg',
929 'CDEF:resv_acc=used_acc,resv_avg_notnull,+',
930 'CDEF:cach_acc=resv_acc,cach_avg_notnull,+',
931 'CDEF:free_acc=cach_acc,free_avg,+',
932 "AREA:free_acc#$HalfGreen",
933 "AREA:cach_acc#$HalfBlue",
934 "AREA:resv_acc#$HalfYellow",
935 "AREA:used_acc#$HalfRed",
936 "LINE1:free_acc#$FullGreen:Free ",
937 'GPRINT:free_min:MIN:%5.1lf%s Min,',
938 'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
939 'GPRINT:free_max:MAX:%5.1lf%s Max,',
940 'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
941 "LINE1:cach_acc#$FullBlue:Cached ",
942 'GPRINT:cach_min:MIN:%5.1lf%s Min,',
943 'GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,',
944 'GPRINT:cach_max:MAX:%5.1lf%s Max,',
945 'GPRINT:cach_avg:LAST:%5.1lf%s Last\l',
946 "LINE1:resv_acc#$FullYellow:Reserved",
947 'GPRINT:resv_min:MIN:%5.1lf%s Min,',
948 'GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,',
949 'GPRINT:resv_max:MAX:%5.1lf%s Max,',
950 'GPRINT:resv_avg:LAST:%5.1lf%s Last\n',
951 "LINE1:used_acc#$FullRed:Used ",
952 'GPRINT:used_min:MIN:%5.1lf%s Min,',
953 'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
954 'GPRINT:used_max:MAX:%5.1lf%s Max,',
955 'GPRINT:used_avg:LAST:%5.1lf%s Last\l'
956 ],
957 temperature => [
958 'DEF:temp_avg={file}:value:AVERAGE',
959 'DEF:temp_min={file}:value:MIN',
960 'DEF:temp_max={file}:value:MAX',
961 "AREA:temp_max#$HalfRed",
962 "AREA:temp_min#$Canvas",
963 "LINE1:temp_avg#$FullRed:Temperature",
964 'GPRINT:temp_min:MIN:%4.1lf Min,',
965 'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
966 'GPRINT:temp_max:MAX:%4.1lf Max,',
967 'GPRINT:temp_avg:LAST:%4.1lf Last\l'
968 ],
969 timeleft => [
970 'DEF:avg={file}:timeleft:AVERAGE',
971 'DEF:min={file}:timeleft:MIN',
972 'DEF:max={file}:timeleft:MAX',
973 "AREA:max#$HalfBlue",
974 "AREA:min#$Canvas",
975 "LINE1:avg#$FullBlue:Time left [min]",
976 'GPRINT:min:MIN:%5.1lf%s Min,',
977 'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
978 'GPRINT:max:MAX:%5.1lf%s Max,',
979 'GPRINT:avg:LAST:%5.1lf%s Last\l'
980 ],
981 time_offset => [ # NTPd
982 'DEF:s_avg={file}:seconds:AVERAGE',
983 'DEF:s_min={file}:seconds:MIN',
984 'DEF:s_max={file}:seconds:MAX',
985 "AREA:s_max#$HalfBlue",
986 "AREA:s_min#$Canvas",
987 "LINE1:s_avg#$FullBlue:{inst}",
988 'GPRINT:s_min:MIN:%7.3lf%s Min,',
989 'GPRINT:s_avg:AVERAGE:%7.3lf%s Avg,',
990 'GPRINT:s_max:MAX:%7.3lf%s Max,',
991 'GPRINT:s_avg:LAST:%7.3lf%s Last'
992 ],
993 traffic => ['DEF:out_min_raw={file}:outgoing:MIN',
994 'DEF:out_avg_raw={file}:outgoing:AVERAGE',
995 'DEF:out_max_raw={file}:outgoing:MAX',
996 'DEF:inc_min_raw={file}:incoming:MIN',
997 'DEF:inc_avg_raw={file}:incoming:AVERAGE',
998 'DEF:inc_max_raw={file}:incoming:MAX',
999 'CDEF:out_min=out_min_raw,8,*',
1000 'CDEF:out_avg=out_avg_raw,8,*',
1001 'CDEF:out_max=out_max_raw,8,*',
1002 'CDEF:inc_min=inc_min_raw,8,*',
1003 'CDEF:inc_avg=inc_avg_raw,8,*',
1004 'CDEF:inc_max=inc_max_raw,8,*',
1005 'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
1006 'CDEF:mytime=out_avg_raw,TIME,TIME,IF',
1007 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
1008 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
1009 'CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*',
1010 'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
1011 'CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*',
1012 'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
1013 "AREA:out_avg#$HalfGreen",
1014 "AREA:inc_avg#$HalfBlue",
1015 "AREA:overlap#$HalfBlueGreen",
1016 "LINE1:out_avg#$FullGreen:Outgoing",
1017 'GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,',
1018 'GPRINT:out_max:MAX:%5.1lf%s Max,',
1019 'GPRINT:out_avg:LAST:%5.1lf%s Last',
1020 'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
1021 "LINE1:inc_avg#$FullBlue:Incoming",
1022 #'GPRINT:inc_min:MIN:%5.1lf %s Min,',
1023 'GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,',
1024 'GPRINT:inc_max:MAX:%5.1lf%s Max,',
1025 'GPRINT:inc_avg:LAST:%5.1lf%s Last',
1026 'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
1027 ],
1028 cpufreq => [
1029 'DEF:cpufreq_avg={file}:value:AVERAGE',
1030 'DEF:cpufreq_min={file}:value:MIN',
1031 'DEF:cpufreq_max={file}:value:MAX',
1032 "AREA:cpufreq_max#$HalfBlue",
1033 "AREA:cpufreq_min#$Canvas",
1034 "LINE1:cpufreq_avg#$FullBlue:Frequency",
1035 'GPRINT:cpufreq_min:MIN:%5.1lf%s Min,',
1036 'GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,',
1037 'GPRINT:cpufreq_max:MAX:%5.1lf%s Max,',
1038 'GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\l'
1039 ],
1040 multimeter => [
1041 'DEF:multimeter_avg={file}:value:AVERAGE',
1042 'DEF:multimeter_min={file}:value:MIN',
1043 'DEF:multimeter_max={file}:value:MAX',
1044 "AREA:multimeter_max#$HalfBlue",
1045 "AREA:multimeter_min#$Canvas",
1046 "LINE1:multimeter_avg#$FullBlue:Multimeter",
1047 'GPRINT:multimeter_min:MIN:%4.1lf Min,',
1048 'GPRINT:multimeter_avg:AVERAGE:%4.1lf Average,',
1049 'GPRINT:multimeter_max:MAX:%4.1lf Max,',
1050 'GPRINT:multimeter_avg:LAST:%4.1lf Last\l'
1051 ],
1052 users => [
1053 'DEF:users_avg={file}:users:AVERAGE',
1054 'DEF:users_min={file}:users:MIN',
1055 'DEF:users_max={file}:users:MAX',
1056 "AREA:users_max#$HalfBlue",
1057 "AREA:users_min#$Canvas",
1058 "LINE1:users_avg#$FullBlue:Users",
1059 'GPRINT:users_min:MIN:%4.1lf Min,',
1060 'GPRINT:users_avg:AVERAGE:%4.1lf Average,',
1061 'GPRINT:users_max:MAX:%4.1lf Max,',
1062 'GPRINT:users_avg:LAST:%4.1lf Last\l'
1063 ],
1064 voltage => [
1065 'DEF:avg={file}:voltage:AVERAGE',
1066 'DEF:min={file}:voltage:MIN',
1067 'DEF:max={file}:voltage:MAX',
1068 "AREA:max#$HalfBlue",
1069 "AREA:min#$Canvas",
1070 "LINE1:avg#$FullBlue:Voltage",
1071 'GPRINT:min:MIN:%5.1lf%sV Min,',
1072 'GPRINT:avg:AVERAGE:%5.1lf%sV Avg,',
1073 'GPRINT:max:MAX:%5.1lf%sV Max,',
1074 'GPRINT:avg:LAST:%5.1lf%sV Last\l'
1075 ],
1076 vs_threads => [
1077 "DEF:total_avg={file}:total:AVERAGE",
1078 "DEF:total_min={file}:total:MIN",
1079 "DEF:total_max={file}:total:MAX",
1080 "DEF:running_avg={file}:running:AVERAGE",
1081 "DEF:running_min={file}:running:MIN",
1082 "DEF:running_max={file}:running:MAX",
1083 "DEF:uninterruptible_avg={file}:uninterruptible:AVERAGE",
1084 "DEF:uninterruptible_min={file}:uninterruptible:MIN",
1085 "DEF:uninterruptible_max={file}:uninterruptible:MAX",
1086 "DEF:onhold_avg={file}:onhold:AVERAGE",
1087 "DEF:onhold_min={file}:onhold:MIN",
1088 "DEF:onhold_max={file}:onhold:MAX",
1089 "LINE1:total_avg#$FullYellow:Total ",
1090 'GPRINT:total_min:MIN:%5.1lf Min,',
1091 'GPRINT:total_avg:AVERAGE:%5.1lf Avg.,',
1092 'GPRINT:total_max:MAX:%5.1lf Max,',
1093 'GPRINT:total_avg:LAST:%5.1lf Last\l',
1094 "LINE1:running_avg#$FullRed:Running ",
1095 'GPRINT:running_min:MIN:%5.1lf Min,',
1096 'GPRINT:running_avg:AVERAGE:%5.1lf Avg.,',
1097 'GPRINT:running_max:MAX:%5.1lf Max,',
1098 'GPRINT:running_avg:LAST:%5.1lf Last\l',
1099 "LINE1:uninterruptible_avg#$FullGreen:Unintr ",
1100 'GPRINT:uninterruptible_min:MIN:%5.1lf Min,',
1101 'GPRINT:uninterruptible_avg:AVERAGE:%5.1lf Avg.,',
1102 'GPRINT:uninterruptible_max:MAX:%5.1lf Max,',
1103 'GPRINT:uninterruptible_avg:LAST:%5.1lf Last\l',
1104 "LINE1:onhold_avg#$FullBlue:Onhold ",
1105 'GPRINT:onhold_min:MIN:%5.1lf Min,',
1106 'GPRINT:onhold_avg:AVERAGE:%5.1lf Avg.,',
1107 'GPRINT:onhold_max:MAX:%5.1lf Max,',
1108 'GPRINT:onhold_avg:LAST:%5.1lf Last\l'
1109 ],
1110 vs_memory => [
1111 'DEF:vm_avg={file}:vm:AVERAGE',
1112 'DEF:vm_min={file}:vm:MIN',
1113 'DEF:vm_max={file}:vm:MAX',
1114 'DEF:vml_avg={file}:vml:AVERAGE',
1115 'DEF:vml_min={file}:vml:MIN',
1116 'DEF:vml_max={file}:vml:MAX',
1117 'DEF:rss_avg={file}:rss:AVERAGE',
1118 'DEF:rss_min={file}:rss:MIN',
1119 'DEF:rss_max={file}:rss:MAX',
1120 'DEF:anon_avg={file}:anon:AVERAGE',
1121 'DEF:anon_min={file}:anon:MIN',
1122 'DEF:anon_max={file}:anon:MAX',
1123 "LINE1:vm_avg#$FullYellow:VM ",
1124 'GPRINT:vm_min:MIN:%5.1lf%s Min,',
1125 'GPRINT:vm_avg:AVERAGE:%5.1lf%s Avg.,',
1126 'GPRINT:vm_max:MAX:%5.1lf%s Avg.,',
1127 'GPRINT:vm_avg:LAST:%5.1lf%s Last\l',
1128 "LINE1:vml_avg#$FullRed:Locked ",
1129 'GPRINT:vml_min:MIN:%5.1lf%s Min,',
1130 'GPRINT:vml_avg:AVERAGE:%5.1lf%s Avg.,',
1131 'GPRINT:vml_max:MAX:%5.1lf%s Avg.,',
1132 'GPRINT:vml_avg:LAST:%5.1lf%s Last\l',
1133 "LINE1:rss_avg#$FullGreen:RSS ",
1134 'GPRINT:rss_min:MIN:%5.1lf%s Min,',
1135 'GPRINT:rss_avg:AVERAGE:%5.1lf%s Avg.,',
1136 'GPRINT:rss_max:MAX:%5.1lf%s Avg.,',
1137 'GPRINT:rss_avg:LAST:%5.1lf%s Last\l',
1138 "LINE1:anon_avg#$FullBlue:Anon. ",
1139 'GPRINT:anon_min:MIN:%5.1lf%s Min,',
1140 'GPRINT:anon_avg:AVERAGE:%5.1lf%s Avg.,',
1141 'GPRINT:anon_max:MAX:%5.1lf%s Avg.,',
1142 'GPRINT:anon_avg:LAST:%5.1lf%s Last\l',
1143 ],
1144 vs_processes => [
1145 'DEF:proc_avg={file}:total:AVERAGE',
1146 'DEF:proc_min={file}:total:MIN',
1147 'DEF:proc_max={file}:total:MAX',
1148 "AREA:proc_max#$HalfBlue",
1149 "AREA:proc_min#$Canvas",
1150 "LINE1:proc_avg#$FullBlue:Processes",
1151 'GPRINT:proc_min:MIN:%4.1lf Min,',
1152 'GPRINT:proc_avg:AVERAGE:%4.1lf Avg.,',
1153 'GPRINT:proc_max:MAX:%4.1lf Max,',
1154 'GPRINT:proc_avg:LAST:%4.1lf Last\l'
1155 ],
1156 };
1157 $GraphDefs->{'disk'} = $GraphDefs->{'partition'};
1158 $GraphDefs->{'if_errors'} = $GraphDefs->{'if_packets'};
1159 $GraphDefs->{'meminfo'} = $GraphDefs->{'memory'};
1160 $GraphDefs->{'sensors'} = $GraphDefs->{'temperature'};
1162 $GraphDefs->{'delay'} = $GraphDefs->{'time_offset'};
1163 $GraphDefs->{'time_dispersion'} = $GraphDefs->{'time_offset'};
1164 }
1166 our $GraphArgs =
1167 {
1168 apache_bytes => ['-t', 'apache traffic', '-v', 'Bit/s'],
1169 apache_requests => ['-t', 'apache requests', '-v', 'Requests/s'],
1170 apache_scoreboard => ['-t', 'apache scoreboard {inst}', '-v', 'Processes'],
1171 charge => ['-t', '{host} charge', '-v', 'Ampere hours'],
1172 charge_percent => ['-t', '{host} charge', '-v', 'Percent'],
1173 cpu => ['-t', '{host} cpu{inst} usage', '-v', 'Percent', '-l', '0'],
1174 cpufreq => ['-t', '{host} cpu{inst} usage', '-v', 'Mhz'],
1175 current => ['-t', '{host} current', '-v', 'Ampere'],
1176 #disk => ['-t', '{host} disk {inst} IO wait', '-v', 'Seconds'],
1177 delay => ['-t', 'NTPd peer delay ({inst})', '-v', 'Seconds'],
1178 df => ['-t', '{host}:{inst} usage', '-v', 'Percent', '-l', '0'],
1179 disk => ['-t', '{host} disk {inst} usage', '-v', 'Byte/s'],
1180 dns_traffic => ['-t', '{host} DNS traffic', '-v', 'Bit/s'],
1181 email => ['-t', '{host} E-Mail {inst} count', '-v', 'E-Mails'],
1182 email_size => ['-t', '{host} E-Mail {inst} size', '-v', 'Bytes'],
1183 spam_score => ['-t', '{host} spam score', '-v', 'score'],
1184 spam_check => ['-t', '{host} spam checks {inst}', '-v', 'hits'],
1185 fanspeed => ['-t', '{host} fanspeed {inst}', '-v', 'RPM'],
1186 frequency_offset => ['-t', 'NTPd frequency offset ({inst})', '-v', 'Parts per million'],
1187 hddtemp => ['-t', '{host} hdd temperature {inst}', '-v', '°Celsius'],
1188 if_errors => ['-t', '{host} {inst} errors', '-v', 'Errors/s'],
1189 if_packets => ['-t', '{host} {inst} packets', '-v', 'Packets/s'],
1190 load => ['-t', '{host} load average', '-v', 'System load', '-X', '0'],
1191 load_percent => ['-t', '{host} load', '-v', 'Percent'],
1192 mails => ['-t', '{host} mail count', '-v', 'Amount', '-X', '0'],
1193 memory => ['-t', '{host} memory usage', '-v', 'Bytes', '-b', '1024', '-l', '0'],
1194 mysql_commands => ['-t', 'mysql command {inst}', '-v', 'Issues/s' ],
1195 mysql_handler => ['-t', 'mysql handler {inst}', '-v', 'Issues/s' ],
1196 mysql_qcache => ['-t', 'mysql query cache', '-v', 'Queries/s' ],
1197 mysql_threads => ['-t', 'mysql threads', '-v', 'Threads' ],
1198 nfs3_procedures => ['-t', '{host} NFSv3 {inst} procedures', '-v', 'Procedures/s' ],
1199 opcode => ['-t', 'OpCode {inst}', '-v', 'Queries/s'],
1200 partition => ['-t', '{host} partition {inst} usage', '-v', 'Byte/s'],
1201 ping => ['-t', '{host} ping to {inst}', '-v', 'ms'],
1202 processes => ['-t', '{host} processes', '-v', 'Processes'],
1203 ps_rss => ['-t', '{host} process {inst} RSS', '-v', 'Bytes', '-b', '1024'],
1204 ps_cputime => ['-t', '{host} process {inst} CPU usage', '-v', 'Seconds'],
1205 ps_count => ['-t', '{host} process {inst} count', '-v', 'Threads/Processes'],
1206 ps_pagefaults => ['-t', '{host} process {inst} pagefaults', '-v', 'Pagefaults/s'],
1207 qtype => ['-t', 'QType {inst}', '-v', 'Queries/s'],
1208 rcode => ['-t', 'RCode {inst}', '-v', 'Queries/s'],
1209 sensors => ['-t', '{host} sensor {inst}', '-v', '°Celsius'],
1210 swap => ['-t', '{host} swap usage', '-v', 'Bytes', '-b', '1024', '-l', '0'],
1211 temperature => ['-t', '{host} temperature {inst}', '-v', '°Celsius'],
1212 timeleft => ['-t', '{host} UPS time left', '-v', 'Time [min]'],
1213 time_offset => ['-t', 'NTPd time offset ({inst})', '-v', 'Seconds'],
1214 time_dispersion => ['-t', 'NTPd time dispersion ({inst})', '-v', 'Seconds'],
1215 traffic => ['-t', '{host} {inst} traffic', '-v', 'Bit/s'],
1216 users => ['-t', '{host} users', '-v', 'Users'],
1217 multimeter => ['-t', '{host} multimeter', '-v', 'Value'],
1218 voltage => ['-t', '{host} voltage {inst}', '-v', 'Volts'],
1219 vs_threads => ['-t', '{host} threads', '-v', 'Threads'],
1220 vs_memory => ['-t', '{host} memory usage', '-v', 'Bytes'],
1221 vs_processes => ['-t', '{host} processes', '-v', 'Processes'],
1222 };
1224 our $GraphMulti =
1225 {
1226 apache_scoreboard => \&output_graph_apache_scoreboard,
1227 cpu => \&output_graph_cpu,
1228 cpufreq => 1,
1229 disk => 1,
1230 email => \&output_graph_email_count,
1231 email_size => \&output_graph_email_size,
1232 spam_score => 1,
1233 spam_check => \&output_graph_spam_check,
1234 load => 0,
1235 mails => 0,
1236 memory => 0,
1237 mysql_commands => \&output_graph_mysql_commands,
1238 mysql_handler => \&output_graph_mysql_handler,
1239 partition => 1,
1240 ping => \&output_graph_ping,
1241 qtype => \&output_graph_named_qtype,
1242 rcode => \&output_graph_named_rcode,
1243 sensors => 1,
1244 traffic => 1,
1245 users => 1,
1246 multimeter => 1
1247 };
1249 our @Info;
1250 if (defined ($ENV{'GATEWAY_INTERFACE'}))
1251 {
1252 @Info = ($ENV{'PATH_INFO'} || '') =~ m#([\w\-\.]+)#g;
1253 }
1254 else
1255 {
1256 @Info = @ARGV;
1257 }
1259 parse_pathinfo (@Info);
1261 if ($TimeSpan)
1262 {
1263 output_graph ();
1264 }
1265 else
1266 {
1267 output_page ();
1268 }
1270 exit (0);
1272 sub output_graph_cpu
1273 {
1274 my @inst = @_;
1275 my @ret = ();
1277 die if (@inst < 2);
1279 for (@inst)
1280 {
1281 push (@ret,
1282 "DEF:user_avg_$_=$AbsDir/cpu-$_.rrd:user:AVERAGE",
1283 "DEF:user_min_$_=$AbsDir/cpu-$_.rrd:user:MIN",
1284 "DEF:user_max_$_=$AbsDir/cpu-$_.rrd:user:MAX",
1285 "DEF:nice_avg_$_=$AbsDir/cpu-$_.rrd:nice:AVERAGE",
1286 "DEF:nice_min_$_=$AbsDir/cpu-$_.rrd:nice:MIN",
1287 "DEF:nice_max_$_=$AbsDir/cpu-$_.rrd:nice:MAX",
1288 "DEF:syst_avg_$_=$AbsDir/cpu-$_.rrd:syst:AVERAGE",
1289 "DEF:syst_min_$_=$AbsDir/cpu-$_.rrd:syst:MIN",
1290 "DEF:syst_max_$_=$AbsDir/cpu-$_.rrd:syst:MAX",
1291 "DEF:wait_avg_$_=$AbsDir/cpu-$_.rrd:wait:AVERAGE",
1292 "DEF:wait_min_$_=$AbsDir/cpu-$_.rrd:wait:MIN",
1293 "DEF:wait_max_$_=$AbsDir/cpu-$_.rrd:wait:MAX");
1294 }
1296 for (qw(user nice syst wait))
1297 {
1298 my $def = $_;
1299 my $cdef;
1301 my $default_value = ($def eq 'user' or $def eq 'syst') ? 'UNKN' : '0';
1303 for (qw(avg min max))
1304 {
1305 my $cf = $_;
1307 for (@inst)
1308 {
1309 push (@ret, "CDEF:${def}_${cf}_notnull_${_}=${def}_${cf}_${_},UN,0,${def}_${cf}_${_},IF");
1310 push (@ret, "CDEF:${def}_${cf}_defined_${_}=${def}_${cf}_${_},UN,0,1,IF");
1311 }
1313 $cdef = "CDEF:${def}_${cf}_num=" . join (',', map { "${def}_${cf}_defined_${_}" } (@inst));
1314 $cdef .= ',+' x (scalar (@inst) - 1);
1315 push (@ret, $cdef);
1317 $cdef = "CDEF:${def}_${cf}=${def}_${cf}_num," . join (',', map { "${def}_${cf}_notnull_${_}" } (@inst));
1318 $cdef .= ',+' x (scalar (@inst) - 1);
1319 $cdef .= ",${def}_${cf}_num,${def}_${cf}_num,1,IF,/,$default_value,IF";
1320 push (@ret, $cdef);
1321 push (@ret, "CDEF:${def}_${cf}_notnull=${def}_${cf},UN,0,${def}_${cf},IF");
1322 }
1323 }
1325 push (@ret,
1326 "CDEF:nice_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,nice_avg_notnull,+,+,+",
1327 "CDEF:user_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,+,+",
1328 "CDEF:wait_acc=syst_avg_notnull,wait_avg_notnull,+",
1329 "CDEF:syst_acc=syst_avg_notnull");
1331 push (@ret, grep { $_ !~ m/^C?DEF/ } (@{$GraphDefs->{'cpu'}}));
1333 return (@ret);
1334 }
1336 sub output_graph_apache_scoreboard
1337 {
1338 my @inst = @_;
1339 my @ret = ();
1341 die if (@inst < 2);
1343 my @colors = get_n_colors (scalar (@inst));
1345 for (my $i = 0; $i < scalar (@inst); $i++)
1346 {
1347 my $inst = $inst[$i];
1348 push (@ret,
1349 "DEF:avg_$i=$AbsDir/apache_scoreboard-$inst.rrd:count:AVERAGE",
1350 "DEF:min_$i=$AbsDir/apache_scoreboard-$inst.rrd:count:MIN",
1351 "DEF:max_$i=$AbsDir/apache_scoreboard-$inst.rrd:count:MAX");
1352 }
1354 for (my $i = 0; $i < scalar (@inst); $i++)
1355 {
1356 my $inst = $inst[$i];
1357 my $color = $colors[$i];
1359 if (length ($inst) > 15)
1360 {
1361 $inst = substr ($inst, 0, 12) . '...';
1362 }
1363 else
1364 {
1365 $inst = sprintf ('%-15s', $inst);
1366 }
1368 push (@ret,
1369 "LINE1:avg_$i#$color:$inst",
1370 "GPRINT:min_$i:MIN:%6.2lf Min,",
1371 "GPRINT:avg_$i:AVERAGE:%6.2lf Avg,",
1372 "GPRINT:max_$i:MAX:%6.2lf Max,",
1373 "GPRINT:avg_$i:LAST:%6.2lf Last\\l");
1374 }
1376 return (@ret);
1377 }
1379 sub output_graph_ping
1380 {
1381 my @inst = @_;
1382 my @ret = ();
1384 die if (@inst < 2);
1386 my @colors = get_n_colors (scalar (@inst));
1388 for (my $i = 0; $i < scalar (@inst); $i++)
1389 {
1390 my $inst = $inst[$i];
1391 push (@ret,
1392 "DEF:avg_$i=$AbsDir/ping-$inst.rrd:ping:AVERAGE",
1393 "DEF:min_$i=$AbsDir/ping-$inst.rrd:ping:MIN",
1394 "DEF:max_$i=$AbsDir/ping-$inst.rrd:ping:MAX");
1395 }
1397 for (my $i = 0; $i < scalar (@inst); $i++)
1398 {
1399 my $inst = $inst[$i];
1400 my $color = $colors[$i];
1402 if (length ($inst) > 15)
1403 {
1404 $inst = substr ($inst, 0, 12) . '...';
1405 }
1406 else
1407 {
1408 $inst = sprintf ('%-15s', $inst);
1409 }
1411 push (@ret,
1412 "LINE1:avg_$i#$color:$inst",
1413 "GPRINT:min_$i:MIN:%4.1lf ms Min,",
1414 "GPRINT:avg_$i:AVERAGE:%4.1lf ms Avg,",
1415 "GPRINT:max_$i:MAX:%4.1lf ms Max,",
1416 "GPRINT:avg_$i:LAST:%4.1lf ms Last\\l");
1417 }
1419 return (@ret);
1420 }
1422 sub output_graph_email_count
1423 {
1424 my @inst = @_;
1425 my @ret = ();
1427 my $c = scalar @inst;
1429 my @colors = get_n_colors ($c);
1431 for (my $i = 0; $i < $c; ++$i) {
1432 push @ret,
1433 "DEF:min_$i=$AbsDir/email-$inst[$i].rrd:count:MIN",
1434 "DEF:avg_$i=$AbsDir/email-$inst[$i].rrd:count:AVERAGE",
1435 "DEF:max_$i=$AbsDir/email-$inst[$i].rrd:count:MAX";
1436 }
1438 for (my $i = 0; $i < $c; ++$i) {
1439 my $s = "";
1441 if (length $inst[$i] > 10) {
1442 $s = substr ($inst[$i], 0, 7) . '...';
1443 }
1444 else {
1445 $s = sprintf '%-10s', $inst[$i];
1446 }
1448 push @ret,
1449 "LINE1:avg_$i#$colors[$i]:$s",
1450 "GPRINT:min_$i:MIN:%4.1lf Min,",
1451 "GPRINT:avg_$i:AVERAGE:%4.1lf Avg,",
1452 "GPRINT:max_$i:MAX:%4.1lf Max,",
1453 "GPRINT:avg_$i:LAST:%4.1lf Last\\l";
1454 }
1455 return @ret;
1456 }
1458 sub output_graph_email_size
1459 {
1460 my @inst = @_;
1461 my @ret = ();
1463 my $c = scalar @inst;
1465 my @colors = get_n_colors ($c);
1467 for (my $i = 0; $i < $c; ++$i) {
1468 push @ret,
1469 "DEF:min_$i=$AbsDir/email_size-$inst[$i].rrd:size:MIN",
1470 "DEF:avg_$i=$AbsDir/email_size-$inst[$i].rrd:size:AVERAGE",
1471 "DEF:max_$i=$AbsDir/email_size-$inst[$i].rrd:size:MAX";
1472 }
1474 for (my $i = 0; $i < $c; ++$i) {
1475 my $s = "";
1477 if (length $inst[$i] > 10) {
1478 $s = substr ($inst[$i], 0, 7) . '...';
1479 }
1480 else {
1481 $s = sprintf '%-10s', $inst[$i];
1482 }
1484 push @ret,
1485 "LINE1:avg_$i#$colors[$i]:$s",
1486 "GPRINT:min_$i:MIN:%4.1lf Min,",
1487 "GPRINT:avg_$i:AVERAGE:%4.1lf Avg,",
1488 "GPRINT:max_$i:MAX:%4.1lf Max,",
1489 "GPRINT:avg_$i:LAST:%4.1lf Last\\l";
1490 }
1491 return @ret;
1492 }
1494 sub output_graph_spam_check
1495 {
1496 my @inst = sort @_;
1497 my @ret = ();
1499 my $c = scalar @inst;
1501 my @colors = get_n_colors ($c);
1503 for (my $i = 0; $i < $c; ++$i) {
1504 push @ret,
1505 "DEF:min_$i=$AbsDir/spam_check-$inst[$i].rrd:hits:MIN",
1506 "DEF:avg_$i=$AbsDir/spam_check-$inst[$i].rrd:hits:AVERAGE",
1507 "DEF:max_$i=$AbsDir/spam_check-$inst[$i].rrd:hits:MAX";
1508 }
1510 for (my $i = 0; $i < $c; ++$i) {
1511 my $s = "";
1513 if (length $inst[$i] > 25) {
1514 $s = substr ($inst[$i], 0, 22) . '...';
1515 }
1516 else {
1517 $s = sprintf '%-25s', $inst[$i];
1518 }
1520 push @ret,
1521 "LINE1:avg_$i#$colors[$i]:$s",
1522 "GPRINT:min_$i:MIN:%4.1lf Min,",
1523 "GPRINT:avg_$i:AVERAGE:%4.1lf Avg,",
1524 "GPRINT:max_$i:MAX:%4.1lf Max,",
1525 "GPRINT:avg_$i:LAST:%4.1lf Last\\l";
1526 }
1527 return @ret;
1528 }
1530 sub output_graph_mysql_commands
1531 {
1532 my @inst = @_;
1533 my @ret = ();
1535 die if (@inst < 2);
1537 my @colors = get_n_colors (scalar (@inst));
1539 for (my $i = 0; $i < scalar (@inst); $i++)
1540 {
1541 my $inst = $inst[$i];
1542 push (@ret,
1543 "DEF:avg_$i=$AbsDir/mysql_commands-$inst.rrd:value:AVERAGE",
1544 "DEF:min_$i=$AbsDir/mysql_commands-$inst.rrd:value:MIN",
1545 "DEF:max_$i=$AbsDir/mysql_commands-$inst.rrd:value:MAX");
1546 }
1548 for (my $i = 0; $i < scalar (@inst); $i++)
1549 {
1550 my $inst = $inst[$i];
1551 my $color = $colors[$i];
1553 if (length ($inst) > 18)
1554 {
1555 $inst = substr ($inst, 0, 15) . '...';
1556 }
1557 else
1558 {
1559 $inst = sprintf ('%-18s', $inst);
1560 }
1562 push (@ret,
1563 "LINE1:avg_$i#$color:$inst",
1564 "GPRINT:min_$i:MIN:%6.1lf Min,",
1565 "GPRINT:avg_$i:AVERAGE:%6.1lf Avg,",
1566 "GPRINT:max_$i:MAX:%6.1lf Max,",
1567 "GPRINT:avg_$i:LAST:%6.1lf Last\\l");
1568 }
1570 return (@ret);
1571 }
1573 sub output_graph_mysql_handler
1574 {
1575 my @inst = @_;
1576 my @ret = ();
1578 die if (@inst < 2);
1580 my @colors = get_n_colors (scalar (@inst));
1582 for (my $i = 0; $i < scalar (@inst); $i++)
1583 {
1584 my $inst = $inst[$i];
1585 push (@ret,
1586 "DEF:avg_$i=$AbsDir/mysql_handler-$inst.rrd:value:AVERAGE",
1587 "DEF:min_$i=$AbsDir/mysql_handler-$inst.rrd:value:MIN",
1588 "DEF:max_$i=$AbsDir/mysql_handler-$inst.rrd:value:MAX");
1589 }
1591 for (my $i = 0; $i < scalar (@inst); $i++)
1592 {
1593 my $inst = $inst[$i];
1594 my $color = $colors[$i];
1596 if (length ($inst) > 18)
1597 {
1598 $inst = substr ($inst, 0, 15) . '...';
1599 }
1600 else
1601 {
1602 $inst = sprintf ('%-18s', $inst);
1603 }
1605 push (@ret,
1606 "LINE1:avg_$i#$color:$inst",
1607 "GPRINT:min_$i:MIN:%6.1lf Min,",
1608 "GPRINT:avg_$i:AVERAGE:%6.1lf Avg,",
1609 "GPRINT:max_$i:MAX:%6.1lf Max,",
1610 "GPRINT:avg_$i:LAST:%6.1lf Last\\l");
1611 }
1613 return (@ret);
1614 }
1616 sub output_graph_named_qtype
1617 {
1618 my @inst = @_;
1619 my @ret = ();
1621 die if (@inst < 2);
1623 my @colors = get_n_colors (scalar (@inst));
1625 for (my $i = 0; $i < scalar (@inst); $i++)
1626 {
1627 my $inst = $inst[$i];
1628 push (@ret,
1629 "DEF:avg_$i=$AbsDir/qtype-$inst.rrd:value:AVERAGE",
1630 "DEF:min_$i=$AbsDir/qtype-$inst.rrd:value:MIN",
1631 "DEF:max_$i=$AbsDir/qtype-$inst.rrd:value:MAX");
1632 }
1634 for (my $i = 0; $i < scalar (@inst); $i++)
1635 {
1636 my $inst = $inst[$i];
1637 my $color = $colors[$i];
1638 my $type = ($i == 0) ? 'AREA' : 'STACK';
1640 if (length ($inst) > 5)
1641 {
1642 $inst = substr ($inst, 0, 5);
1643 }
1644 else
1645 {
1646 $inst = sprintf ('%-5s', $inst);
1647 }
1649 push (@ret,
1650 "$type:avg_$i#$color:$inst",
1651 "GPRINT:min_$i:MIN:%9.3lf Min,",
1652 "GPRINT:avg_$i:AVERAGE:%9.3lf Avg,",
1653 "GPRINT:max_$i:MAX:%9.3lf Max,",
1654 "GPRINT:avg_$i:LAST:%9.3lf Last\\l");
1655 }
1657 return (@ret);
1658 }
1660 sub output_graph_named_rcode
1661 {
1662 my @inst = @_;
1663 my @ret = ();
1665 die if (@inst < 2);
1667 my @colors = get_n_colors (scalar (@inst));
1669 for (my $i = 0; $i < scalar (@inst); $i++)
1670 {
1671 my $inst = $inst[$i];
1672 push (@ret,
1673 "DEF:avg_$i=$AbsDir/rcode-$inst.rrd:value:AVERAGE",
1674 "DEF:min_$i=$AbsDir/rcode-$inst.rrd:value:MIN",
1675 "DEF:max_$i=$AbsDir/rcode-$inst.rrd:value:MAX");
1676 }
1678 for (my $i = 0; $i < scalar (@inst); $i++)
1679 {
1680 my $inst = $inst[$i];
1681 my $color = $colors[$i];
1682 my $type = ($i == 0) ? 'AREA' : 'STACK';
1684 if (length ($inst) > 8)
1685 {
1686 $inst = substr ($inst, 0, 6) . '..';
1687 }
1688 else
1689 {
1690 $inst = sprintf ('%-8s', $inst);
1691 }
1693 push (@ret,
1694 "$type:avg_$i#$color:$inst",
1695 "GPRINT:min_$i:MIN:%9.3lf Min,",
1696 "GPRINT:avg_$i:AVERAGE:%9.3lf Avg,",
1697 "GPRINT:max_$i:MAX:%9.3lf Max,",
1698 "GPRINT:avg_$i:LAST:%9.3lf Last\\l");
1699 }
1701 return (@ret);
1702 }
1703 sub output_graph
1704 {
1705 die unless (defined ($GraphDefs->{$Type}));
1707 my $host;
1708 my @cmd = ();
1709 my $file = $AbsDir . '/';
1710 my $files = get_all_files ($AbsDir);
1712 #
1713 # get hostname
1714 #
1715 if ($RelDir =~ m#([^/]+)$#)
1716 {
1717 $host = $1;
1718 }
1719 else
1720 {
1721 $host = $Config->{'HostName'};
1722 }
1724 #
1725 # get timespan
1726 #
1727 if ($TimeSpan =~ m/(\d+)/)
1728 {
1729 $TimeSpan = -1 * int ($1);
1730 }
1731 else
1732 {
1733 my %t = (hour => -3600, day => -86400, week => -604800, month => -2678400, year => -31622400);
1734 die unless (defined ($t{$TimeSpan}));
1735 $TimeSpan = $t{$TimeSpan};
1736 }
1738 if (scalar (@{$files->{$Type}}) == 1)
1739 {
1740 $Inst = $files->{$Type}[0];
1741 }
1743 #push (@cmd, '-', '-a', 'PNG', '-s', $TimeSpan, '-w', 800, '-h', 150);
1744 push (@cmd, '-', '-a', 'PNG', '-s', $TimeSpan);
1745 push (@cmd, @{$GraphArgs->{$Type}}) if (defined ($GraphArgs->{$Type}));
1747 for (qw(Back ShadeA ShadeB Font Canvas Grid MGrid Frame Arrow))
1748 {
1749 push (@cmd, '-c', uc ($_) . '#' . $Config->{'Colors'}{$_});
1750 }
1752 if ((length ($Inst) == 0) and (ref ($GraphMulti->{$Type}) eq 'CODE'))
1753 {
1754 push (@cmd, $GraphMulti->{$Type}->(@{$files->{$Type}}));
1755 }
1756 else
1757 {
1758 if (length ("$Inst"))
1759 {
1760 $file .= "$Type-$Inst.rrd";
1761 }
1762 else
1763 {
1764 $file .= "$Type.rrd";
1765 }
1767 die ("File not found: $file") unless (-e $file);
1769 push (@cmd, @{$GraphDefs->{$Type}});
1770 }
1772 for (@cmd)
1773 {
1774 $_ =~ s/{file}/$file/g;
1775 $_ =~ s/{host}/$host/g;
1776 $_ =~ s/{inst}/$Inst/g;
1777 $_ =~ s/{type}/$Type/g;
1778 }
1780 $| = 1;
1782 print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1783 Content-Type: image/png
1784 Cache-Control: no-cache
1786 HEADER
1788 if (1)
1789 {
1790 my $fh;
1791 open ($fh, ">/tmp/collection.log") or die ("open: $!");
1792 flock ($fh, LOCK_EX) or die ("flock: $!");
1794 print $fh join ("\n\t", @cmd) . "\n";
1796 close ($fh);
1797 }
1799 RRDs::graph (@cmd);
1801 die ('RRDs::error: ' . RRDs::error ()) if (RRDs::error ());
1802 }
1804 sub output_page
1805 {
1806 my $files = get_all_files ($AbsDir);
1807 my $dirs = get_all_dirs ($AbsDir);
1809 print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1810 Content-Type: text/html
1811 Cache-Control: no-cache
1813 <html>
1814 <head>
1815 <title>Collection: $RelDir</title>
1816 <style type="text/css">
1817 img { border: none; display: block; }
1818 </style>
1819 </head>
1821 <body>
1822 HEADER
1824 my $MySelf = defined ($ENV{'GATEWAY_INTERFACE'}) ? $ENV{'SCRIPT_NAME'} : $0;
1826 if ((length ($Type) != 0) and (length ($Inst) == 0) and (ref ($GraphMulti->{$Type}) eq 'CODE') and (scalar (@{$files->{$Type}}) > 1))
1827 {
1828 print qq(\t\t<div><a href="$MySelf$RelDir">Go up</a></div>\n);
1830 print "\t\t<ul>\n";
1831 for (@{$files->{$Type}})
1832 {
1833 print qq(\t\t\t<li><a href="$MySelf$RelDir/$Type/$_">$_</a></li>\n);
1834 }
1835 print <<HTML;
1836 </ul>
1838 <h3>Hourly</h3>
1839 <div><img src="$MySelf$RelDir/$Type/hour" /></div>
1840 <h3>Daily</h3>
1841 <div><img src="$MySelf$RelDir/$Type/day" /></div>
1842 <h3>Weekly</h3>
1843 <div><img src="$MySelf$RelDir/$Type/week" /></div>
1844 <h3>Monthly</h3>
1845 <div><img src="$MySelf$RelDir/$Type/month" /></div>
1846 <h3>Yearly</h3>
1847 <div><img src="$MySelf$RelDir/$Type/year" /></div>
1848 HTML
1849 }
1850 elsif (length ($Type) != 0)
1851 {
1852 my $ext = length ($Inst) ? "$Type/$Inst" : $Type;
1854 if ((ref ($GraphMulti->{$Type}) eq 'CODE') and (scalar (@{$files->{$Type}}) > 1))
1855 {
1856 print qq(<div><a href="$MySelf$RelDir/$Type">Go up</a></div>\n);
1857 }
1858 else
1859 {
1860 print qq(<div><a href="$MySelf$RelDir">Go up</a></div>\n);
1861 }
1863 print <<HTML;
1864 <h3>Hourly</h3>
1865 <div><img src="$MySelf$RelDir/$ext/hour" /></div>
1866 <h3>Daily</h3>
1867 <div><img src="$MySelf$RelDir/$ext/day" /></div>
1868 <h3>Weekly</h3>
1869 <div><img src="$MySelf$RelDir/$ext/week" /></div>
1870 <h3>Monthly</h3>
1871 <div><img src="$MySelf$RelDir/$ext/month" /></div>
1872 <h3>Yearly</h3>
1873 <div><img src="$MySelf$RelDir/$ext/year" /></div>
1874 HTML
1875 }
1876 else
1877 {
1878 if ($RelDir)
1879 {
1880 my ($up) = $RelDir =~ m#(.*)/[^/]+$#;
1881 print qq(\t\t<div><a href="$MySelf$up">Go up</a></div>\n);
1882 }
1884 if (@$dirs)
1885 {
1886 print "<ul>\n";
1887 for (@$dirs)
1888 {
1889 print qq(<li>$AbsDir/<a href="$MySelf$RelDir/$_">$_</a></li>\n);
1890 }
1891 print "</ul>\n";
1892 }
1894 for (sort (keys %$files))
1895 {
1896 my $type = $_;
1898 if (ref ($GraphMulti->{$type}) eq 'CODE')
1899 {
1900 print qq(\t\t<a href="$MySelf$RelDir/$type" />),
1901 qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
1902 next;
1903 }
1905 for (@{$files->{$type}})
1906 {
1907 my $inst = "$_";
1909 if (length ($inst))
1910 {
1911 print qq(\t\t<a href="$MySelf$RelDir/$type/$inst" />),
1912 qq(<img src="$MySelf$RelDir/$type/$inst/day" /></a>\n);
1913 }
1914 else
1915 {
1916 print qq(\t\t<a href="$MySelf$RelDir/$type" />),
1917 qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
1918 }
1919 }
1920 }
1921 }
1923 print STDOUT <<FOOTER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1924 </body>
1925 </html>
1926 FOOTER
1927 }
1929 sub output_xml
1930 {
1931 my $files = get_all_files ();
1933 print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1934 Content-Type: text/xml
1935 Cache-Control: no-cache
1937 HEADER
1938 print STDOUT pl2xml ($files);
1939 }
1941 sub read_config
1942 {
1943 my $file = @_ ? shift : '/etc/collection.conf';
1944 my $conf;
1945 my $fh;
1947 # if (open ($fh, "< $file"))
1948 # {
1949 # my $xml;
1950 # local $/ = undef;
1951 # $xml = <$fh>;
1952 #
1953 # eval
1954 # {
1955 # $conf = xml2pl ($xml);
1956 # };
1957 # close ($fh);
1958 # }
1960 if (!$conf)
1961 {
1962 return ({
1963 Colors =>
1964 {
1965 Back => 'FFFFFF',
1966 ShadeA => 'FFFFFF',
1967 ShadeB => 'FFFFFF',
1968 Font => '000000',
1969 Canvas => 'F5F5F5',
1970 Grid => 'D0D0D0',
1971 MGrid => 'A0A0A0',
1972 Frame => '646464',
1973 Arrow => 'FF0000',
1975 FullRed => 'FF0000',
1976 FullBlue => '0000FF',
1977 FullGreen => '00E000',
1978 FullYellow => 'F0A000',
1979 FullCyan => '00A0FF',
1980 FullMagenta => 'A000FF',
1981 Alpha => 0.25,
1982 HalfRed => 'F8B8B8',
1983 HalfBlue => 'B8B8F8',
1984 HalfGreen => 'B8F0B8',
1985 HalfYellow => 'F4F4B8'
1986 },
1987 Directory => '/var/lib/collectd',
1988 HostName => (defined ($ENV{'SERVER_NAME'}) ? $ENV{'SERVER_NAME'} : 'localhost')
1989 });
1990 }
1991 else
1992 {
1993 return ($conf);
1994 }
1995 }
1997 sub parse_pathinfo
1998 {
1999 my @info = @_;
2001 $AbsDir = $Config->{'Directory'};
2002 $RelDir = '';
2004 while (@info and -d $AbsDir . '/' . $info[0])
2005 {
2006 my $new = shift (@info);
2007 next if ($new =~ m/^\./);
2009 $AbsDir .= '/' . $new;
2010 $RelDir .= '/' . $new;
2011 }
2013 $Type = '';
2014 $Inst = '';
2015 $TimeSpan = '';
2017 confess ("parse_pathinfo: too many elements in pathinfo") if (scalar (@info) > 3);
2018 return unless (@info);
2020 $Type = shift (@info);
2021 return unless (@info);
2023 if ($info[-1] =~ m/^(hour|day|week|month|year)$/i)
2024 {
2025 $TimeSpan = pop (@info);
2026 }
2028 $Inst = shift (@info) if (@info);
2030 confess ("unrecognized elements in pathinfo") if (@info);
2031 }
2033 sub get_all_files
2034 {
2035 my $dir = @_ ? shift : $Config->{'Directory'};
2036 my $hash = {};
2037 my $dh;
2039 if (opendir ($dh, $dir))
2040 {
2041 while (my $thing = readdir ($dh))
2042 {
2043 next if ($thing =~ m/^\./);
2045 my $type;
2046 my $inst;
2048 if ($thing =~ m/^(\w+)-([\w\-\.]+)\.rrd$/)
2049 {
2050 $type = $1;
2051 $inst = $2;
2052 }
2053 elsif ($thing =~ m/^(\w+)\.rrd$/)
2054 {
2055 $type = $1;
2056 $inst = '';
2057 }
2058 else
2059 {
2060 next;
2061 }
2063 # Only load RRD files we can actually display..
2064 next unless (defined ($GraphDefs->{$type}));
2066 $hash->{$type} = [] unless (defined ($hash->{$type}));
2067 push (@{$hash->{$type}}, $inst);
2068 }
2070 closedir ($dh);
2071 }
2073 return ($hash);
2074 }
2076 sub get_all_dirs
2077 {
2078 my $dir = @_ ? shift : $Config->{'Directory'};
2079 my @ret = ();
2080 my $dh;
2082 if (opendir ($dh, $dir))
2083 {
2084 while (my $thing = readdir ($dh))
2085 {
2086 next if ($thing =~ m/^\./);
2088 next if (!-d "$dir/$thing");
2090 push (@ret, $thing);
2091 }
2093 closedir ($dh);
2094 }
2096 return (@ret) if (wantarray ());
2097 return (\@ret);
2098 }
2100 sub color_hex2rgb
2101 {
2102 my $color = shift;
2104 my ($red, $green, $blue) = map { ord (pack ("H2", $_)) } ($color =~ m/([A-Fa-f0-9]{2})/g);
2105 #print STDERR "$color -> rgb($red,$green,$blue)\n";
2107 return ($red, $green, $blue);
2108 }
2110 sub color_rgb2hex
2111 {
2112 croak unless (scalar (@_) == 3);
2114 my ($red, $green, $blue) = @_;
2116 my $ret = sprintf ("%02X%02X%02X", $red, $green, $blue);
2117 #print STDERR "rgb($red,$green,$blue) -> $ret\n";
2119 return ($ret);
2120 }
2122 sub color_calculate_transparent
2123 {
2124 my $alpha = shift;
2125 my $canvas = [color_hex2rgb (shift)];
2126 my @colors = map { [color_hex2rgb ($_)] } (@_);
2128 if (($alpha < 0.0) or ($alpha > 1.0))
2129 {
2130 $alpha = 1.0;
2131 }
2133 if ($alpha == 0.0)
2134 {
2135 return (color_rgb2hex (@$canvas));
2136 }
2137 if ($alpha == 1.0)
2138 {
2139 return (color_rgb2hex (@{$colors[-1]}));
2140 }
2142 my $ret = _color_calculate_transparent ($alpha, $canvas, @colors);
2144 return (color_rgb2hex (@$ret));
2145 }
2147 sub _color_calculate_transparent
2148 {
2149 my $alpha = shift;
2150 my $canvas = shift;
2151 my $color = shift;
2152 my @colors = @_ ? shift : ();
2153 my $ret = [0, 0, 0];
2155 for (my $i = 0; $i < 3; $i++)
2156 {
2157 $ret->[$i] = ($alpha * $color->[$i]) + ((1 - $alpha) * $canvas->[$i]);
2158 }
2160 return (_color_calculate_transparent ($alpha, $ret, @colors)) if (@colors);
2161 return ($ret);
2162 }
2164 sub get_n_colors
2165 {
2166 my $num = shift;
2167 my @ret = ();
2169 for (my $i = 0; $i < $num; $i++)
2170 {
2171 my $pos = 6 * $i / $num;
2172 my $n = int ($pos);
2173 my $p = $pos - $n;
2174 my $q = 1 - $p;
2176 my $red = 0;
2177 my $green = 0;
2178 my $blue = 0;
2180 if ($n == 0)
2181 {
2182 $red = 255;
2183 $blue = 255 * $p;
2184 }
2185 elsif ($n == 1)
2186 {
2187 $red = 255 * $q;
2188 $blue = 255;
2189 }
2190 elsif ($n == 2)
2191 {
2192 $green = 255 * $p;
2193 $blue = 255;
2194 }
2195 elsif ($n == 3)
2196 {
2197 $green = 255;
2198 $blue = 255 * $q;
2199 }
2200 elsif ($n == 4)
2201 {
2202 $red = 255 * $p;
2203 $green = 255;
2204 }
2205 elsif ($n == 5)
2206 {
2207 $red = 255;
2208 $green = 255 * $q;
2209 }
2210 else { die; }
2212 push (@ret, sprintf ("%02x%02x%02x", $red, $green, $blue));
2213 }
2215 return (@ret);
2216 }