]>
Commit | Line | Data |
---|---|---|
0b1641db | 1 | #!/usr/bin/perl |
350b52c5 | 2 | # Generate Graphs exported from Makegraphs to minimize system load an only generate the Graphs when displayed |
0edf2f61 | 3 | # This is part of the IPFire Firewall |
350b52c5 | 4 | |
0b1641db | 5 | |
350b52c5 CS |
6 | package Graphs; |
7 | ||
8 | use strict; | |
9 | use RRDs; | |
10 | ||
11 | require '/var/ipfire/general-functions.pl'; | |
12 | require "${General::swroot}/lang.pl"; | |
13 | require "${General::swroot}/header.pl"; | |
14 | ||
350b52c5 CS |
15 | my $ERROR; |
16 | my $rrdlog = "/var/log/rrd"; | |
17 | my $graphs = "/srv/web/ipfire/html/graphs"; | |
18 | $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; | |
19 | ||
6257cba2 CS |
20 | # Read the global settings files to get the current theme and after this load |
21 | # colors for this theme | |
22 | ||
350b52c5 CS |
23 | my %color = (); |
24 | my %mainsettings = (); | |
e1e3dbe5 | 25 | my %mbmonsettings = (); |
350b52c5 | 26 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); |
e1e3dbe5 | 27 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); |
cce90b0b | 28 | |
6257cba2 CS |
29 | |
30 | # If the collection deamon is working and collecting mbmon data there will be | |
31 | # some data source named after a common scheme, with the mbmonsettingsfile | |
32 | # the user is able to deactivate some of this parameters, in case not to show | |
33 | # false collected value´s may be disable. The user has the ability to enter | |
34 | # custom graph names in order to change temp0 to cpu or motherboad | |
35 | ||
350b52c5 CS |
36 | my $key; |
37 | my $value; | |
38 | my @args = (); | |
39 | my $count = 0; | |
e1e3dbe5 CS |
40 | my @mbmongraphs = (); |
41 | if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){ | |
42 | @mbmongraphs = `ls /var/log/rrd/collectd/localhost/mbmon/`; | |
43 | foreach (@mbmongraphs){ | |
44 | chomp($_); | |
45 | my @name=split(/\./,$_);my $label = $name[0]; $label=~ s/-//; | |
46 | $mbmonsettings{'LABEL-'.$name[0]}="$label"; | |
47 | $mbmonsettings{'LINE-'.$name[0]}="checked"; | |
48 | } | |
49 | } | |
50 | ||
51 | &General::readhash("${General::swroot}/mbmon/settings", \%mbmonsettings); | |
350b52c5 CS |
52 | use Encode 'from_to'; |
53 | ||
54 | my %tr=(); | |
b4af7142 | 55 | if ((${Lang::language} eq 'el') || |
350b52c5 CS |
56 | (${Lang::language} eq 'fa') || |
57 | (${Lang::language} eq 'ru') || | |
b4af7142 | 58 | (${Lang::language} eq 'th') || |
350b52c5 CS |
59 | (${Lang::language} eq 'vi') || |
60 | (${Lang::language} eq 'zh') || | |
61 | (${Lang::language} eq 'zt')) { | |
62 | eval `/bin/cat "${General::swroot}/langs/en.pl"`; | |
63 | } else { | |
64 | %tr=%Lang::tr; # use translated version for other languages | |
65 | } | |
66 | ||
6257cba2 CS |
67 | # Generate the CPU Graph for the current period of time for values given by |
68 | # collectd atm only cpu average is displayed and only 1 or 2 cpu´s is working | |
350b52c5 CS |
69 | |
70 | sub updatecpugraph { | |
6257cba2 CS |
71 | my $period = $_[0]; |
72 | my @command = ("$graphs/cpu-$period.png", | |
73 | "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}", | |
74 | "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r", | |
60412147 CS |
75 | "--color", "SHADEA".$color{"color19"}, |
76 | "--color", "SHADEB".$color{"color19"}, | |
77 | "--color", "BACK".$color{"color21"}, | |
6257cba2 CS |
78 | "-t $Lang::tr{'cpu usage per'} $Lang::tr{$period}"); |
79 | ||
80 | if ( -e "/var/log/rrd/collectd/localhost/cpu-1/" ){ | |
81 | push(@command,"DEF:iowait0=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE", | |
82 | "DEF:nice0=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE", | |
83 | "DEF:interrupt0=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE", | |
84 | "DEF:steal0=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE", | |
85 | "DEF:user0=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE", | |
86 | "DEF:system0=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE", | |
87 | "DEF:idle0=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE", | |
88 | "DEF:irq0=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE"); | |
89 | push(@command,"DEF:iowait1=$rrdlog/collectd/localhost/cpu-1/cpu-wait.rrd:value:AVERAGE", | |
90 | "DEF:nice1=$rrdlog/collectd/localhost/cpu-1/cpu-nice.rrd:value:AVERAGE", | |
91 | "DEF:interrupt1=$rrdlog/collectd/localhost/cpu-1/cpu-interrupt.rrd:value:AVERAGE", | |
92 | "DEF:steal1=$rrdlog/collectd/localhost/cpu-1/cpu-steal.rrd:value:AVERAGE", | |
93 | "DEF:user1=$rrdlog/collectd/localhost/cpu-1/cpu-user.rrd:value:AVERAGE", | |
94 | "DEF:system1=$rrdlog/collectd/localhost/cpu-1/cpu-system.rrd:value:AVERAGE", | |
95 | "DEF:idle1=$rrdlog/collectd/localhost/cpu-1/cpu-idle.rrd:value:AVERAGE", | |
96 | "DEF:irq1=$rrdlog/collectd/localhost/cpu-1/cpu-softirq.rrd:value:AVERAGE"); | |
97 | push(@command,"CDEF:user=user0,user1,+", | |
98 | "CDEF:nice=nice0,nice1,+", | |
99 | "CDEF:interrupt=interrupt0,interrupt1,+", | |
100 | "CDEF:steal=steal0,steal1,+", | |
101 | "CDEF:system=system0,system1,+", | |
102 | "CDEF:idle=idle0,idle1,+", | |
103 | "CDEF:iowait=iowait0,iowait1,+", | |
104 | "CDEF:irq=irq0,irq1,+"); | |
105 | } | |
106 | else { | |
107 | push(@command,"DEF:iowait=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE", | |
108 | "DEF:nice=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE", | |
109 | "DEF:interrupt=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE", | |
110 | "DEF:steal=$rrdlog/collectd/localhost/cpu-0/cpu-steal.rrd:value:AVERAGE", | |
111 | "DEF:user=$rrdlog/collectd/localhost/cpu-0/cpu-user.rrd:value:AVERAGE", | |
112 | "DEF:system=$rrdlog/collectd/localhost/cpu-0/cpu-system.rrd:value:AVERAGE", | |
113 | "DEF:idle=$rrdlog/collectd/localhost/cpu-0/cpu-idle.rrd:value:AVERAGE", | |
114 | "DEF:irq=$rrdlog/collectd/localhost/cpu-0/cpu-softirq.rrd:value:AVERAGE"); | |
115 | } | |
116 | push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,+,+,+,+,+,+,+", | |
117 | "CDEF:userpct=100,user,total,/,*", | |
118 | "CDEF:nicepct=100,nice,total,/,*", | |
119 | "CDEF:interruptpct=100,interrupt,total,/,*", | |
120 | "CDEF:stealpct=100,steal,total,/,*", | |
121 | "CDEF:systempct=100,system,total,/,*", | |
122 | "CDEF:idlepct=100,idle,total,/,*", | |
123 | "CDEF:iowaitpct=100,iowait,total,/,*", | |
124 | "CDEF:irqpct=100,irq,total,/,*", | |
125 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), | |
126 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
127 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
128 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
129 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
a332b303 | 130 | "AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr{'cpu iowait usage'}), |
249dda69 CS |
131 | "GPRINT:iowaitpct:MAX:%3.2lf%%", |
132 | "GPRINT:iowaitpct:AVERAGE:%3.2lf%%", | |
133 | "GPRINT:iowaitpct:MIN:%3.2lf%%", | |
134 | "GPRINT:iowaitpct:LAST:%3.2lf%%\\j", | |
a332b303 | 135 | "STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'cpu irq usage'}), |
249dda69 CS |
136 | "GPRINT:irqpct:MAX:%3.2lf%%", |
137 | "GPRINT:irqpct:AVERAGE:%3.2lf%%", | |
138 | "GPRINT:irqpct:MIN:%3.2lf%%", | |
139 | "GPRINT:irqpct:LAST:%3.2lf%%\\j", | |
a332b303 CS |
140 | "STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr{'cpu nice usage'}), |
141 | "GPRINT:nicepct:MAX:%3.2lf%%", | |
142 | "GPRINT:nicepct:AVERAGE:%3.2lf%%", | |
143 | "GPRINT:nicepct:MIN:%3.2lf%%", | |
144 | "GPRINT:nicepct:LAST:%3.2lf%%\\j", | |
145 | "STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr{'cpu interrupt usage'}), | |
146 | "GPRINT:interruptpct:MAX:%3.2lf%%", | |
147 | "GPRINT:interruptpct:AVERAGE:%3.2lf%%", | |
148 | "GPRINT:interruptpct:MIN:%3.2lf%%", | |
149 | "GPRINT:interruptpct:LAST:%3.2lf%%\\j", | |
150 | "STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr{'cpu steal usage'}), | |
151 | "GPRINT:stealpct:MAX:%3.2lf%%", | |
152 | "GPRINT:stealpct:AVERAGE:%3.2lf%%", | |
153 | "GPRINT:stealpct:MIN:%3.2lf%%", | |
154 | "GPRINT:stealpct:LAST:%3.2lf%%\\j", | |
155 | "STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'cpu user usage'}), | |
249dda69 CS |
156 | "GPRINT:userpct:MAX:%3.2lf%%", |
157 | "GPRINT:userpct:AVERAGE:%3.2lf%%", | |
158 | "GPRINT:userpct:MIN:%3.2lf%%", | |
159 | "GPRINT:userpct:LAST:%3.2lf%%\\j", | |
a332b303 | 160 | "STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cpu system usage'}), |
249dda69 CS |
161 | "GPRINT:systempct:MAX:%3.2lf%%", |
162 | "GPRINT:systempct:AVERAGE:%3.2lf%%", | |
163 | "GPRINT:systempct:MIN:%3.2lf%%", | |
164 | "GPRINT:systempct:LAST:%3.2lf%%\\j", | |
a332b303 | 165 | "STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'cpu idle usage'}), |
249dda69 CS |
166 | "GPRINT:idlepct:MAX:%3.2lf%%", |
167 | "GPRINT:idlepct:AVERAGE:%3.2lf%%", | |
168 | "GPRINT:idlepct:MIN:%3.2lf%%", | |
169 | "GPRINT:idlepct:LAST:%3.2lf%%\\j"); | |
6257cba2 CS |
170 | |
171 | RRDs::graph (@command); | |
60412147 CS |
172 | $ERROR = RRDs::error; |
173 | print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; | |
350b52c5 CS |
174 | } |
175 | ||
6257cba2 CS |
176 | # Generate the Load Graph for the current period of time for values given by collecd |
177 | ||
350b52c5 | 178 | sub updateloadgraph { |
60412147 CS |
179 | my $period = $_[0]; |
180 | ||
181 | RRDs::graph ("$graphs/load-$period.png", | |
182 | "--start", "-1$period", "-aPNG", | |
6257cba2 CS |
183 | "-w 600", "-h 125", "-i", "-z", "-W www.ipfire.org", "-l 0", "-r", "--alt-y-grid", |
184 | "-t Load Average $Lang::tr{'graph per'} $Lang::tr{$period}", "-v $Lang::tr{'processes'}", | |
60412147 CS |
185 | "--color", "SHADEA".$color{"color19"}, |
186 | "--color", "SHADEB".$color{"color19"}, | |
187 | "--color", "BACK".$color{"color21"}, | |
a332b303 CS |
188 | "DEF:load1=$rrdlog/collectd/localhost/load/load.rrd:shortterm:AVERAGE", |
189 | "DEF:load5=$rrdlog/collectd/localhost/load/load.rrd:midterm:AVERAGE", | |
190 | "DEF:load15=$rrdlog/collectd/localhost/load/load.rrd:longterm:AVERAGE", | |
6257cba2 | 191 | "AREA:load1".$color{"color13"}."A0:1 Minute:", |
60412147 | 192 | "GPRINT:load1:LAST:%5.2lf", |
6257cba2 | 193 | "AREA:load5".$color{"color18"}."A0:5 Minuten:", |
60412147 | 194 | "GPRINT:load5:LAST:%5.2lf", |
6257cba2 | 195 | "AREA:load15".$color{"color14"}."A0:15 Minuten:", |
60412147 CS |
196 | "GPRINT:load15:LAST:%5.2lf\\j", |
197 | "LINE1:load5".$color{"color13"}, | |
198 | "LINE1:load1".$color{"color18"}); | |
199 | $ERROR = RRDs::error; | |
200 | print "Error in RRD::graph for load: $ERROR\n" if $ERROR; | |
350b52c5 CS |
201 | } |
202 | ||
6257cba2 CS |
203 | # Generate the Memory and Swap Graph for the current period of time for values given by collecd |
204 | ||
350b52c5 | 205 | sub updatememgraph { |
60412147 CS |
206 | my $period = $_[0]; |
207 | ||
208 | RRDs::graph ("$graphs/memory-$period.png", | |
a332b303 | 209 | "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}", |
6257cba2 | 210 | "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r", |
60412147 CS |
211 | "--color", "SHADEA".$color{"color19"}, |
212 | "--color", "SHADEB".$color{"color19"}, | |
213 | "--color", "BACK".$color{"color21"}, | |
0edf2f61 | 214 | "-t $Lang::tr{'memory usage per'} $Lang::tr{$period}", |
a332b303 CS |
215 | "DEF:used=$rrdlog/collectd/localhost/memory/memory-used.rrd:value:AVERAGE", |
216 | "DEF:free=$rrdlog/collectd/localhost/memory/memory-free.rrd:value:AVERAGE", | |
217 | "DEF:buffer=$rrdlog/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE", | |
218 | "DEF:cache=$rrdlog/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE", | |
219 | "CDEF:total=used,free,cache,buffer,+,+,+", | |
220 | "CDEF:usedpct=used,total,/,100,*", | |
221 | "CDEF:bufferpct=buffer,total,/,100,*", | |
222 | "CDEF:cachepct=cache,total,/,100,*", | |
223 | "CDEF:freepct=free,total,/,100,*", | |
6257cba2 CS |
224 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), |
225 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
226 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
227 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
228 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
a332b303 | 229 | "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used memory'}), |
249dda69 CS |
230 | "GPRINT:usedpct:MAX:%3.2lf%%", |
231 | "GPRINT:usedpct:AVERAGE:%3.2lf%%", | |
232 | "GPRINT:usedpct:MIN:%3.2lf%%", | |
233 | "GPRINT:usedpct:LAST:%3.2lf%%\\j", | |
a332b303 | 234 | "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'buffered memory'}), |
249dda69 CS |
235 | "GPRINT:bufferpct:MAX:%3.2lf%%", |
236 | "GPRINT:bufferpct:AVERAGE:%3.2lf%%", | |
237 | "GPRINT:bufferpct:MIN:%3.2lf%%", | |
238 | "GPRINT:bufferpct:LAST:%3.2lf%%\\j", | |
a332b303 | 239 | "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr{'cached memory'}), |
249dda69 CS |
240 | "GPRINT:cachepct:MAX:%3.2lf%%", |
241 | "GPRINT:cachepct:AVERAGE:%3.2lf%%", | |
242 | "GPRINT:cachepct:MIN:%3.2lf%%", | |
243 | "GPRINT:cachepct:LAST:%3.2lf%%\\j", | |
a332b303 | 244 | "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free memory'}), |
249dda69 CS |
245 | "GPRINT:freepct:MAX:%3.2lf%%", |
246 | "GPRINT:freepct:AVERAGE:%3.2lf%%", | |
247 | "GPRINT:freepct:MIN:%3.2lf%%", | |
248 | "GPRINT:freepct:LAST:%3.2lf%%\\j"); | |
60412147 CS |
249 | $ERROR = RRDs::error; |
250 | print "Error in RRD::graph for mem: $ERROR\n" if $ERROR; | |
251 | ||
252 | RRDs::graph ("$graphs/swap-$period.png", | |
a332b303 | 253 | "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", "-v $Lang::tr{'percentage'}", |
6257cba2 | 254 | "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-u 100", "-r", |
60412147 CS |
255 | "--color", "SHADEA".$color{"color19"}, |
256 | "--color", "SHADEB".$color{"color19"}, | |
257 | "--color", "BACK".$color{"color21"}, | |
0edf2f61 | 258 | "-t $Lang::tr{'swap usage per'} $Lang::tr{$period}", |
a332b303 CS |
259 | "DEF:used=$rrdlog/collectd/localhost/swap/swap-used.rrd:value:AVERAGE", |
260 | "DEF:free=$rrdlog/collectd/localhost/swap/swap-free.rrd:value:AVERAGE", | |
261 | "DEF:cached=$rrdlog/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE", | |
262 | "CDEF:total=used,free,cached,+,+", | |
60412147 CS |
263 | "CDEF:usedpct=100,used,total,/,*", |
264 | "CDEF:freepct=100,free,total,/,*", | |
a332b303 | 265 | "CDEF:cachedpct=100,cached,total,/,*", |
6257cba2 CS |
266 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), |
267 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
268 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
269 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
270 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
a332b303 | 271 | "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used swap'}), |
249dda69 CS |
272 | "GPRINT:usedpct:MAX:%3.2lf%%", |
273 | "GPRINT:usedpct:AVERAGE:%3.2lf%%", | |
274 | "GPRINT:usedpct:MIN:%3.2lf%%", | |
275 | "GPRINT:usedpct:LAST:%3.2lf%%\\j", | |
a332b303 | 276 | "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free swap'}), |
249dda69 CS |
277 | "GPRINT:freepct:MAX:%3.2lf%%", |
278 | "GPRINT:freepct:AVERAGE:%3.2lf%%", | |
279 | "GPRINT:freepct:MIN:%3.2lf%%", | |
a332b303 CS |
280 | "GPRINT:freepct:LAST:%3.2lf%%\\j", |
281 | "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cached swap'}), | |
282 | "GPRINT:cachedpct:MAX:%3.2lf%%", | |
283 | "GPRINT:cachedpct:AVERAGE:%3.2lf%%", | |
284 | "GPRINT:cachedpct:MIN:%3.2lf%%", | |
285 | "GPRINT:cachedpct:LAST:%3.2lf%%\\j"); | |
60412147 CS |
286 | $ERROR = RRDs::error; |
287 | print "Error in RRD::graph for swap: $ERROR\n" if $ERROR; | |
350b52c5 CS |
288 | } |
289 | ||
6257cba2 CS |
290 | # Generate the Disk Graph for the current period of time for values given by collecd |
291 | ||
350b52c5 | 292 | sub updatediskgraph { |
60412147 CS |
293 | my $period = $_[0]; |
294 | my $disk = $_[1]; | |
295 | ||
296 | RRDs::graph ("$graphs/disk-$disk-$period.png", | |
a332b303 | 297 | "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}", |
6257cba2 | 298 | "--alt-y-grid", "-w 600", "-h 125", "-r", "-z", |
a332b303 | 299 | "--color", "SHADEA".$color{"color19"}, |
60412147 CS |
300 | "--color", "SHADEB".$color{"color19"}, |
301 | "--color", "BACK".$color{"color21"}, | |
af95dec5 | 302 | "-t $disk $Lang::tr{'disk access per'} $Lang::tr{$period}", |
a332b303 CS |
303 | "DEF:read=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE", |
304 | "DEF:write=$rrdlog/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE", | |
305 | "CDEF:writen=write,-1,*", | |
471a46f7 CS |
306 | "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE", |
307 | "CDEF:st=standby,INF,*", | |
6257cba2 CS |
308 | "COMMENT:".sprintf("%-25s",$Lang::tr{'caption'}), |
309 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
310 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
311 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
312 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
e1e3dbe5 | 313 | "AREA:st".$color{"color20"}."A0:standby\\j", |
42dc0090 | 314 | "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'read bytes'}), |
a332b303 CS |
315 | "GPRINT:read:MAX:%8.1lf %sBps", |
316 | "GPRINT:read:AVERAGE:%8.1lf %sBps", | |
317 | "GPRINT:read:MIN:%8.1lf %sBps", | |
318 | "GPRINT:read:LAST:%8.1lf %sBps\\j", | |
319 | "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'written bytes'}), | |
320 | "GPRINT:write:MAX:%8.1lf %sBps", | |
321 | "GPRINT:write:AVERAGE:%8.1lf %sBps", | |
322 | "GPRINT:write:MIN:%8.1lf %sBps", | |
323 | "GPRINT:write:LAST:%8.1lf %sBps\\j"); | |
60412147 CS |
324 | $ERROR = RRDs::error; |
325 | print "Error in RRD::graph for disk: $ERROR\n" if $ERROR; | |
350b52c5 CS |
326 | } |
327 | ||
6257cba2 CS |
328 | # Generate the Interface Graph for the current period of time for values given by collecd |
329 | ||
350b52c5 | 330 | sub updateifgraph { |
a332b303 CS |
331 | my $interface = $_[0]; |
332 | my $period = $_[1]; | |
333 | ||
334 | RRDs::graph ("$graphs/$interface-$period.png", | |
335 | "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", "-v $Lang::tr{'bytes per second'}", | |
6257cba2 | 336 | "--alt-y-grid", "-w 600", "-h 125", "-z", "-r", |
a332b303 CS |
337 | "--color", "SHADEA".$color{"color19"}, |
338 | "--color", "SHADEB".$color{"color19"}, | |
339 | "--color", "BACK".$color{"color21"}, | |
340 | "-t $Lang::tr{'traffic on'} $interface $Lang::tr{'graph per'} $Lang::tr{$period}", | |
341 | "-v$Lang::tr{'bytes per second'}", | |
342 | "DEF:incoming=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:rx:AVERAGE", | |
343 | "DEF:outgoing=$rrdlog/collectd/localhost/interface/if_octets-$interface.rrd:tx:AVERAGE", | |
344 | "CDEF:outgoingn=outgoing,-1,*", | |
6257cba2 CS |
345 | "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}), |
346 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
347 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
348 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
349 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
350 | "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr{'incoming traffic in bytes per second'}), | |
a332b303 CS |
351 | "GPRINT:incoming:MAX:%8.1lf %sBps", |
352 | "GPRINT:incoming:AVERAGE:%8.1lf %sBps", | |
353 | "GPRINT:incoming:MIN:%8.1lf %sBps", | |
354 | "GPRINT:incoming:LAST:%8.1lf %sBps\\j", | |
6257cba2 | 355 | "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr{'outgoing traffic in bytes per second'}), |
a332b303 CS |
356 | "GPRINT:outgoing:MAX:%8.1lf %sBps", |
357 | "GPRINT:outgoing:AVERAGE:%8.1lf %sBps", | |
358 | "GPRINT:outgoing:MIN:%8.1lf %sBps", | |
359 | "GPRINT:outgoing:LAST:%8.1lf %sBps\\j"); | |
360 | $ERROR = RRDs::error; | |
361 | print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR; | |
350b52c5 CS |
362 | } |
363 | ||
6257cba2 CS |
364 | # Generate the Firewall Graph for the current period of time for values given by collecd |
365 | ||
350b52c5 | 366 | sub updatefwhitsgraph { |
a332b303 CS |
367 | my $period = $_[0]; |
368 | RRDs::graph ("$graphs/fwhits-$period.png", | |
369 | "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", | |
6257cba2 | 370 | "--alt-y-grid", "-w 600", "-h 125", "-r", "-v $Lang::tr{'bytes per second'}", |
a332b303 CS |
371 | "--color", "SHADEA".$color{"color19"}, |
372 | "--color", "SHADEB".$color{"color19"}, | |
373 | "--color", "BACK".$color{"color21"}, | |
374 | "-t $Lang::tr{'firewall hits per'} $Lang::tr{$period}", | |
375 | "DEF:output=$rrdlog/collectd/localhost/iptables-filter-FORWARD/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE", | |
376 | "DEF:input=$rrdlog/collectd/localhost/iptables-filter-INPUT/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE", | |
377 | "DEF:newnotsyn=$rrdlog/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE", | |
378 | "DEF:portscan=$rrdlog/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE", | |
379 | "CDEF:amount=output,input,newnotsyn,+,+", | |
6257cba2 CS |
380 | "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}), |
381 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
382 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
383 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
384 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
a332b303 CS |
385 | "AREA:amount".$color{"color24"}."A0:".sprintf("%-20s",$Lang::tr{'firewallhits'}), |
386 | "GPRINT:amount:MAX:%8.1lf %sBps", | |
387 | "GPRINT:amount:AVERAGE:%8.1lf %sBps", | |
388 | "GPRINT:amount:MIN:%8.1lf %sBps", | |
389 | "GPRINT:amount:LAST:%8.1lf %sBps\\j", | |
390 | "STACK:portscan".$color{"color25"}."A0:".sprintf("%-20s",$Lang::tr{'portscans'}), | |
391 | "GPRINT:portscan:MAX:%8.1lf %sBps", | |
392 | "GPRINT:portscan:MIN:%8.1lf %sBps", | |
393 | "GPRINT:portscan:AVERAGE:%8.1lf %sBps", | |
394 | "GPRINT:portscan:LAST:%8.1lf %sBps\\j"); | |
395 | $ERROR = RRDs::error; | |
6257cba2 | 396 | print "Error in RRD::graph for Firewallhits: $ERROR\n" if $ERROR; |
350b52c5 CS |
397 | } |
398 | ||
6257cba2 CS |
399 | # Generate the Line Quality Graph for the current period of time for values given by collecd |
400 | ||
350b52c5 | 401 | sub updatelqgraph { |
a332b303 CS |
402 | my $period = $_[0]; |
403 | RRDs::graph ("$graphs/lq-$period.png", | |
404 | "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", | |
6257cba2 | 405 | "--alt-y-grid", "-w 600", "-h 125", "-l 0", "-r", "-v ms", |
a332b303 CS |
406 | "-t $Lang::tr{'linkq'} $Lang::tr{'graph per'} $Lang::tr{$period}", |
407 | "--color", "SHADEA".$color{"color19"}, | |
408 | "--color", "SHADEB".$color{"color19"}, | |
409 | "--color", "BACK".$color{"color21"}, | |
410 | "DEF:roundtrip=$rrdlog/collectd/localhost/ping/ping-gateway.rrd:ping:AVERAGE", | |
411 | "COMMENT:$Lang::".sprintf("%-20s",$Lang::tr{'caption'})."\\j", | |
e1e3dbe5 CS |
412 | "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/", |
413 | "CDEF:r0=roundtrip,30,MIN", | |
414 | "CDEF:r1=roundtrip,70,MIN", | |
415 | "CDEF:r2=roundtrip,150,MIN", | |
416 | "CDEF:r3=roundtrip,300,MIN", | |
417 | "AREA:roundtrip".$color{"color25"}."A0:>300 ms", | |
418 | "AREA:r3".$color{"color18"}."A0:150-300 ms", | |
419 | "AREA:r2".$color{"color14"}."A0:70-150 ms", | |
420 | "AREA:r1".$color{"color17"}."A0:30-70 ms", | |
421 | "AREA:r0".$color{"color12"}."A0:<30 ms\\j", | |
323208ea | 422 | "COMMENT:".sprintf("%-15s",$Lang::tr{'maximal'}), |
6257cba2 CS |
423 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), |
424 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
425 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
a332b303 CS |
426 | "LINE1:roundtrip#707070:", |
427 | "GPRINT:roundtrip:MAX:%3.2lf ms", | |
428 | "GPRINT:roundtrip:AVERAGE:%3.2lf ms", | |
429 | "GPRINT:roundtrip:MIN:%3.2lf ms", | |
430 | "GPRINT:roundtrip:LAST:%3.2lf ms\\j"); | |
431 | $ERROR = RRDs::error; | |
432 | print "Error in RRD::graph for Link Quality: $ERROR\n" if $ERROR; | |
350b52c5 CS |
433 | } |
434 | ||
6257cba2 CS |
435 | # Generate the Hdd Graph for the current period of time for values given by collecd |
436 | ||
350b52c5 | 437 | sub updatehddgraph { |
cce90b0b | 438 | |
350b52c5 CS |
439 | my $disk = $_[0]; |
440 | my $period = $_[1]; | |
441 | ||
442 | RRDs::graph ("$graphs/hddtemp-$disk-$period.png", | |
fbfdb241 | 443 | "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", |
6257cba2 | 444 | "--alt-y-grid", "-w 600", "-h 125", |
350b52c5 CS |
445 | "--color", "SHADEA".$color{"color19"}, |
446 | "--color", "SHADEB".$color{"color19"}, | |
447 | "--color", "BACK".$color{"color21"}, | |
af95dec5 | 448 | "-t $disk $Lang::tr{'harddisk temperature'} $Lang::tr{'graph per'} $Lang::tr{$period}", |
350b52c5 | 449 | "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE", |
471a46f7 CS |
450 | "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE", |
451 | "CDEF:st=standby,INF,*", | |
e1e3dbe5 CS |
452 | "AREA:st".$color{"color20"}."A0:standby", |
453 | "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j", | |
0edf2f61 CS |
454 | "COMMENT:$Lang::tr{'maximal'}", |
455 | "COMMENT:$Lang::tr{'average'}", | |
456 | "COMMENT:$Lang::tr{'minimal'}", | |
457 | "COMMENT:$Lang::tr{'current'}\\j", | |
a28fdc01 CS |
458 | "GPRINT:temperature:MAX:%3.0lf Grad C", |
459 | "GPRINT:temperature:AVERAGE:%3.0lf Grad C", | |
460 | "GPRINT:temperature:MIN:%3.0lf Grad C", | |
461 | "GPRINT:temperature:LAST:%3.0lf Grad C\\j", | |
350b52c5 | 462 | ); |
b4af7142 | 463 | $ERROR = RRDs::error; |
350b52c5 CS |
464 | print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR; |
465 | } | |
466 | ||
6257cba2 CS |
467 | # Generate the QoS Graph for the current period of time |
468 | ||
0b1641db CS |
469 | sub overviewgraph { |
470 | ||
471 | my $period = $_[0]; | |
472 | my $periodstring; | |
473 | my $description; | |
474 | my %qossettings = (); | |
475 | &General::readhash("${General::swroot}/qos/settings", \%qossettings); | |
476 | my $classentry = ""; | |
477 | my @classes = (); | |
478 | my @classline = (); | |
479 | my $classfile = "/var/ipfire/qos/classes"; | |
b4af7142 | 480 | |
0b1641db | 481 | $qossettings{'DEV'} = $_[1]; |
b4af7142 | 482 | if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) { |
0b1641db | 483 | $qossettings{'CLASSPRFX'} = '1'; |
b4af7142 | 484 | } else { |
0b1641db CS |
485 | $qossettings{'CLASSPRFX'} = '2'; |
486 | } | |
b4af7142 | 487 | |
0b1641db CS |
488 | if ( $period ne '3240' ){ $periodstring = "-1$period";}else{ $periodstring = "-".$period;} |
489 | if ( $period ne '3240' ){ $description = "-t $Lang::tr{'Utilization on'} ($qossettings{'DEV'}) ($Lang::tr{'graph per'} $Lang::tr{$period})";}else{ $description = "-t $Lang::tr{'Utilization on'} ($qossettings{'DEV'})";} | |
b4af7142 | 490 | |
0b1641db CS |
491 | my $ERROR=""; |
492 | my $count="1"; | |
493 | my $color="#000000"; | |
494 | my @command=("/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'DEV'}-$period.png", | |
fbfdb241 | 495 | "--start", $periodstring, "-aPNG", "-i", "-z", "-W www.ipfire.org", |
6257cba2 | 496 | "--alt-y-grid", "-w 600", "-h 125", "-r", "-v $Lang::tr{'bytes per second'}", |
0b1641db CS |
497 | "--color", "SHADEA".$color{"color19"}, |
498 | "--color", "SHADEB".$color{"color19"}, | |
499 | "--color", "BACK".$color{"color21"}, | |
6257cba2 CS |
500 | "COMMENT:".sprintf("%-28s",$Lang::tr{'caption'}), |
501 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
502 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
503 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
504 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
0b1641db CS |
505 | $description |
506 | ); | |
507 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; | |
508 | @classes = <FILE>; | |
509 | close FILE; | |
510 | foreach $classentry (sort @classes) | |
511 | { | |
512 | @classline = split( /\;/, $classentry ); | |
513 | if ( $classline[0] eq $qossettings{'DEV'} ) | |
514 | { | |
515 | $color=random_hex_color(6); | |
fbfdb241 | 516 | push(@command, "DEF:$classline[1]=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE"); |
0b1641db CS |
517 | |
518 | if ($count eq "1") { | |
359179f3 | 519 | push(@command, "AREA:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8])); |
0b1641db | 520 | } else { |
359179f3 CS |
521 | push(@command, "STACK:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8])); |
522 | ||
0b1641db | 523 | } |
6257cba2 CS |
524 | push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps"); |
525 | push(@command, "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps"); | |
526 | push(@command, "GPRINT:$classline[1]:MIN:%8.1lf %sBps"); | |
527 | push(@command, "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j"); | |
0b1641db CS |
528 | $count++; |
529 | } | |
530 | } | |
531 | RRDs::graph (@command); | |
532 | $ERROR = RRDs::error; | |
533 | print "$ERROR"; | |
534 | } | |
535 | ||
6257cba2 | 536 | # Generate the Temperature Graph for the current period of time for values given by collecd and mbmon |
e1e3dbe5 CS |
537 | |
538 | sub updatehwtempgraph { | |
539 | ||
540 | my $period = $_[0]; | |
541 | ||
542 | my @command = ("$graphs/mbmon-hwtemp-$period.png", | |
543 | "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", | |
6257cba2 | 544 | "--alt-y-grid", "-w 600", "-h 125", |
e1e3dbe5 CS |
545 | "--color", "SHADEA".$color{"color19"},"--color", |
546 | "SHADEB".$color{"color19"},"--color", | |
547 | "BACK".$color{"color21"}, | |
548 | "-t $Lang::tr{'mbmon temp'} $Lang::tr{'graph per'} $Lang::tr{$period}"); | |
549 | ||
550 | foreach(@mbmongraphs){ | |
551 | chomp($_); | |
552 | if ( $_ =~ /temperature/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE"); | |
553 | } | |
554 | } | |
8c55860f | 555 | push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j"); |
e1e3dbe5 CS |
556 | foreach(@mbmongraphs){ |
557 | chomp($_); | |
558 | if ( $_ =~ /temperature/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}), | |
559 | "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%3.2lf C","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":LAST:%3.2lf C\\j",);} | |
560 | } | |
561 | RRDs::graph (@command); | |
562 | $ERROR = RRDs::error; | |
563 | print "$ERROR"; | |
564 | } | |
565 | ||
6257cba2 CS |
566 | # Generate the Voltage Graph for the current period of time for values given by collecd and mbmon |
567 | ||
e1e3dbe5 CS |
568 | sub updatehwvoltgraph { |
569 | ||
570 | my $period = $_[0]; | |
571 | ||
572 | my @command = ("$graphs/mbmon-hwvolt-$period.png", | |
573 | "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", | |
6257cba2 | 574 | "--alt-y-grid", "-w 600", "-h 125", |
e1e3dbe5 CS |
575 | "--color", "SHADEA".$color{"color19"},"--color", |
576 | "SHADEB".$color{"color19"},"--color", | |
577 | "BACK".$color{"color21"}, | |
578 | "-t $Lang::tr{'mbmon volt'} $Lang::tr{'graph per'} $Lang::tr{$period}"); | |
579 | ||
580 | foreach(@mbmongraphs){ | |
581 | chomp($_); | |
582 | if ( $_ =~ /voltage/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE");} | |
583 | } | |
8c55860f | 584 | push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j"); |
e1e3dbe5 CS |
585 | foreach(@mbmongraphs){ |
586 | chomp($_); | |
587 | if ( $_ =~ /voltage/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}), | |
588 | "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%3.2lf V","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":LAST:%3.2lf V\\j",);} | |
589 | } | |
590 | RRDs::graph (@command); | |
591 | $ERROR = RRDs::error; | |
592 | print "$ERROR"; | |
593 | } | |
594 | ||
6257cba2 CS |
595 | # Generate the Load Graph for the current period of time for values given by collecd and mbmon |
596 | ||
e1e3dbe5 CS |
597 | sub updatehwfangraph { |
598 | ||
599 | my $period = $_[0]; | |
600 | ||
601 | my @command = ("$graphs/mbmon-hwfan-$period.png", | |
602 | "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", | |
6257cba2 | 603 | "--alt-y-grid", "-w 600", "-h 125", |
e1e3dbe5 CS |
604 | "--color", "SHADEA".$color{"color19"},"--color", |
605 | "SHADEB".$color{"color19"},"--color", | |
606 | "BACK".$color{"color21"}, | |
607 | "-t $Lang::tr{'mbmon fan'} $Lang::tr{'graph per'} $Lang::tr{$period}"); | |
608 | ||
609 | foreach(@mbmongraphs){ | |
610 | chomp($_); | |
611 | if ( $_ =~ /fanspeed/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"DEF:".$mbmonsettings{'LABEL-'.$name[0]}."=$rrdlog/collectd/localhost/mbmon/".$_.":value:AVERAGE");} | |
612 | } | |
8c55860f | 613 | push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j"); |
e1e3dbe5 CS |
614 | foreach(@mbmongraphs){ |
615 | chomp($_); | |
616 | if ( $_ =~ /fanspeed/ ) {my @name=split(/\./,$_);if ( $mbmonsettings{'LINE-'.$name[0]} eq "off" ){next;}push(@command,"LINE3:".$mbmonsettings{'LABEL-'.$name[0]}.random_hex_color(6)."A0:".sprintf("%-25s",$mbmonsettings{'LABEL-'.$name[0]}), | |
617 | "GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MAX:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":AVERAGE:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":MIN:%5.0lf RPM","GPRINT:".$mbmonsettings{'LABEL-'.$name[0]}.":LAST:%5.0lf RPM\\j",);} | |
618 | } | |
619 | RRDs::graph (@command); | |
620 | $ERROR = RRDs::error; | |
621 | print "$ERROR"; | |
622 | } | |
6257cba2 CS |
623 | |
624 | # Generate a random color, used by Qos Graph to be independent from the amount of values | |
625 | ||
626 | sub random_hex_color { | |
627 | my $size = shift; | |
628 | $size = 6 if $size !~ /^3|6$/; | |
629 | my @hex = ( 0 .. 9, 'a' .. 'f' ); | |
630 | my @color; | |
631 | push @color, @hex[rand(@hex)] for 1 .. $size; | |
632 | return join('', '#', @color); | |
633 | } |