jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [system/] [diagrams.pl] - Blame information for rev 20

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2 
3# $Id: diagrams.pl,v 1.33 2004/09/19 10:07:58 bernisys Exp $
4 
5# include PERL libraries
6use strict;
7use warnings;
8use diagnostics;
9 
10# include HotSaNIC libraries
11use lib "../../lib";
12use lib "./platform";
13use HotSaNICparser;
14use HotSaNICdiagram;
15use common;
16 
17(my $VERSION = '$Revision: 1.33 $') =~ s/.*(\d+\.\d+).*/$1/;
18(my $IDENTIFIER = '$Id: diagrams.pl,v 1.33 2004/09/19 10:07:58 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;
19 
20# read all settings
21#
22my $MODNAME=HotSaNICparser::get_module_name();
23my %CONFIG=HotSaNICparser::get_config("../..");
24my %MODULECONFIG=HotSaNICmod::common::configure();
25 
26my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"};
27 
28my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME;
29if ( ! -e $OUTDIR ) { mkdir "$OUTDIR",0755; }
30 
31my ($FORCE,$DEBUGLEVEL,%PLOT)=HotSaNICdiagram::check_args(@ARGV);
32 
33my ($name,$range,$descr);
34 
35my @OPTIONS=();
36 
37foreach my $section (split /\s+/,uc $MODULECONFIG{SECTIONS}) {
38 
39 if (%PLOT) { next if ! defined $PLOT{lc $section}; }
40 
41 $MODULECONFIG{GRAPH_MIN}=$MODULECONFIG{"GRAPH_MIN.$section"} || 0;
42 $MODULECONFIG{GRAPH_MAX}=$MODULECONFIG{"GRAPH_MAX.$section"} || 10;
43 $MODULECONFIG{GRAPH_MIN_LOG}=$MODULECONFIG{"GRAPH_MIN_LOG.$section"} || 0.01;
44 $MODULECONFIG{GRAPH_RIGID}=$MODULECONFIG{"GRAPH_RIGID.$section"} || 0;
45 $MODULECONFIG{GRAPH_STYLE}=$MODULECONFIG{"GRAPH_STYLE.$section"} || "lin";
46 $MODULECONFIG{GRAPH_UNIT}=$MODULECONFIG{"GRAPH_UNIT.$section"} || 1000;
47 $MODULECONFIG{GRAPH_BASE}=$MODULECONFIG{"GRAPH_BASE.$section"} || "";
48 
49 @OPTIONS=HotSaNICdiagram::get_common_options(%MODULECONFIG,%CONFIG);
50 push @OPTIONS,"--alt-autoscale-max"; # alternate scaling
51 
52 if ($section eq "LOAD") { plot_load(); }
53 if ($section eq "PROC") { plot_proc(); }
54 if ($section eq "CPU") { plot_cpu(); }
55 if ($section eq "MEM") { plot_mem(); }
56 if ($section eq "SWAP") { plot_swap(); }
57 if ($section eq "USERS") { plot_user(); }
58 if ($section eq "IRQ") { plot_irq(); }
59 if ($section eq "UPTIME") { plot_uptime(); }
60 }
61 
62exit 0;
63 
64 
65sub plot_load {
66 
67 print "creating images for loadavg...\n";
68 
69 opendir(DIR,"./rrd");
70 my @files=readdir(DIR);
71 closedir(DIR);
72 my @results=grep /load.*\.rrd/,@files;
73 foreach (@results) { s/\.rrd//g; }
74 
75 # if database exists, create images...
76 if (@results) {
77 my $LEGEND="load";
78 foreach my $dev (@results) {
79 my $DB_FILE="./rrd/$dev.rrd";
80 print " $dev:\n";
81 foreach $range ("1h","6h","1day","1week","1month","1year") {
82 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
83 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "--title", "system-load - last $descr ($DATESTRING)");
84 my @COMMANDS=();
85 
86 if ($range eq "1h") {
87 @COMMANDS=(
88 "DEF:ld1=$DB_FILE:load1:AVERAGE",
89 "DEF:ld2=$DB_FILE:load5:AVERAGE",
90 "DEF:ld3=$DB_FILE:load15:AVERAGE",
91 HotSaNICdiagram::insert_data("AREA","ld1",$MODULECONFIG{COLOR_LOAD_1}," 1 min avg","min max cur"),
92 HotSaNICdiagram::insert_data("LINE2","ld2",$MODULECONFIG{COLOR_LOAD_5}," 5 min avg","min max"),
93 HotSaNICdiagram::insert_data("LINE2","ld3",$MODULECONFIG{COLOR_LOAD_15},"15 min avg","min max"),
94 HotSaNICdiagram::insert_lines(%MODULECONFIG));
95 }
96 else {
97 @COMMANDS=(
98 HotSaNICdiagram::insert_vars($DB_FILE,"load1","load","MIN AVERAGE MAX"),
99 "DEF:avg5=$DB_FILE:load5:AVERAGE",
100 "DEF:avg15=$DB_FILE:load15:AVERAGE",
101 HotSaNICdiagram::insert_minmax("load_min load_max",$MODULECONFIG{COLOR_LOAD_AREA_MINMAX},$MODULECONFIG{COLOR_LOAD_BORDER},"min/max","",0),
102 "LINE1:load_avg#".$MODULECONFIG{COLOR_LOAD_1}.":avg (1 min)",
103 "LINE1:avg5#".$MODULECONFIG{COLOR_LOAD_5}.":avg (5 min)",
104 "LINE1:avg15#".$MODULECONFIG{COLOR_LOAD_15}.":avg (15 min)",
105 HotSaNICdiagram::insert_lines(%MODULECONFIG));
106 }
107 
108 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
109 HotSaNICdiagram::graph(%CONF);
110 
111 }
112 }
113 }
114 else { print " No database found\n Please check if the daemon is running.\n"; }
115 print "\n";
116 }
117 
118 
119sub plot_proc {
120 
121 print "creating images for processes...\n";
122 
123 opendir(DIR,"./rrd");
124 my @files=readdir(DIR);
125 closedir(DIR);
126 my @results=grep /proc.*\.rrd/,@files;
127 foreach (@results) { s/\.rrd//g; }
128 
129 # if database exists, create images...
130 if (@results) {
131 my $LEGEND="processes";
132 foreach my $dev (@results) {
133 my $DB_FILE="./rrd/$dev.rrd";
134 print " $dev:\n";
135 foreach $range ("1h","6h","1day","1week","1month","1year") {
136 my $legends="min avg max";
137 if($range eq "1h") { $legends="min avg max cur"; }
138 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
139 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "--title", "processes - last $descr ($DATESTRING)");
140 my @COMMANDS=(
141 HotSaNICdiagram::insert_vars($DB_FILE,"procslp","slp","MIN AVERAGE MAX"),
142 HotSaNICdiagram::insert_vars($DB_FILE,"procrun","run","MIN AVERAGE MAX"),
143 HotSaNICdiagram::insert_vars($DB_FILE,"proczmb","zmb","MIN AVERAGE MAX"),
144 HotSaNICdiagram::insert_vars($DB_FILE,"procstp","stp","MIN AVERAGE MAX"),
145 HotSaNICdiagram::insert_vars($DB_FILE,"procdsc","dsk","MIN AVERAGE MAX"),
146 HotSaNICdiagram::insert_data("AREA" ,"slp_avg slp_min slp_avg slp_max slp_max",$MODULECONFIG{COLOR_PROC_SLEEP} ,"sleeping",$legends,$LEGEND),
147 HotSaNICdiagram::insert_data("STACK","dsk_avg dsk_min dsk_avg dsk_max dsk_max",$MODULECONFIG{COLOR_PROC_DISC} ,"disc ",$legends,$LEGEND),
148 HotSaNICdiagram::insert_data("STACK","run_avg run_min run_avg run_max run_max",$MODULECONFIG{COLOR_PROC_RUN} ,"running ",$legends,$LEGEND),
149 HotSaNICdiagram::insert_data("STACK","zmb_avg zmb_min zmb_avg zmb_max zmb_max",$MODULECONFIG{COLOR_PROC_ZOMBIE},"zombie ",$legends,$LEGEND),
150 HotSaNICdiagram::insert_data("STACK","stp_avg stp_min stp_avg stp_max stp_max",$MODULECONFIG{COLOR_PROC_STOP} ,"stopped ",$legends,$LEGEND),
151 HotSaNICdiagram::insert_lines(%MODULECONFIG));
152 
153 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
154 HotSaNICdiagram::graph(%CONF);
155 
156 }
157 }
158 }
159 else { print " No database found\n Please check if the daemon is running.\n"; }
160 print "\n";
161 }
162 
163 
164sub plot_cpu {
165 print "creating images for CPU-usage...\n";
166 
167 my $NUMCPU=$MODULECONFIG{NUMCPU} || 1;
168 if ($NUMCPU < 1) { $NUMCPU=1; }
169 
170 my ($PERCENT,$SIGN,$SIGN1);
171 
172 my $LEGEND="usage";
173 
174 if ( ($MODULECONFIG{GRAPH_BASE} eq "percent" ) or ($MODULECONFIG{GRAPH_BASE} eq "%" ) ) { $PERCENT="100"; $SIGN=" (%)"; $SIGN1=" %% "; }
175 else { $PERCENT="1"; $SIGN=""; $SIGN1=""; }
176 
177 opendir(DIR,"./rrd");
178 my @files=readdir(DIR);
179 closedir(DIR);
180 my @results=grep /cpu.*\.rrd/,@files;
181 foreach (@results) { s/\.rrd//g; }
182 
183 # if database exists, create images...
184 if (@results) {
185 foreach my $dev (sort @results) {
186 my $DB_FILE="./rrd/$dev.rrd";
187 print " $dev:\n";
188 foreach $range ("1h","6h","1day","1week","1month","1year") {
189 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
190 my $FILENAME="$OUTDIR/$dev-$file.$IMGFMT";
191 
192 # for multicpu: plot range 0..1 for cpu0, cpu1, ... else range 0...$NUMCPU
193 #
194 my $NUM=$NUMCPU;
195 if ( $dev =~ /[0-9]/ ) { $NUM=1; }
196 
197 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "-u", ($NUMCPU*$PERCENT), "--title", "CPU usage - last $descr ($DATESTRING)");
198 my @COMMANDS=();
199 
200 my $legends="min avg max";
201 if ($range eq "1h") { $legends="min avg max cur"; }
202 
203 if ( ($^O eq "linux") || ($^O eq "solaris") ) {
204 @COMMANDS=(
205 "DEF:usrdat=$DB_FILE:cpuusr:AVERAGE",
206 "DEF:nicdat=$DB_FILE:cpunic:AVERAGE",
207 "DEF:sysdat=$DB_FILE:cpusys:AVERAGE",
208 "DEF:idldat=$DB_FILE:cpuidl:AVERAGE",
209 "CDEF:usravg=usrdat,$NUM,$PERCENT,*,*",
210 "CDEF:nicavg=nicdat,$NUM,$PERCENT,*,*",
211 "CDEF:sysavg=sysdat,$NUM,$PERCENT,*,*",
212 "CDEF:idlavg=idldat,$NUM,$PERCENT,*,*",
213 HotSaNICdiagram::insert_data("AREA" ,"sysavg",$MODULECONFIG{COLOR_CPU_SYSTEM},"system",$legends,$SIGN1),
214 HotSaNICdiagram::insert_data("STACK","usravg",$MODULECONFIG{COLOR_CPU_USER} ,"user ",$legends,$SIGN1),
215 HotSaNICdiagram::insert_data("STACK","nicavg",$MODULECONFIG{COLOR_CPU_NICE} ,"nice ",$legends,$SIGN1),
216 HotSaNICdiagram::insert_data("STACK","idlavg",$MODULECONFIG{COLOR_CPU_IDLE} ,"idle ",$legends,$SIGN1));
217 }
218 elsif ( ($^O eq "freebsd") || ($^O eq "netbsd")) {
219 @COMMANDS=(
220 "DEF:usravg=$DB_FILE:cpuusr:AVERAGE",
221 "DEF:nicavg=$DB_FILE:cpunic:AVERAGE",
222 "DEF:sysavg=$DB_FILE:cpusys:AVERAGE",
223 "DEF:idlavg=$DB_FILE:cpuidl:AVERAGE",
224 "DEF:intavg=$DB_FILE:cpuint:AVERAGE",
225 HotSaNICdiagram::insert_data("AREA" ,"sysavg",$MODULECONFIG{COLOR_CPU_SYSTEM} ,"system ",$legends,$SIGN1),
226 HotSaNICdiagram::insert_data("STACK","intavg",$MODULECONFIG{COLOR_CPU_INTERRUPT},"interrupt",$legends,$SIGN1),
227 HotSaNICdiagram::insert_data("STACK","usravg",$MODULECONFIG{COLOR_CPU_USER} ,"user ",$legends,$SIGN1),
228 HotSaNICdiagram::insert_data("STACK","nicavg",$MODULECONFIG{COLOR_CPU_NICE} ,"nice ",$legends,$SIGN1),
229 HotSaNICdiagram::insert_data("STACK","idlavg",$MODULECONFIG{COLOR_CPU_IDLE} ,"idle ",$legends,$SIGN1));
230 }
231 if ( ($fullrange > 600800) and ($MODULECONFIG{CPU_SHOW_MAX} == 1) ) {
232 push @COMMANDS,(
233 "DEF:usrdx=$DB_FILE:cpuusr:MAX",
234 "DEF:nicdx=$DB_FILE:cpunic:MAX",
235 "DEF:sysdx=$DB_FILE:cpusys:MAX",
236 "CDEF:usrmax=usrdx,$NUM,$PERCENT,*,*",
237 "CDEF:nicmax=nicdx,$NUM,$PERCENT,*,*",
238 "CDEF:sysmax=sysdx,$NUM,$PERCENT,*,*",
239 "LINE1:sysmax#".$MODULECONFIG{COLOR_CPU_SYSTEM_MAX}.":",
240 "LINE1:usrmax#".$MODULECONFIG{COLOR_CPU_USER_MAX}.":",
241 "LINE1:nicmax#".$MODULECONFIG{COLOR_CPU_NICE_MAX}.":");
242 }
243 push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
244 
245 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
246 HotSaNICdiagram::graph(%CONF);
247 }
248 }
249 }
250 else { print " No database found\n Please check if the daemon is running.\n"; }
251 print "\n";
252 }
253 
254 
255sub plot_mem {
256 
257 print "creating images for memory-usage...\n";
258 
259 opendir(DIR,"./rrd");
260 my @files=readdir(DIR);
261 closedir(DIR);
262 my @results=grep /mem.*\.rrd/,@files;
263 foreach (@results) { s/\.rrd//g; }
264 
265 # if database exists, create images...
266 if (@results) {
267 my $LEGEND="bytes";
268 foreach my $dev (@results) {
269 my $DB_FILE="./rrd/$dev.rrd";
270 print " mem:\n";
271 foreach $range ("1h","6h","1day","1week","1month","1year") {
272 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
273 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "--title", "memory usage - last $descr ($DATESTRING)");
274 my @COMMANDS=();
275 
276 my $legends="min avg max";
277 if ($range eq "1h") { $legends="min avg max cur"; }
278 if ($^O eq "linux") {
279 @COMMANDS=(
280 "DEF:memfre=$DB_FILE:memfre:AVERAGE",
281 "DEF:memshr=$DB_FILE:memshr:AVERAGE",
282 "DEF:membuf=$DB_FILE:membuf:AVERAGE",
283 "DEF:memcac=$DB_FILE:memcac:AVERAGE",
284 HotSaNICdiagram::insert_data("AREA" ,"memcac",$MODULECONFIG{COLOR_MEM_CACHED} ,"cached ",$legends,$LEGEND,1),
285 HotSaNICdiagram::insert_data("STACK","memshr",$MODULECONFIG{COLOR_MEM_SHARED} ,"shared ",$legends,$LEGEND,1),
286 HotSaNICdiagram::insert_data("STACK","membuf",$MODULECONFIG{COLOR_MEM_BUFFERED},"buffered",$legends,$LEGEND,1),
287 HotSaNICdiagram::insert_data("STACK","memfre",$MODULECONFIG{COLOR_MEM_FREE} ,"free ",$legends,$LEGEND,1),
288 HotSaNICdiagram::insert_lines(%MODULECONFIG));
289 }
290 if ($^O eq "solaris") {
291 @COMMANDS=(
292 "DEF:memfre=$DB_FILE:memfre:AVERAGE",
293 "DEF:memshr=$DB_FILE:memshr:AVERAGE",
294 HotSaNICdiagram::insert_data("AREA" ,"memshr",$MODULECONFIG{COLOR_MEM_USED},"used",$legends,$LEGEND,1),
295 HotSaNICdiagram::insert_data("STACK","memfre",$MODULECONFIG{COLOR_MEM_FREE},"free",$legends,$LEGEND,1),
296 HotSaNICdiagram::insert_lines(%MODULECONFIG));
297 }
298 elsif ($^O eq "freebsd") {
299 @COMMANDS=(
300 "DEF:memfree=$DB_FILE:memfree:AVERAGE",
301 "DEF:memwire=$DB_FILE:memwire:AVERAGE",
302 "DEF:memactv=$DB_FILE:memactv:AVERAGE",
303 "DEF:meminac=$DB_FILE:meminac:AVERAGE",
304 "DEF:memcach=$DB_FILE:memcach:AVERAGE",
305 HotSaNICdiagram::insert_data("AREA" ,"memwire",$MODULECONFIG{COLOR_MEM_WIRED} ,"wired ",$legends,$LEGEND,1),
306 HotSaNICdiagram::insert_data("STACK","memactv",$MODULECONFIG{COLOR_MEM_ACTIVE} ,"active ",$legends,$LEGEND,1),
307 HotSaNICdiagram::insert_data("STACK","memcach",$MODULECONFIG{COLOR_MEM_CACHED} ,"cached ",$legends,$LEGEND,1),
308 HotSaNICdiagram::insert_data("STACK","meminac",$MODULECONFIG{COLOR_MEM_INACTIVE},"inactive",$legends,$LEGEND,1),
309 HotSaNICdiagram::insert_data("STACK","memfree",$MODULECONFIG{COLOR_MEM_FREE} ,"free ",$legends,$LEGEND,1),
310 HotSaNICdiagram::insert_lines(%MODULECONFIG));
311 }
312 elsif ($^O eq "netbsd") {
313 @COMMANDS=(
314 "DEF:memfree=$DB_FILE:memfree:AVERAGE",
315 "DEF:meminac=$DB_FILE:meminac:AVERAGE",
316 "DEF:memactv=$DB_FILE:memactv:AVERAGE",
317 "DEF:memwire=$DB_FILE:memwire:AVERAGE",
318 "DEF:memcach=$DB_FILE:memcach:AVERAGE",
319 HotSaNICdiagram::insert_data("AREA" ,"memcach",$MODULECONFIG{COLOR_MEM_NBSD_CACHED} ,"cached ",$legends,$LEGEND,1),
320 HotSaNICdiagram::insert_data("STACK","memwire",$MODULECONFIG{COLOR_MEM_NBSD_WIRED} ,"wired ",$legends,$LEGEND,1),
321 HotSaNICdiagram::insert_data("STACK","memactv",$MODULECONFIG{COLOR_MEM_ACTIVE} ,"active ",$legends,$LEGEND,1),
322 HotSaNICdiagram::insert_data("STACK","meminac",$MODULECONFIG{COLOR_MEM_NBSD_INACTIVE},"inactive",$legends,$LEGEND,1),
323 HotSaNICdiagram::insert_data("STACK","memfree",$MODULECONFIG{COLOR_MEM_NBSD_FREE} ,"free ",$legends,$LEGEND,1),
324 HotSaNICdiagram::insert_lines(%MODULECONFIG));
325 }
326 elsif ($^O eq "darwin") {
327 @COMMANDS=(
328 "DEF:memfree=$DB_FILE:memfree:AVERAGE",
329 "DEF:memwire=$DB_FILE:memwire:AVERAGE",
330 "DEF:memactv=$DB_FILE:memactv:AVERAGE",
331 "DEF:meminac=$DB_FILE:meminac:AVERAGE",
332 HotSaNICdiagram::insert_data("AREA" ,"memwire",$MODULECONFIG{COLOR_MEM_WIRED} ,"wired ",$legends,$LEGEND,1),
333 HotSaNICdiagram::insert_data("STACK","memactv",$MODULECONFIG{COLOR_MEM_ACTIVE} ,"active ",$legends,$LEGEND,1),
334 HotSaNICdiagram::insert_data("STACK","meminac",$MODULECONFIG{COLOR_MEM_INACTIVE},"inactive",$legends,$LEGEND,1),
335 HotSaNICdiagram::insert_data("STACK","memfree",$MODULECONFIG{COLOR_MEM_FREE} ,"free ",$legends,$LEGEND,1),
336 HotSaNICdiagram::insert_lines(%MODULECONFIG));
337 }
338 
339 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
340 HotSaNICdiagram::graph(%CONF);
341 
342 }
343 }
344 }
345 else { print " No database found\n Please check if the daemon is running.\n"; }
346 print "\n";
347 }
348 
349 
350sub plot_swap {
351 
352 print "creating images for swapfile-usage...\n";
353 
354 opendir(DIR,"./rrd");
355 my @files=readdir(DIR);
356 closedir(DIR);
357 my @results=grep /mem.*\.rrd/,@files;
358 foreach (@results) { s/\.rrd//g; }
359 
360 my $LEGEND="bytes";
361 
362 # if database exists, create images...
363 if (@results) {
364 foreach my $dev (@results) {
365 my $DB_FILE="./rrd/$dev.rrd";
366 print " swap:\n";
367 foreach $range ("1h","6h","1day","1week","1month","1year") {
368 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
369 (my $dev1=$dev) =~ s/^mem/swap/g;
370 
371 my $legends="min avg max";
372 if ($range eq "1h") { $legends="min avg max cur"; }
373 
374 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "--title", "swapfile usage - last $descr ($DATESTRING)");
375 my @COMMANDS=(
376 "DEF:swpfre=$DB_FILE:swpfre:AVERAGE",
377 "DEF:swpuse=$DB_FILE:swpuse:AVERAGE",
378 "DEF:maxswpuse=$DB_FILE:swpuse:MAX",
379 HotSaNICdiagram::insert_data("AREA" ,"swpuse" ,$MODULECONFIG{COLOR_SWAP_USED} ,"used ",$legends,$LEGEND,1),
380 HotSaNICdiagram::insert_data("STACK","swpfre" ,$MODULECONFIG{COLOR_SWAP_FREE} ,"free ",$legends,$LEGEND,1),
381 HotSaNICdiagram::insert_data("LINE1","maxswpuse",$MODULECONFIG{COLOR_SWAP_USED_MAX},"max used",$legends,$LEGEND,1),
382 HotSaNICdiagram::insert_lines(%MODULECONFIG));
383 
384 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev1-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
385 HotSaNICdiagram::graph(%CONF);
386 
387 }
388 }
389 }
390 else { print " No database found\n Please check if the daemon is running.\n"; }
391 print "\n";
392 }
393 
394 
395sub plot_user {
396 
397 print "creating images for user-stats...\n";
398 
399 opendir(DIR,"./rrd");
400 my @files=readdir(DIR);
401 closedir(DIR);
402 my @results=grep /users.*\.rrd/,@files;
403 foreach (@results) { s/\.rrd//g; }
404 
405 # if database exists, create images...
406 if (@results) {
407 my $LEGEND="users";
408 foreach my $dev (@results) {
409 my $DB_FILE="./rrd/$dev.rrd";
410 print " $dev:\n";
411 foreach $range ("1h","6h","1day","1week","1month","1year") {
412 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
413 
414 my $legends="min avg max";
415 if($range eq "1h") { $legends="min avg max cur"; }
416 
417 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "--title", "users - last $descr ($DATESTRING)");
418 my @COMMANDS=(
419 HotSaNICdiagram::insert_vars($DB_FILE,"tty","tty","MIN AVERAGE MAX"),
420 HotSaNICdiagram::insert_vars($DB_FILE,"pty","pty","MIN AVERAGE MAX"),
421 HotSaNICdiagram::insert_vars($DB_FILE,"pts","pts","MIN AVERAGE MAX"),
422 HotSaNICdiagram::insert_data("AREA" ,"tty_avg tty_min tty_avg tty_max",$MODULECONFIG{COLOR_USERS_TTY},"tty users",$legends,$LEGEND,1),
423 HotSaNICdiagram::insert_data("STACK","pty_avg pty_min pty_avg pty_max",$MODULECONFIG{COLOR_USERS_PTY},"pty users",$legends,$LEGEND,1),
424 HotSaNICdiagram::insert_data("STACK","pts_avg pts_min pts_avg pts_max",$MODULECONFIG{COLOR_USERS_PTS},"pts users",$legends,$LEGEND,1));
425 if ($MODULECONFIG{USERS_SHOW_TOTAL} == 1) {
426 push @COMMANDS,("CDEF:tot_avg=tty_avg,pty_avg,pts_avg,+,+",
427 "CDEF:tot_max=tty_max,pty_max,pts_max,+,+",
428 HotSaNICdiagram::insert_data("LINE1","tot_max",$MODULECONFIG{COLOR_USERS_TOTAL_MAX},"total max",$legends,$LEGEND,1),
429 HotSaNICdiagram::insert_data("LINE1","tot_avg",$MODULECONFIG{COLOR_USERS_TOTAL} ,"total avg",$legends,$LEGEND,1));
430 }
431 push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
432 
433 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
434 HotSaNICdiagram::graph(%CONF);
435 
436 
437 }
438 }
439 }
440 else { print " No database found\n Please check if the daemon is running.\n"; }
441 print "\n";
442 }
443 
444 
445sub plot_irq {
446 
447 print "creating images for interrupts...\n";
448 
449 my @ITEMS=("(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)","(?)");
450 
451 foreach (@{$MODULECONFIG{IRQ}}) {
452 my ($num,$descr)=split /,/;
453 if ( (!defined $descr) or ($descr eq "") ) { $descr="(?)"; }
454 else { $ITEMS[$num]=substr("(".substr($descr,0,5).") ",0,7); }
455 }
456 
457 my $dev="irq";
458 my $LEGEND="$dev/s";
459 my $DB_FILE="./rrd/$dev.rrd";
460 
461 # if database exists, create images...
462 if ( -e $DB_FILE) {
463 foreach $range ("1h","6h","1day","1week","1month","1year") {
464 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
465 my $legends="min avg max";
466 if($range eq "1h") { $legends="min avg max cur"; }
467 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "--title", "total IRQ/s - last $descr ($DATESTRING)");
468 my @COMMANDS=(
469 HotSaNICdiagram::insert_vars($DB_FILE,"irqall","irqall","MIN AVERAGE MAX"),
470 "DEF:irqa00=$DB_FILE:irq00:AVERAGE",
471 "DEF:irqa01=$DB_FILE:irq01:AVERAGE",
472 "DEF:irqa02=$DB_FILE:irq02:AVERAGE",
473 "DEF:irqa03=$DB_FILE:irq03:AVERAGE",
474 "DEF:irqa04=$DB_FILE:irq04:AVERAGE",
475 "DEF:irqa05=$DB_FILE:irq05:AVERAGE",
476 "DEF:irqa06=$DB_FILE:irq06:AVERAGE",
477 "DEF:irqa07=$DB_FILE:irq07:AVERAGE",
478 "DEF:irqa08=$DB_FILE:irq08:AVERAGE",
479 "DEF:irqa09=$DB_FILE:irq09:AVERAGE",
480 "DEF:irqa10=$DB_FILE:irq10:AVERAGE",
481 "DEF:irqa11=$DB_FILE:irq11:AVERAGE",
482 "DEF:irqa12=$DB_FILE:irq12:AVERAGE",
483 "DEF:irqa13=$DB_FILE:irq13:AVERAGE",
484 "DEF:irqa14=$DB_FILE:irq14:AVERAGE",
485 "DEF:irqa15=$DB_FILE:irq15:AVERAGE",
486 HotSaNICdiagram::insert_data("AREA","irqall_max irqall_min irqall_avg irqall_max",$MODULECONFIG{COLOR_INT_AREA},"total",$legends,$LEGEND,1),
487 "AREA:irqall_min#ffffff:\\g",
488 "LINE1:irqall_max#".$MODULECONFIG{COLOR_INT_ALL_MAX}.":",
489 "LINE1:irqall_min#".$MODULECONFIG{COLOR_INT_ALL_MIN}.":",
490 "LINE1:irqall_avg#".$MODULECONFIG{COLOR_INT_ALL_AVG}.":",
491 "COMMENT:Averages (min/max):\\n");
492 for (my $int=0;$int<16;$int++) {
493 my $intnum=$int;
494 if ($int<10) { $intnum="0$int"; }
495 
496 push @COMMANDS,("LINE2:irqa$intnum#".$MODULECONFIG{"COLOR_INT_$intnum"}.":$intnum".$ITEMS[$int],
497 "GPRINT:irqa$intnum:MIN:%5.1lf%s/\\g",
498 "GPRINT:irqa$intnum:MAX:%5.1lf%s");
499 }
500 push @COMMANDS,HotSaNICdiagram::insert_lines(%MODULECONFIG);
501 
502 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
503 HotSaNICdiagram::graph(%CONF);
504 
505 }
506 }
507 else { print " No database \"$DB_FILE\" found\n Please check if the daemon is running.\n"; }
508 print "\n";
509 }
510 
511sub plot_uptime {
512 
513 print "creating images for uptime...\n";
514 
515 opendir(DIR,"./rrd");
516 my @files=readdir(DIR);
517 closedir(DIR);
518 my @results=grep /uptime.*\.rrd/,@files;
519 foreach (@results) { s/\.rrd//g; }
520 
521 # if database exists, create images...
522 if (@results) {
523 my $LEGEND="days";
524 foreach my $dev (@results) {
525 my $DB_FILE="./rrd/$dev.rrd";
526 print " $dev:\n";
527 foreach $range ("1h", "6h", "1day","1week","1month","1year") {
528 my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range);
529 my @EXTOPTIONS=("-s","-$range", "-v", $LEGEND, "--title", "system-uptime - last $descr ($DATESTRING)");
530 my @COMMANDS=(
531 "DEF:up=$DB_FILE:up:AVERAGE",
532 "DEF:idle=$DB_FILE:idle:AVERAGE",
533 "AREA:up#".$MODULECONFIG{COLOR_UPTIME}.":uptime",
534 "GPRINT:up:MAX:(%1.2lf $LEGEND)\\n",
535 "AREA:idle#".$MODULECONFIG{COLOR_UPTIME_IDLE}.":idle time",
536 "GPRINT:idle:MAX:(%1.2lf $LEGEND)\\n",
537 HotSaNICdiagram::insert_lines(%MODULECONFIG));
538 
539 my %CONF=(RANGE=>$descr,FILENAME=>"$OUTDIR/$dev-$file",FORMAT=>$IMGFMT,INTERVAL=>$build,FORCE=>$FORCE,OPTIONS=>[@OPTIONS,@EXTOPTIONS,@COMMANDS],DEBUGLEVEL=>$DEBUGLEVEL,MODNAME=>$MODNAME);
540 HotSaNICdiagram::graph(%CONF);
541 }
542 }
543 }
544 else { print " No database found\n Please check if the daemon is running.\n"; }
545 print "\n";
546 }

Powered by WebSVN 2.2.1