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