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