10 use Fcntl (qw(:flock));
11 use Carp (qw(carp cluck confess croak));
13 our $Config = read_config ();
21 for (qw(Red Green Blue Yellow Cyan Magenta))
23 $Config->{'Colors'}{"Half$_"} = color_calculate_transparent ($Config->{'Colors'}{'Alpha'},
24 $Config->{'Colors'}{'Canvas'}, $Config->{'Colors'}{"Full$_"});
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'});
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'};
56 cpu => ['DEF:user_avg={file}:user:AVERAGE',
57 'DEF:user_min={file}:user:MIN',
58 'DEF:user_max={file}:user:MAX',
59 'DEF:nice_avg={file}:nice:AVERAGE',
60 'DEF:nice_min={file}:nice:MIN',
61 'DEF:nice_max={file}:nice:MAX',
62 'DEF:syst_avg={file}:syst:AVERAGE',
63 'DEF:syst_min={file}:syst:MIN',
64 'DEF:syst_max={file}:syst:MAX',
65 'DEF:idle_avg={file}:idle:AVERAGE',
66 'DEF:idle_min={file}:idle:MIN',
67 'DEF:idle_max={file}:idle:MAX',
68 'DEF:wait_avg={file}:wait:AVERAGE',
69 'DEF:wait_min={file}:wait:MIN',
70 'DEF:wait_max={file}:wait:MAX',
71 'CDEF:user_avg_notnull=user_avg,UN,0,user_avg,IF',
72 'CDEF:nice_avg_notnull=nice_avg,UN,0,nice_avg,IF',
73 'CDEF:syst_avg_notnull=syst_avg,UN,0,syst_avg,IF',
74 'CDEF:idle_avg_notnull=idle_avg,UN,0,idle_avg,IF',
75 'CDEF:wait_avg_notnull=wait_avg,UN,0,wait_avg,IF',
76 'CDEF:totl_avg_notnull=user_avg_notnull,nice_avg_notnull,+,syst_avg_notnull,+,idle_avg_notnull,+,wait_avg_notnull,+',
77 'CDEF:user_avg_pct=user_avg_notnull,100,*,totl_avg_notnull,/',
78 'CDEF:nice_avg_pct=nice_avg_notnull,100,*,totl_avg_notnull,/',
79 'CDEF:syst_avg_pct=syst_avg_notnull,100,*,totl_avg_notnull,/',
80 'CDEF:wait_avg_pct=wait_avg_notnull,100,*,totl_avg_notnull,/',
81 'CDEF:nice_acc=syst_avg_pct,wait_avg_pct,user_avg_pct,nice_avg_pct,+,+,+',
82 'CDEF:user_acc=syst_avg_pct,wait_avg_pct,user_avg_pct,+,+',
83 'CDEF:wait_acc=syst_avg_pct,wait_avg_pct,+',
84 'CDEF:syst_acc=syst_avg_pct',
85 # 'CDEF:nice_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,nice_avg_notnull,+,+,+',
86 # 'CDEF:user_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,+,+',
87 # 'CDEF:wait_acc=syst_avg_notnull,wait_avg_notnull,+',
88 # 'CDEF:syst_acc=syst_avg_notnull',
89 "AREA:nice_acc#$HalfGreen",
90 "AREA:user_acc#$HalfBlue",
91 "AREA:wait_acc#$HalfYellow",
92 "AREA:syst_acc#$HalfRed",
93 "LINE1:nice_acc#$FullGreen:Nice ",
94 'GPRINT:nice_min:MIN:%5.1lf%% Min,',
95 'GPRINT:nice_avg:AVERAGE:%5.1lf%% Avg,',
96 'GPRINT:nice_max:MAX:%5.1lf%% Max,',
97 'GPRINT:nice_avg:LAST:%5.1lf%% Last\l',
98 "LINE1:user_acc#$FullBlue:User ",
99 'GPRINT:user_min:MIN:%5.1lf%% Min,',
100 'GPRINT:user_avg:AVERAGE:%5.1lf%% Avg,',
101 'GPRINT:user_max:MAX:%5.1lf%% Max,',
102 'GPRINT:user_avg:LAST:%5.1lf%% Last\l',
103 "LINE1:wait_acc#$FullYellow:Wait-IO",
104 'GPRINT:wait_min:MIN:%5.1lf%% Min,',
105 'GPRINT:wait_avg:AVERAGE:%5.1lf%% Avg,',
106 'GPRINT:wait_max:MAX:%5.1lf%% Max,',
107 'GPRINT:wait_avg:LAST:%5.1lf%% Last\l',
108 "LINE1:syst_acc#$FullRed:System ",
109 'GPRINT:syst_min:MIN:%5.1lf%% Min,',
110 'GPRINT:syst_avg:AVERAGE:%5.1lf%% Avg,',
111 'GPRINT:syst_max:MAX:%5.1lf%% Max,',
112 'GPRINT:syst_avg:LAST:%5.1lf%% Last\l'
115 'DEF:free_avg={file}:free:AVERAGE',
116 'DEF:free_min={file}:free:MIN',
117 'DEF:free_max={file}:free:MAX',
118 'DEF:used_avg={file}:used:AVERAGE',
119 'DEF:used_min={file}:used:MIN',
120 'DEF:used_max={file}:used:MAX',
121 'CDEF:total=free_avg,used_avg,+',
122 'CDEF:free_pct=100,free_avg,*,total,/',
123 'CDEF:used_pct=100,used_avg,*,total,/',
124 'CDEF:free_acc=free_pct,used_pct,+',
125 'CDEF:used_acc=used_pct',
126 "AREA:free_acc#$HalfGreen",
127 "AREA:used_acc#$HalfRed",
128 "LINE1:free_acc#$FullGreen:Free",
129 'GPRINT:free_min:MIN:%5.1lf%sB Min,',
130 'GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,',
131 'GPRINT:free_max:MAX:%5.1lf%sB Max,',
132 'GPRINT:free_avg:LAST:%5.1lf%sB Last\l',
133 "LINE1:used_acc#$FullRed:Used",
134 'GPRINT:used_min:MIN:%5.1lf%sB Min,',
135 'GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,',
136 'GPRINT:used_max:MAX:%5.1lf%sB Max,',
137 'GPRINT:used_avg:LAST:%5.1lf%sB Last\l'
140 'DEF:rtime_avg={file}:rtime:AVERAGE',
141 'DEF:rtime_min={file}:rtime:MIN',
142 'DEF:rtime_max={file}:rtime:MAX',
143 'DEF:wtime_avg={file}:wtime:AVERAGE',
144 'DEF:wtime_min={file}:wtime:MIN',
145 'DEF:wtime_max={file}:wtime:MAX',
146 'CDEF:rtime_avg_ms=rtime_avg,1000,/',
147 'CDEF:rtime_min_ms=rtime_min,1000,/',
148 'CDEF:rtime_max_ms=rtime_max,1000,/',
149 'CDEF:wtime_avg_ms=wtime_avg,1000,/',
150 'CDEF:wtime_min_ms=wtime_min,1000,/',
151 'CDEF:wtime_max_ms=wtime_max,1000,/',
152 'CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+',
153 'CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+',
154 'CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+',
155 "AREA:total_max_ms#$HalfRed",
156 "AREA:total_min_ms#$Canvas",
157 "LINE1:wtime_avg_ms#$FullGreen:Write",
158 'GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,',
159 'GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
160 'GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,',
161 'GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n',
162 "LINE1:rtime_avg_ms#$FullBlue:Read ",
163 'GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,',
164 'GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,',
165 'GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,',
166 'GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n',
167 "LINE1:total_avg_ms#$FullRed:Total",
168 'GPRINT:total_min_ms:MIN:%5.1lf%s Min,',
169 'GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,',
170 'GPRINT:total_max_ms:MAX:%5.1lf%s Max,',
171 'GPRINT:total_avg_ms:LAST:%5.1lf%s Last'
174 'DEF:temp_avg={file}:value:AVERAGE',
175 'DEF:temp_min={file}:value:MIN',
176 'DEF:temp_max={file}:value:MAX',
177 "AREA:temp_max#$HalfBlue",
178 "AREA:temp_min#$Canvas",
179 "LINE1:temp_avg#$FullBlue:Temperature",
180 'GPRINT:temp_min:MIN:%4.1lf Min,',
181 'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
182 'GPRINT:temp_max:MAX:%4.1lf Max,',
183 'GPRINT:temp_avg:LAST:%4.1lf Last\l'
185 load => ['DEF:s_avg={file}:shortterm:AVERAGE',
186 'DEF:s_min={file}:shortterm:MIN',
187 'DEF:s_max={file}:shortterm:MAX',
188 'DEF:m_avg={file}:midterm:AVERAGE',
189 'DEF:m_min={file}:midterm:MIN',
190 'DEF:m_max={file}:midterm:MAX',
191 'DEF:l_avg={file}:longterm:AVERAGE',
192 'DEF:l_min={file}:longterm:MIN',
193 'DEF:l_max={file}:longterm:MAX',
194 "AREA:s_max#$HalfGreen",
195 "AREA:s_min#$Canvas",
196 "LINE1:s_avg#$FullGreen: 1m average",
197 'GPRINT:s_min:MIN:%4.2lf Min,',
198 'GPRINT:s_avg:AVERAGE:%4.2lf Avg,',
199 'GPRINT:s_max:MAX:%4.2lf Max,',
200 'GPRINT:s_avg:LAST:%4.2lf Last\n',
201 "LINE1:m_avg#$FullBlue: 5m average",
202 'GPRINT:m_min:MIN:%4.2lf Min,',
203 'GPRINT:m_avg:AVERAGE:%4.2lf Avg,',
204 'GPRINT:m_max:MAX:%4.2lf Max,',
205 'GPRINT:m_avg:LAST:%4.2lf Last\n',
206 "LINE1:l_avg#$FullRed:15m average",
207 'GPRINT:l_min:MIN:%4.2lf Min,',
208 'GPRINT:l_avg:AVERAGE:%4.2lf Avg,',
209 'GPRINT:l_max:MAX:%4.2lf Max,',
210 'GPRINT:l_avg:LAST:%4.2lf Last'
212 mails => ['DEF:rawgood={file}:good:AVERAGE',
213 'DEF:rawspam={file}:spam:AVERAGE',
214 'CDEF:good=rawgood,UN,0,rawgood,IF',
215 'CDEF:spam=rawspam,UN,0,rawspam,IF',
216 'CDEF:negspam=spam,-1,*',
217 "AREA:good#$HalfGreen",
218 "LINE1:good#$FullGreen:Good mails",
219 'GPRINT:good:AVERAGE:%4.1lf Avg,',
220 'GPRINT:good:MAX:%4.1lf Max,',
221 'GPRINT:good:LAST:%4.1lf Last\n',
222 "AREA:negspam#$HalfRed",
223 "LINE1:negspam#$FullRed:Spam mails",
224 'GPRINT:spam:AVERAGE:%4.1lf Avg,',
225 'GPRINT:spam:MAX:%4.1lf Max,',
226 'GPRINT:spam:LAST:%4.1lf Last',
229 'DEF:used_avg={file}:used:AVERAGE',
230 'DEF:free_avg={file}:free:AVERAGE',
231 'DEF:buffers_avg={file}:buffers:AVERAGE',
232 'DEF:cached_avg={file}:cached:AVERAGE',
233 'DEF:used_min={file}:used:MIN',
234 'DEF:free_min={file}:free:MIN',
235 'DEF:buffers_min={file}:buffers:MIN',
236 'DEF:cached_min={file}:cached:MIN',
237 'DEF:used_max={file}:used:MAX',
238 'DEF:free_max={file}:free:MAX',
239 'DEF:buffers_max={file}:buffers:MAX',
240 'DEF:cached_max={file}:cached:MAX',
241 'CDEF:free_cached_buffers_used=free_avg,cached_avg,+,buffers_avg,+,used_avg,+',
242 'CDEF:cached_buffers_used=cached_avg,buffers_avg,+,used_avg,+',
243 'CDEF:buffers_used=buffers_avg,used_avg,+',
244 "AREA:free_cached_buffers_used#$HalfGreen",
245 "AREA:cached_buffers_used#$HalfBlue",
246 "AREA:buffers_used#$HalfYellow",
247 "AREA:used_avg#$HalfRed",
248 "LINE1:free_cached_buffers_used#$FullGreen:Free ",
249 'GPRINT:free_min:MIN:%5.1lf%s Min,',
250 'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
251 'GPRINT:free_max:MAX:%5.1lf%s Max,',
252 'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
253 "LINE1:cached_buffers_used#$FullBlue:Page cache ",
254 'GPRINT:cached_min:MIN:%5.1lf%s Min,',
255 'GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,',
256 'GPRINT:cached_max:MAX:%5.1lf%s Max,',
257 'GPRINT:cached_avg:LAST:%5.1lf%s Last\n',
258 "LINE1:buffers_used#$FullYellow:Buffer cache",
259 'GPRINT:buffers_min:MIN:%5.1lf%s Min,',
260 'GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,',
261 'GPRINT:buffers_max:MAX:%5.1lf%s Max,',
262 'GPRINT:buffers_avg:LAST:%5.1lf%s Last\n',
263 "LINE1:used_avg#$FullRed:Used ",
264 'GPRINT:used_min:MIN:%5.1lf%s Min,',
265 'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
266 'GPRINT:used_max:MAX:%5.1lf%s Max,',
267 'GPRINT:used_avg:LAST:%5.1lf%s Last'
270 "DEF:val_avg={file}:value:AVERAGE",
271 "DEF:val_min={file}:value:MIN",
272 "DEF:val_max={file}:value:MAX",
273 "AREA:val_max#$HalfBlue",
274 "AREA:val_min#$Canvas",
275 "LINE1:val_avg#$FullBlue:{inst}",
276 'GPRINT:val_min:MIN:%5.2lf Min,',
277 'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
278 'GPRINT:val_max:MAX:%5.2lf Max,',
279 'GPRINT:val_avg:LAST:%5.2lf Last'
282 "DEF:val_avg={file}:value:AVERAGE",
283 "DEF:val_min={file}:value:MIN",
284 "DEF:val_max={file}:value:MAX",
285 "AREA:val_max#$HalfBlue",
286 "AREA:val_min#$Canvas",
287 "LINE1:val_avg#$FullBlue:{inst}",
288 'GPRINT:val_min:MIN:%5.2lf Min,',
289 'GPRINT:val_avg:AVERAGE:%5.2lf Avg,',
290 'GPRINT:val_max:MAX:%5.2lf Max,',
291 'GPRINT:val_avg:LAST:%5.2lf Last'
294 "DEF:hits_min={file}:hits:MIN",
295 "DEF:hits_avg={file}:hits:AVERAGE",
296 "DEF:hits_max={file}:hits:MAX",
297 "DEF:inserts_min={file}:inserts:MIN",
298 "DEF:inserts_avg={file}:inserts:AVERAGE",
299 "DEF:inserts_max={file}:inserts:MAX",
300 "DEF:not_cached_min={file}:not_cached:MIN",
301 "DEF:not_cached_avg={file}:not_cached:AVERAGE",
302 "DEF:not_cached_max={file}:not_cached:MAX",
303 "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN",
304 "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE",
305 "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX",
306 "DEF:queries_min={file}:queries_in_cache:MIN",
307 "DEF:queries_avg={file}:queries_in_cache:AVERAGE",
308 "DEF:queries_max={file}:queries_in_cache:MAX",
309 "CDEF:unknown=queries_avg,UNKN,+",
310 "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+",
311 "CDEF:inserts_agg=hits_avg,inserts_avg,+",
312 "CDEF:hits_agg=hits_avg",
313 "AREA:not_cached_agg#$HalfYellow",
314 "AREA:inserts_agg#$HalfBlue",
315 "AREA:hits_agg#$HalfGreen",
316 "LINE1:not_cached_agg#$FullYellow:Not Cached ",
317 'GPRINT:not_cached_min:MIN:%5.2lf Min,',
318 'GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,',
319 'GPRINT:not_cached_max:MAX:%5.2lf Max,',
320 'GPRINT:not_cached_avg:LAST:%5.2lf Last\l',
321 "LINE1:inserts_agg#$FullBlue:Inserts ",
322 'GPRINT:inserts_min:MIN:%5.2lf Min,',
323 'GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,',
324 'GPRINT:inserts_max:MAX:%5.2lf Max,',
325 'GPRINT:inserts_avg:LAST:%5.2lf Last\l',
326 "LINE1:hits_agg#$FullGreen:Hits ",
327 'GPRINT:hits_min:MIN:%5.2lf Min,',
328 'GPRINT:hits_avg:AVERAGE:%5.2lf Avg,',
329 'GPRINT:hits_max:MAX:%5.2lf Max,',
330 'GPRINT:hits_avg:LAST:%5.2lf Last\l',
331 "LINE1:lowmem_prunes_avg#$FullRed:Lowmem Prunes ",
332 'GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,',
333 'GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,',
334 'GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,',
335 'GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\l',
336 "LINE1:unknown#$Canvas:Queries in cache",
337 'GPRINT:queries_min:MIN:%5.0lf Min,',
338 'GPRINT:queries_avg:AVERAGE:%5.0lf Avg,',
339 'GPRINT:queries_max:MAX:%5.0lf Max,',
340 'GPRINT:queries_avg:LAST:%5.0lf Last\l'
343 "DEF:running_min={file}:running:MIN",
344 "DEF:running_avg={file}:running:AVERAGE",
345 "DEF:running_max={file}:running:MAX",
346 "DEF:connected_min={file}:connected:MIN",
347 "DEF:connected_avg={file}:connected:AVERAGE",
348 "DEF:connected_max={file}:connected:MAX",
349 "DEF:cached_min={file}:cached:MIN",
350 "DEF:cached_avg={file}:cached:AVERAGE",
351 "DEF:cached_max={file}:cached:MAX",
352 "DEF:created_min={file}:created:MIN",
353 "DEF:created_avg={file}:created:AVERAGE",
354 "DEF:created_max={file}:created:MAX",
355 "CDEF:unknown=created_avg,UNKN,+",
356 "CDEF:cached_agg=connected_avg,cached_avg,+",
357 "AREA:cached_agg#$HalfGreen",
358 "AREA:connected_avg#$HalfBlue",
359 "AREA:running_avg#$HalfRed",
360 "LINE1:cached_agg#$FullGreen:Cached ",
361 'GPRINT:cached_min:MIN:%5.1lf Min,',
362 'GPRINT:cached_avg:AVERAGE:%5.1lf Avg,',
363 'GPRINT:cached_max:MAX:%5.1lf Max,',
364 'GPRINT:cached_avg:LAST:%5.1lf Last\l',
365 "LINE1:connected_avg#$FullBlue:Connected",
366 'GPRINT:connected_min:MIN:%5.1lf Min,',
367 'GPRINT:connected_avg:AVERAGE:%5.1lf Avg,',
368 'GPRINT:connected_max:MAX:%5.1lf Max,',
369 'GPRINT:connected_avg:LAST:%5.1lf Last\l',
370 "LINE1:running_avg#$FullRed:Running ",
371 'GPRINT:running_min:MIN:%5.1lf Min,',
372 'GPRINT:running_avg:AVERAGE:%5.1lf Avg,',
373 'GPRINT:running_max:MAX:%5.1lf Max,',
374 'GPRINT:running_avg:LAST:%5.1lf Last\l',
375 "LINE1:unknown#$Canvas:Created ",
376 'GPRINT:created_min:MIN:%5.0lf Min,',
377 'GPRINT:created_avg:AVERAGE:%5.0lf Avg,',
378 'GPRINT:created_max:MAX:%5.0lf Max,',
379 'GPRINT:created_avg:LAST:%5.0lf Last\l'
382 "DEF:null_avg={file}:null:AVERAGE",
383 "DEF:getattr_avg={file}:getattr:AVERAGE",
384 "DEF:setattr_avg={file}:setattr:AVERAGE",
385 "DEF:lookup_avg={file}:lookup:AVERAGE",
386 "DEF:access_avg={file}:access:AVERAGE",
387 "DEF:readlink_avg={file}:readlink:AVERAGE",
388 "DEF:read_avg={file}:read:AVERAGE",
389 "DEF:write_avg={file}:write:AVERAGE",
390 "DEF:create_avg={file}:create:AVERAGE",
391 "DEF:mkdir_avg={file}:mkdir:AVERAGE",
392 "DEF:symlink_avg={file}:symlink:AVERAGE",
393 "DEF:mknod_avg={file}:mknod:AVERAGE",
394 "DEF:remove_avg={file}:remove:AVERAGE",
395 "DEF:rmdir_avg={file}:rmdir:AVERAGE",
396 "DEF:rename_avg={file}:rename:AVERAGE",
397 "DEF:link_avg={file}:link:AVERAGE",
398 "DEF:readdir_avg={file}:readdir:AVERAGE",
399 "DEF:readdirplus_avg={file}:readdirplus:AVERAGE",
400 "DEF:fsstat_avg={file}:fsstat:AVERAGE",
401 "DEF:fsinfo_avg={file}:fsinfo:AVERAGE",
402 "DEF:pathconf_avg={file}:pathconf:AVERAGE",
403 "DEF:commit_avg={file}:commit:AVERAGE",
404 "DEF:null_max={file}:null:MAX",
405 "DEF:getattr_max={file}:getattr:MAX",
406 "DEF:setattr_max={file}:setattr:MAX",
407 "DEF:lookup_max={file}:lookup:MAX",
408 "DEF:access_max={file}:access:MAX",
409 "DEF:readlink_max={file}:readlink:MAX",
410 "DEF:read_max={file}:read:MAX",
411 "DEF:write_max={file}:write:MAX",
412 "DEF:create_max={file}:create:MAX",
413 "DEF:mkdir_max={file}:mkdir:MAX",
414 "DEF:symlink_max={file}:symlink:MAX",
415 "DEF:mknod_max={file}:mknod:MAX",
416 "DEF:remove_max={file}:remove:MAX",
417 "DEF:rmdir_max={file}:rmdir:MAX",
418 "DEF:rename_max={file}:rename:MAX",
419 "DEF:link_max={file}:link:MAX",
420 "DEF:readdir_max={file}:readdir:MAX",
421 "DEF:readdirplus_max={file}:readdirplus:MAX",
422 "DEF:fsstat_max={file}:fsstat:MAX",
423 "DEF:fsinfo_max={file}:fsinfo:MAX",
424 "DEF:pathconf_max={file}:pathconf:MAX",
425 "DEF:commit_max={file}:commit:MAX",
426 "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,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
427 "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,+,+,+,+,+,+,+,+,+,+,+,+,+,+",
428 "CDEF:stack_read=read_avg",
429 "CDEF:stack_getattr=stack_read,getattr_avg,+",
430 "CDEF:stack_access=stack_getattr,access_avg,+",
431 "CDEF:stack_lookup=stack_access,lookup_avg,+",
432 "CDEF:stack_write=stack_lookup,write_avg,+",
433 "CDEF:stack_commit=stack_write,commit_avg,+",
434 "CDEF:stack_setattr=stack_commit,setattr_avg,+",
435 "CDEF:stack_other=stack_setattr,other_avg,+",
436 "AREA:stack_other#$HalfRed",
437 "AREA:stack_setattr#$HalfGreen",
438 "AREA:stack_commit#$HalfYellow",
439 "AREA:stack_write#$HalfGreen",
440 "AREA:stack_lookup#$HalfBlue",
441 "AREA:stack_access#$HalfMagenta",
442 "AREA:stack_getattr#$HalfCyan",
443 "AREA:stack_read#$HalfBlue",
444 "LINE1:stack_other#$FullRed:Other ",
445 'GPRINT:other_max:MAX:%5.1lf Max,',
446 'GPRINT:other_avg:AVERAGE:%5.1lf Avg,',
447 'GPRINT:other_avg:LAST:%5.1lf Last\l',
448 "LINE1:stack_setattr#$FullGreen:setattr",
449 'GPRINT:setattr_max:MAX:%5.1lf Max,',
450 'GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,',
451 'GPRINT:setattr_avg:LAST:%5.1lf Last\l',
452 "LINE1:stack_commit#$FullYellow:commit ",
453 'GPRINT:commit_max:MAX:%5.1lf Max,',
454 'GPRINT:commit_avg:AVERAGE:%5.1lf Avg,',
455 'GPRINT:commit_avg:LAST:%5.1lf Last\l',
456 "LINE1:stack_write#$FullGreen:write ",
457 'GPRINT:write_max:MAX:%5.1lf Max,',
458 'GPRINT:write_avg:AVERAGE:%5.1lf Avg,',
459 'GPRINT:write_avg:LAST:%5.1lf Last\l',
460 "LINE1:stack_lookup#$FullBlue:lookup ",
461 'GPRINT:lookup_max:MAX:%5.1lf Max,',
462 'GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,',
463 'GPRINT:lookup_avg:LAST:%5.1lf Last\l',
464 "LINE1:stack_access#$FullMagenta:access ",
465 'GPRINT:access_max:MAX:%5.1lf Max,',
466 'GPRINT:access_avg:AVERAGE:%5.1lf Avg,',
467 'GPRINT:access_avg:LAST:%5.1lf Last\l',
468 "LINE1:stack_getattr#$FullCyan:getattr",
469 'GPRINT:getattr_max:MAX:%5.1lf Max,',
470 'GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,',
471 'GPRINT:getattr_avg:LAST:%5.1lf Last\l',
472 "LINE1:stack_read#$FullBlue:read ",
473 'GPRINT:read_max:MAX:%5.1lf Max,',
474 'GPRINT:read_avg:AVERAGE:%5.1lf Avg,',
475 'GPRINT:read_avg:LAST:%5.1lf Last\l'
478 "DEF:rbyte_avg={file}:rbytes:AVERAGE",
479 "DEF:rbyte_min={file}:rbytes:MIN",
480 "DEF:rbyte_max={file}:rbytes:MAX",
481 "DEF:wbyte_avg={file}:wbytes:AVERAGE",
482 "DEF:wbyte_min={file}:wbytes:MIN",
483 "DEF:wbyte_max={file}:wbytes:MAX",
484 'CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF',
485 "AREA:wbyte_avg#$HalfGreen",
486 "AREA:rbyte_avg#$HalfBlue",
487 "AREA:overlap#$HalfBlueGreen",
488 "LINE1:wbyte_avg#$FullGreen:Write",
489 'GPRINT:wbyte_min:MIN:%5.1lf%s Min,',
490 'GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,',
491 'GPRINT:wbyte_max:MAX:%5.1lf%s Max,',
492 'GPRINT:wbyte_avg:LAST:%5.1lf%s Last\l',
493 "LINE1:rbyte_avg#$FullBlue:Read ",
494 'GPRINT:rbyte_min:MIN:%5.1lf%s Min,',
495 'GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,',
496 'GPRINT:rbyte_max:MAX:%5.1lf%s Max,',
497 'GPRINT:rbyte_avg:LAST:%5.1lf%s Last\l'
499 ping => ['DEF:ping_avg={file}:ping:AVERAGE',
500 'DEF:ping_min={file}:ping:MIN',
501 'DEF:ping_max={file}:ping:MAX',
502 "AREA:ping_max#$HalfBlue",
503 "AREA:ping_min#$Canvas",
504 "LINE1:ping_avg#$FullBlue:Ping",
505 'GPRINT:ping_min:MIN:%4.1lf ms Min,',
506 'GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,',
507 'GPRINT:ping_max:MAX:%4.1lf ms Max,',
508 'GPRINT:ping_avg:LAST:%4.1lf ms Last'],
510 "DEF:running_avg={file}:running:AVERAGE",
511 "DEF:running_min={file}:running:MIN",
512 "DEF:running_max={file}:running:MAX",
513 "DEF:sleeping_avg={file}:sleeping:AVERAGE",
514 "DEF:sleeping_min={file}:sleeping:MIN",
515 "DEF:sleeping_max={file}:sleeping:MAX",
516 "DEF:zombies_avg={file}:zombies:AVERAGE",
517 "DEF:zombies_min={file}:zombies:MIN",
518 "DEF:zombies_max={file}:zombies:MAX",
519 "DEF:stopped_avg={file}:stopped:AVERAGE",
520 "DEF:stopped_min={file}:stopped:MIN",
521 "DEF:stopped_max={file}:stopped:MAX",
522 "DEF:paging_avg={file}:paging:AVERAGE",
523 "DEF:paging_min={file}:paging:MIN",
524 "DEF:paging_max={file}:paging:MAX",
525 "DEF:blocked_avg={file}:blocked:AVERAGE",
526 "DEF:blocked_min={file}:blocked:MIN",
527 "DEF:blocked_max={file}:blocked:MAX",
528 'CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+',
529 'CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+',
530 'CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+',
531 'CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+',
532 'CDEF:running_acc=sleeping_avg,running_avg,+',
533 'CDEF:sleeping_acc=sleeping_avg',
534 "AREA:paging_acc#$HalfYellow",
535 "AREA:blocked_acc#$HalfCyan",
536 "AREA:zombies_acc#$HalfRed",
537 "AREA:stopped_acc#$HalfMagenta",
538 "AREA:running_acc#$HalfGreen",
539 "AREA:sleeping_acc#$HalfBlue",
540 "LINE1:paging_acc#$FullYellow:Paging ",
541 'GPRINT:paging_min:MIN:%5.1lf Min,',
542 'GPRINT:paging_avg:AVERAGE:%5.1lf Average,',
543 'GPRINT:paging_max:MAX:%5.1lf Max,',
544 'GPRINT:paging_avg:LAST:%5.1lf Last\l',
545 "LINE1:blocked_acc#$FullCyan:Blocked ",
546 'GPRINT:blocked_min:MIN:%5.1lf Min,',
547 'GPRINT:blocked_avg:AVERAGE:%5.1lf Average,',
548 'GPRINT:blocked_max:MAX:%5.1lf Max,',
549 'GPRINT:blocked_avg:LAST:%5.1lf Last\l',
550 "LINE1:zombies_acc#$FullRed:Zombies ",
551 'GPRINT:zombies_min:MIN:%5.1lf Min,',
552 'GPRINT:zombies_avg:AVERAGE:%5.1lf Average,',
553 'GPRINT:zombies_max:MAX:%5.1lf Max,',
554 'GPRINT:zombies_avg:LAST:%5.1lf Last\l',
555 "LINE1:stopped_acc#$FullMagenta:Stopped ",
556 'GPRINT:stopped_min:MIN:%5.1lf Min,',
557 'GPRINT:stopped_avg:AVERAGE:%5.1lf Average,',
558 'GPRINT:stopped_max:MAX:%5.1lf Max,',
559 'GPRINT:stopped_avg:LAST:%5.1lf Last\l',
560 "LINE1:running_acc#$FullGreen:Running ",
561 'GPRINT:running_min:MIN:%5.1lf Min,',
562 'GPRINT:running_avg:AVERAGE:%5.1lf Average,',
563 'GPRINT:running_max:MAX:%5.1lf Max,',
564 'GPRINT:running_avg:LAST:%5.1lf Last\l',
565 "LINE1:sleeping_acc#$FullBlue:Sleeping",
566 'GPRINT:sleeping_min:MIN:%5.1lf Min,',
567 'GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,',
568 'GPRINT:sleeping_max:MAX:%5.1lf Max,',
569 'GPRINT:sleeping_avg:LAST:%5.1lf Last\l'
572 'DEF:temp_avg={file}:value:AVERAGE',
573 'DEF:temp_min={file}:value:MIN',
574 'DEF:temp_max={file}:value:MAX',
575 "AREA:temp_max#$HalfBlue",
576 "AREA:temp_min#$Canvas",
577 "LINE1:temp_avg#$FullBlue:Value",
578 'GPRINT:temp_min:MIN:%4.1lf Min,',
579 'GPRINT:temp_avg:AVERAGE:%4.1lf Avg,',
580 'GPRINT:temp_max:MAX:%4.1lf Max,',
581 'GPRINT:temp_avg:LAST:%4.1lf Last\l'
584 'DEF:used_avg={file}:used:AVERAGE',
585 'DEF:used_min={file}:used:MIN',
586 'DEF:used_max={file}:used:MAX',
587 'DEF:free_avg={file}:free:AVERAGE',
588 'DEF:free_min={file}:free:MIN',
589 'DEF:free_max={file}:free:MAX',
590 'DEF:cach_avg={file}:cached:AVERAGE',
591 'DEF:cach_min={file}:cached:MIN',
592 'DEF:cach_max={file}:cached:MAX',
593 'DEF:resv_avg={file}:resv:AVERAGE',
594 'DEF:resv_min={file}:resv:MIN',
595 'DEF:resv_max={file}:resv:MAX',
596 'CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF',
597 'CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF',
598 'CDEF:used_acc=used_avg',
599 'CDEF:resv_acc=used_acc,resv_avg_notnull,+',
600 'CDEF:cach_acc=resv_acc,cach_avg_notnull,+',
601 'CDEF:free_acc=cach_acc,free_avg,+',
602 "AREA:free_acc#$HalfGreen",
603 "AREA:cach_acc#$HalfBlue",
604 "AREA:resv_acc#$HalfYellow",
605 "AREA:used_acc#$HalfRed",
606 "LINE1:free_acc#$FullGreen:Free ",
607 'GPRINT:free_min:MIN:%5.1lf%s Min,',
608 'GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,',
609 'GPRINT:free_max:MAX:%5.1lf%s Max,',
610 'GPRINT:free_avg:LAST:%5.1lf%s Last\n',
611 "LINE1:cach_acc#$FullBlue:Cached ",
612 'GPRINT:cach_min:MIN:%5.1lf%s Min,',
613 'GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,',
614 'GPRINT:cach_max:MAX:%5.1lf%s Max,',
615 'GPRINT:cach_avg:LAST:%5.1lf%s Last\l',
616 "LINE1:resv_acc#$FullYellow:Reserved",
617 'GPRINT:resv_min:MIN:%5.1lf%s Min,',
618 'GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,',
619 'GPRINT:resv_max:MAX:%5.1lf%s Max,',
620 'GPRINT:resv_avg:LAST:%5.1lf%s Last\n',
621 "LINE1:used_acc#$FullRed:Used ",
622 'GPRINT:used_min:MIN:%5.1lf%s Min,',
623 'GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,',
624 'GPRINT:used_max:MAX:%5.1lf%s Max,',
625 'GPRINT:used_avg:LAST:%5.1lf%s Last\l'
627 traffic => ['DEF:out_min_raw={file}:outgoing:MIN',
628 'DEF:out_avg_raw={file}:outgoing:AVERAGE',
629 'DEF:out_max_raw={file}:outgoing:MAX',
630 'DEF:inc_min_raw={file}:incoming:MIN',
631 'DEF:inc_avg_raw={file}:incoming:AVERAGE',
632 'DEF:inc_max_raw={file}:incoming:MAX',
633 'CDEF:out_min=out_min_raw,8,*',
634 'CDEF:out_avg=out_avg_raw,8,*',
635 'CDEF:out_max=out_max_raw,8,*',
636 'CDEF:inc_min=inc_min_raw,8,*',
637 'CDEF:inc_avg=inc_avg_raw,8,*',
638 'CDEF:inc_max=inc_max_raw,8,*',
639 'CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF',
640 'CDEF:mytime=out_avg_raw,TIME,TIME,IF',
641 'CDEF:sample_len_raw=mytime,PREV(mytime),-',
642 'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
643 'CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*',
644 'CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+',
645 'CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*',
646 'CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+',
647 "AREA:out_avg#$HalfGreen",
648 "AREA:inc_avg#$HalfBlue",
649 "AREA:overlap#$HalfBlueGreen",
650 "LINE1:out_avg#$FullGreen:Outgoing",
651 'GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,',
652 'GPRINT:out_max:MAX:%5.1lf%s Max,',
653 'GPRINT:out_avg:LAST:%5.1lf%s Last',
654 'GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\l',
655 "LINE1:inc_avg#$FullBlue:Incoming",
656 #'GPRINT:inc_min:MIN:%5.1lf %s Min,',
657 'GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,',
658 'GPRINT:inc_max:MAX:%5.1lf%s Max,',
659 'GPRINT:inc_avg:LAST:%5.1lf%s Last',
660 'GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
663 'DEF:cpufreq_avg={file}:value:AVERAGE',
664 'DEF:cpufreq_min={file}:value:MIN',
665 'DEF:cpufreq_max={file}:value:MAX',
666 "AREA:cpufreq_max#$HalfBlue",
667 "AREA:cpufreq_min#$Canvas",
668 "LINE1:cpufreq_avg#$FullBlue:Frequency",
669 'GPRINT:cpufreq_min:MIN:%5.1lf%s Min,',
670 'GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,',
671 'GPRINT:cpufreq_max:MAX:%5.1lf%s Max,',
672 'GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\l'
675 'DEF:users_avg={file}:users:AVERAGE',
676 'DEF:users_min={file}:users:MIN',
677 'DEF:users_max={file}:users:MAX',
678 "AREA:users_max#$HalfBlue",
679 "AREA:users_min#$Canvas",
680 "LINE1:users_avg#$FullBlue:Users",
681 'GPRINT:users_min:MIN:%4.1lf Min,',
682 'GPRINT:users_avg:AVERAGE:%4.1lf Average,',
683 'GPRINT:users_max:MAX:%4.1lf Max,',
684 'GPRINT:users_avg:LAST:%4.1lf Last\l'
687 $GraphDefs->{'disk'} = $GraphDefs->{'partition'};
688 $GraphDefs->{'meminfo'} = $GraphDefs->{'memory'};
693 cpu => ['-t', '{host} cpu{inst} usage', '-v', 'Percent', '-l', '0'],
694 cpufreq => ['-t', '{host} cpu{inst} usage', '-v', 'Mhz'],
695 #disk => ['-t', '{host} disk {inst} IO wait', '-v', 'Seconds'],
696 df => ['-t', '{host}:{inst} usage', '-v', 'Percent', '-l', '0'],
697 disk => ['-t', '{host} disk {inst} usage', '-v', 'Byte/s'],
698 hddtemp => ['-t', '{host} hdd temperature {inst}', '-v', '°Celsius'],
699 load => ['-t', '{host} load average', '-v', 'System load', '-X', '0'],
700 mails => ['-t', '{host} mail count', '-v', 'Amount', '-X', '0'],
701 memory => ['-t', '{host} memory usage', '-v', 'Bytes', '-b', '1024', '-l', '0'],
702 mysql_commands => ['-t', 'mysql command {inst}', '-v', 'Issues/s' ],
703 mysql_handler => ['-t', 'mysql handler {inst}', '-v', 'Issues/s' ],
704 mysql_qcache => ['-t', 'mysql query cache', '-v', 'Queries/s' ],
705 mysql_threads => ['-t', 'mysql threads', '-v', 'Threads' ],
706 nfs3_procedures => ['-t', '{host} NFSv3 {inst} procedures', '-v', 'Procedures/s' ],
707 partition => ['-t', '{host} partition {inst} usage', '-v', 'Byte/s'],
708 ping => ['-t', '{host} ping to {inst}', '-v', 'ms'],
709 processes => ['-t', '{host} processes', '-v', 'Processes'],
710 sensors => ['-t', '{host} sensor {inst}', '-v', '°Celsius'],
711 swap => ['-t', '{host} swap usage', '-v', 'Bytes', '-b', '1024', '-l', '0'],
712 traffic => ['-t', '{host} {inst} traffic', '-v', 'Bit/s'],
713 users => ['-t', '{host} users', '-v', 'Users'],
718 cpu => \&output_graph_cpu,
724 mysql_commands => \&output_graph_mysql_commands,
725 mysql_handler => \&output_graph_mysql_handler,
727 ping => \&output_graph_ping,
734 if (defined ($ENV{'GATEWAY_INTERFACE'}))
736 @Info = ($ENV{'PATH_INFO'} || '') =~ m#([\w\-\.]+)#g;
743 parse_pathinfo (@Info);
766 "DEF:user_avg_$_=$AbsDir/cpu-$_.rrd:user:AVERAGE",
767 "DEF:user_min_$_=$AbsDir/cpu-$_.rrd:user:MIN",
768 "DEF:user_max_$_=$AbsDir/cpu-$_.rrd:user:MAX",
769 "DEF:nice_avg_$_=$AbsDir/cpu-$_.rrd:nice:AVERAGE",
770 "DEF:nice_min_$_=$AbsDir/cpu-$_.rrd:nice:MIN",
771 "DEF:nice_max_$_=$AbsDir/cpu-$_.rrd:nice:MAX",
772 "DEF:syst_avg_$_=$AbsDir/cpu-$_.rrd:syst:AVERAGE",
773 "DEF:syst_min_$_=$AbsDir/cpu-$_.rrd:syst:MIN",
774 "DEF:syst_max_$_=$AbsDir/cpu-$_.rrd:syst:MAX",
775 "DEF:wait_avg_$_=$AbsDir/cpu-$_.rrd:wait:AVERAGE",
776 "DEF:wait_min_$_=$AbsDir/cpu-$_.rrd:wait:MIN",
777 "DEF:wait_max_$_=$AbsDir/cpu-$_.rrd:wait:MAX");
780 for (qw(user nice syst wait))
785 my $default_value = ($def eq 'user' or $def eq 'syst') ? 'UNKN' : '0';
787 for (qw(avg min max))
793 push (@ret, "CDEF:${def}_${cf}_notnull_${_}=${def}_${cf}_${_},UN,0,${def}_${cf}_${_},IF");
794 push (@ret, "CDEF:${def}_${cf}_defined_${_}=${def}_${cf}_${_},UN,0,1,IF");
797 $cdef = "CDEF:${def}_${cf}_num=" . join (',', map { "${def}_${cf}_defined_${_}" } (@inst));
798 $cdef .= ',+' x (scalar (@inst) - 1);
801 $cdef = "CDEF:${def}_${cf}=${def}_${cf}_num," . join (',', map { "${def}_${cf}_notnull_${_}" } (@inst));
802 $cdef .= ',+' x (scalar (@inst) - 1);
803 $cdef .= ",${def}_${cf}_num,${def}_${cf}_num,1,IF,/,$default_value,IF";
805 push (@ret, "CDEF:${def}_${cf}_notnull=${def}_${cf},UN,0,${def}_${cf},IF");
810 "CDEF:nice_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,nice_avg_notnull,+,+,+",
811 "CDEF:user_acc=syst_avg_notnull,wait_avg_notnull,user_avg_notnull,+,+",
812 "CDEF:wait_acc=syst_avg_notnull,wait_avg_notnull,+",
813 "CDEF:syst_acc=syst_avg_notnull");
815 push (@ret, grep { $_ !~ m/^C?DEF/ } (@{$GraphDefs->{'cpu'}}));
820 sub output_graph_ping
827 my @colors = get_n_colors (scalar (@inst));
829 for (my $i = 0; $i < scalar (@inst); $i++)
831 my $inst = $inst[$i];
833 "DEF:avg_$i=$AbsDir/ping-$inst.rrd:ping:AVERAGE",
834 "DEF:min_$i=$AbsDir/ping-$inst.rrd:ping:MIN",
835 "DEF:max_$i=$AbsDir/ping-$inst.rrd:ping:MAX");
838 for (my $i = 0; $i < scalar (@inst); $i++)
840 my $inst = $inst[$i];
841 my $color = $colors[$i];
843 if (length ($inst) > 15)
845 $inst = substr ($inst, 0, 12) . '...';
849 $inst = sprintf ('%-15s', $inst);
853 "LINE1:avg_$i#$color:$inst",
854 "GPRINT:min_$i:MIN:%4.1lf ms Min,",
855 "GPRINT:avg_$i:AVERAGE:%4.1lf ms Avg,",
856 "GPRINT:max_$i:MAX:%4.1lf ms Max,",
857 "GPRINT:avg_$i:LAST:%4.1lf ms Last\\l");
863 sub output_graph_mysql_commands
870 my @colors = get_n_colors (scalar (@inst));
872 for (my $i = 0; $i < scalar (@inst); $i++)
874 my $inst = $inst[$i];
876 "DEF:avg_$i=$AbsDir/mysql_commands-$inst.rrd:value:AVERAGE",
877 "DEF:min_$i=$AbsDir/mysql_commands-$inst.rrd:value:MIN",
878 "DEF:max_$i=$AbsDir/mysql_commands-$inst.rrd:value:MAX");
881 for (my $i = 0; $i < scalar (@inst); $i++)
883 my $inst = $inst[$i];
884 my $color = $colors[$i];
886 if (length ($inst) > 18)
888 $inst = substr ($inst, 0, 15) . '...';
892 $inst = sprintf ('%-18s', $inst);
896 "LINE1:avg_$i#$color:$inst",
897 "GPRINT:min_$i:MIN:%6.1lf Min,",
898 "GPRINT:avg_$i:AVERAGE:%6.1lf Avg,",
899 "GPRINT:max_$i:MAX:%6.1lf Max,",
900 "GPRINT:avg_$i:LAST:%6.1lf Last\\l");
906 sub output_graph_mysql_handler
913 my @colors = get_n_colors (scalar (@inst));
915 for (my $i = 0; $i < scalar (@inst); $i++)
917 my $inst = $inst[$i];
919 "DEF:avg_$i=$AbsDir/mysql_handler-$inst.rrd:value:AVERAGE",
920 "DEF:min_$i=$AbsDir/mysql_handler-$inst.rrd:value:MIN",
921 "DEF:max_$i=$AbsDir/mysql_handler-$inst.rrd:value:MAX");
924 for (my $i = 0; $i < scalar (@inst); $i++)
926 my $inst = $inst[$i];
927 my $color = $colors[$i];
929 if (length ($inst) > 18)
931 $inst = substr ($inst, 0, 15) . '...';
935 $inst = sprintf ('%-18s', $inst);
939 "LINE1:avg_$i#$color:$inst",
940 "GPRINT:min_$i:MIN:%6.1lf Min,",
941 "GPRINT:avg_$i:AVERAGE:%6.1lf Avg,",
942 "GPRINT:max_$i:MAX:%6.1lf Max,",
943 "GPRINT:avg_$i:LAST:%6.1lf Last\\l");
951 die unless (defined ($GraphDefs->{$Type}));
955 my $file = $AbsDir . '/';
956 my $files = get_all_files ($AbsDir);
961 if ($RelDir =~ m#([^/]+)$#)
967 $host = $Config->{'HostName'};
973 if ($TimeSpan =~ m/(\d+)/)
975 $TimeSpan = -1 * int ($1);
979 my %t = (hour => -3600, day => -86400, week => -604800, month => -2678400, year => -31622400);
980 die unless (defined ($t{$TimeSpan}));
981 $TimeSpan = $t{$TimeSpan};
984 if (scalar (@{$files->{$Type}}) == 1)
986 $Inst = $files->{$Type}[0];
989 push (@cmd, '-', '-a', 'PNG', '-s', $TimeSpan);
990 push (@cmd, @{$GraphArgs->{$Type}}) if (defined ($GraphArgs->{$Type}));
992 for (qw(Back ShadeA ShadeB Font Canvas Grid MGrid Frame Arrow))
994 push (@cmd, '-c', uc ($_) . '#' . $Config->{'Colors'}{$_});
997 if ((length ($Inst) == 0) and (ref ($GraphMulti->{$Type}) eq 'CODE'))
999 push (@cmd, $GraphMulti->{$Type}->(@{$files->{$Type}}));
1003 if (length ("$Inst"))
1005 $file .= "$Type-$Inst.rrd";
1009 $file .= "$Type.rrd";
1012 die ("File not found: $file") unless (-e $file);
1014 push (@cmd, @{$GraphDefs->{$Type}});
1019 $_ =~ s/{file}/$file/g;
1020 $_ =~ s/{host}/$host/g;
1021 $_ =~ s/{inst}/$Inst/g;
1022 $_ =~ s/{type}/$Type/g;
1027 print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1028 Content-Type: image/png
1029 Cache-Control: no-cache
1036 open ($fh, ">/tmp/collection.log") or die ("open: $!");
1037 flock ($fh, LOCK_EX) or die ("flock: $!");
1039 print $fh join ("\n\t", @cmd) . "\n";
1046 die ('RRDs::error: ' . RRDs::error ()) if (RRDs::error ());
1051 my $files = get_all_files ($AbsDir);
1052 my $dirs = get_all_dirs ($AbsDir);
1054 print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1055 Content-Type: text/html
1056 Cache-Control: no-cache
1060 <title>Collection: $RelDir</title>
1061 <style type="text/css">
1062 img { border: none; display: block; }
1069 my $MySelf = defined ($ENV{'GATEWAY_INTERFACE'}) ? $ENV{'SCRIPT_NAME'} : $0;
1071 if ((length ($Type) != 0) and (length ($Inst) == 0) and (ref ($GraphMulti->{$Type}) eq 'CODE') and (scalar (@{$files->{$Type}}) > 1))
1073 print qq(\t\t<div><a href="$MySelf$RelDir">Go up</a></div>\n);
1076 for (@{$files->{$Type}})
1078 print qq(\t\t\t<li><a href="$MySelf$RelDir/$Type/$_">$_</a></li>\n);
1084 <div><img src="$MySelf$RelDir/$Type/day" /></div>
1086 <div><img src="$MySelf$RelDir/$Type/week" /></div>
1088 <div><img src="$MySelf$RelDir/$Type/month" /></div>
1090 <div><img src="$MySelf$RelDir/$Type/year" /></div>
1093 elsif (length ($Type) != 0)
1095 my $ext = length ($Inst) ? "$Type/$Inst" : $Type;
1097 if ((ref ($GraphMulti->{$Type}) eq 'CODE') and (scalar (@{$files->{$Type}}) > 1))
1099 print qq(<div><a href="$MySelf$RelDir/$Type">Go up</a></div>\n);
1103 print qq(<div><a href="$MySelf$RelDir">Go up</a></div>\n);
1108 <div><img src="$MySelf$RelDir/$ext/day" /></div>
1110 <div><img src="$MySelf$RelDir/$ext/week" /></div>
1112 <div><img src="$MySelf$RelDir/$ext/month" /></div>
1114 <div><img src="$MySelf$RelDir/$ext/year" /></div>
1121 my ($up) = $RelDir =~ m#(.*)/[^/]+$#;
1122 print qq(\t\t<div><a href="$MySelf$up">Go up</a></div>\n);
1130 print qq(<li>$AbsDir/<a href="$MySelf$RelDir/$_">$_</a></li>\n);
1135 for (sort (keys %$files))
1139 if (ref ($GraphMulti->{$type}) eq 'CODE')
1141 print qq(\t\t<a href="$MySelf$RelDir/$type" />),
1142 qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
1146 for (@{$files->{$type}})
1152 print qq(\t\t<a href="$MySelf$RelDir/$type/$inst" />),
1153 qq(<img src="$MySelf$RelDir/$type/$inst/day" /></a>\n);
1157 print qq(\t\t<a href="$MySelf$RelDir/$type" />),
1158 qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
1164 print STDOUT <<FOOTER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1172 my $files = get_all_files ();
1174 print STDOUT <<HEADER if (defined ($ENV{'GATEWAY_INTERFACE'}));
1175 Content-Type: text/xml
1176 Cache-Control: no-cache
1179 print STDOUT pl2xml ($files);
1184 my $file = @_ ? shift : '/etc/collection.conf';
1188 # if (open ($fh, "< $file"))
1196 # $conf = xml2pl ($xml);
1216 FullRed => 'FF0000',
1217 FullBlue => '0000FF',
1218 FullGreen => '00E000',
1219 FullYellow => 'F0A000',
1220 FullCyan => '00A0FF',
1221 FullMagenta => 'A000FF',
1223 HalfRed => 'F8B8B8',
1224 HalfBlue => 'B8B8F8',
1225 HalfGreen => 'B8F0B8',
1226 HalfYellow => 'F4F4B8'
1228 Directory => '/var/lib/collectd',
1229 HostName => (defined ($ENV{'SERVER_NAME'}) ? $ENV{'SERVER_NAME'} : 'localhost')
1242 $AbsDir = $Config->{'Directory'};
1245 while (@info and -d $AbsDir . '/' . $Info[0])
1247 my $new = shift (@info);
1248 next if ($new =~ m/^\./);
1250 $AbsDir .= '/' . $new;
1251 $RelDir .= '/' . $new;
1258 confess ("parse_pathinfo: too many elements in pathinfo") if (scalar (@info) > 3);
1259 return unless (@info);
1261 $Type = shift (@info);
1262 return unless (@info);
1264 if ($info[-1] =~ m/^(hour|day|week|month|year)$/i)
1266 $TimeSpan = pop (@info);
1269 $Inst = shift (@info) if (@info);
1271 confess ("unrecognized elements in pathinfo") if (@info);
1276 my $dir = @_ ? shift : $Config->{'Directory'};
1280 if (opendir ($dh, $dir))
1282 while (my $thing = readdir ($dh))
1284 next if ($thing =~ m/^\./);
1289 if ($thing =~ m/^(\w+)-([\w\-\.]+)\.rrd$/)
1294 elsif ($thing =~ m/^(\w+)\.rrd$/)
1304 # Only load RRD files we can actually display..
1305 next unless (defined ($GraphDefs->{$type}));
1307 $hash->{$type} = [] unless (defined ($hash->{$type}));
1308 push (@{$hash->{$type}}, $inst);
1319 my $dir = @_ ? shift : $Config->{'Directory'};
1323 if (opendir ($dh, $dir))
1325 while (my $thing = readdir ($dh))
1327 next if ($thing =~ m/^\./);
1329 next if (!-d "$dir/$thing");
1331 push (@ret, $thing);
1337 return (@ret) if (wantarray ());
1345 my ($red, $green, $blue) = map { ord (pack ("H2", $_)) } ($color =~ m/([A-Fa-f0-9]{2})/g);
1346 #print STDERR "$color -> rgb($red,$green,$blue)\n";
1348 return ($red, $green, $blue);
1353 croak unless (scalar (@_) == 3);
1355 my ($red, $green, $blue) = @_;
1357 my $ret = sprintf ("%02X%02X%02X", $red, $green, $blue);
1358 #print STDERR "rgb($red,$green,$blue) -> $ret\n";
1363 sub color_calculate_transparent
1366 my $canvas = [color_hex2rgb (shift)];
1367 my @colors = map { [color_hex2rgb ($_)] } (@_);
1369 if (($alpha < 0.0) or ($alpha > 1.0))
1376 return (color_rgb2hex (@$canvas));
1380 return (color_rgb2hex (@{$colors[-1]}));
1383 my $ret = _color_calculate_transparent ($alpha, $canvas, @colors);
1385 return (color_rgb2hex (@$ret));
1388 sub _color_calculate_transparent
1393 my @colors = @_ ? shift : ();
1394 my $ret = [0, 0, 0];
1396 for (my $i = 0; $i < 3; $i++)
1398 $ret->[$i] = ($alpha * $color->[$i]) + ((1 - $alpha) * $canvas->[$i]);
1401 return (_color_calculate_transparent ($alpha, $ret, @colors)) if (@colors);
1410 for (my $i = 0; $i < $num; $i++)
1412 my $pos = 6 * $i / $num;
1453 push (@ret, sprintf ("%02x%02x%02x", $red, $green, $blue));