]>
Commit | Line | Data |
---|---|---|
3961e831 AF |
1 | #!/usr/bin/perl |
2 | # Generate Graphs exported from Makegraphs to minimize system load an only generate the Graphs when displayed | |
4e481c3a CS |
3 | ############################################################################### |
4 | # # | |
5 | # IPFire.org - A linux based firewall # | |
0d08de33 | 6 | # Copyright (C) 2005-2010 IPFire Team # |
4e481c3a CS |
7 | # # |
8 | # This program is free software: you can redistribute it and/or modify # | |
9 | # it under the terms of the GNU General Public License as published by # | |
10 | # the Free Software Foundation, either version 3 of the License, or # | |
11 | # (at your option) any later version. # | |
12 | # # | |
13 | # This program is distributed in the hope that it will be useful, # | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
16 | # GNU General Public License for more details. # | |
17 | # # | |
18 | # You should have received a copy of the GNU General Public License # | |
19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
20 | # # | |
21 | ############################################################################### | |
3961e831 AF |
22 | |
23 | package Graphs; | |
24 | ||
25 | use strict; | |
26 | use RRDs; | |
27 | ||
28 | require '/var/ipfire/general-functions.pl'; | |
29 | require "${General::swroot}/lang.pl"; | |
30 | require "${General::swroot}/header.pl"; | |
31 | ||
910f1e84 LAH |
32 | # Graph image size in pixel |
33 | our %image_size = ('width' => 910, 'height' => 300); | |
34 | ||
35 | # List of all available time ranges | |
36 | our @time_ranges = ("hour", "day", "week", "month", "year"); | |
37 | ||
3961e831 | 38 | my $ERROR; |
3961e831 | 39 | |
a249ccd2 MT |
40 | my @GRAPH_ARGS = ( |
41 | # Output format | |
42 | "--imgformat", "PNG", | |
43 | ||
44 | # No border | |
45 | "--border", "0", | |
46 | ||
47 | # For a more 'organic' look | |
48 | "--slope-mode", | |
49 | ||
50 | # HxW define the size of the output image | |
51 | "--full-size-mode", | |
52 | ||
53 | # Watermark | |
54 | "-W www.ipfire.org", | |
55 | ||
56 | # Default size | |
910f1e84 LAH |
57 | "-w $image_size{'width'}", |
58 | "-h $image_size{'height'}", | |
a249ccd2 MT |
59 | |
60 | # Use alternative grid | |
61 | "--alt-y-grid", | |
62 | ); | |
63 | ||
3961e831 AF |
64 | # Read the global settings files to get the current theme and after this load |
65 | # colors for this theme | |
66 | ||
67 | my %color = (); | |
68 | my %mainsettings = (); | |
69 | my %sensorsettings = (); | |
70 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
71 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
72 | ||
bcad0fd0 CS |
73 | if ( $mainsettings{'RRDLOG'} eq "" ){ |
74 | $mainsettings{'RRDLOG'}="/var/log/rrd"; | |
75 | &General::writehash("${General::swroot}/main/settings", \%mainsettings); | |
76 | } | |
77 | ||
3961e831 AF |
78 | # If the collection deamon is working and collecting lm_sensors data there will be |
79 | # some data source named after a common scheme, with the sensorssettingsfile | |
80 | # the user is able to deactivate some of this parameters, in case not to show | |
2d281532 CS |
81 | # false collected values may be disable. The user has the ability to enter |
82 | # custom graph names in order to change temp0 to cpu or motherboard | |
3961e831 | 83 | |
3961e831 AF |
84 | my $count = 0; |
85 | my @sensorsgraphs = (); | |
0d08de33 | 86 | my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/ 2>/dev/null`; |
1c163c04 | 87 | foreach (@sensorsdir){ |
3961e831 AF |
88 | chomp($_);chop($_); |
89 | foreach (`ls $_/*`){ | |
90 | chomp($_); | |
91 | push(@sensorsgraphs,$_); | |
92 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
93 | my $label = $2.$3;$label=~ s/-//g; | |
94 | $sensorsettings{'LABEL-'.$label}="$label"; | |
95 | $sensorsettings{'LINE-'.$label}="checked"; | |
96 | } | |
97 | } | |
98 | ||
99 | &General::readhash("${General::swroot}/sensors/settings", \%sensorsettings); | |
4e481c3a CS |
100 | |
101 | # Generate a nice box for selection of time range in graphs | |
2d281532 | 102 | # this will generate a nice iframe for the cgi every klick for |
4e481c3a | 103 | # the graph will be handled inside the iframe |
2d281532 | 104 | # 0 is the cgi refering to |
4e481c3a CS |
105 | # 1 is the graph name |
106 | # 2 is the time range for the graph | |
107 | # 3 if given is the height of the iframe default if nothing is given | |
108 | ||
109 | sub makegraphbox { | |
4e481c3a | 110 | print "<center>"; |
2d0adb74 | 111 | print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>"; |
4e481c3a | 112 | print " - "; |
2d0adb74 | 113 | print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>"; |
4e481c3a | 114 | print " - "; |
2d0adb74 | 115 | print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>"; |
4e481c3a | 116 | print " - "; |
2d0adb74 | 117 | print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>"; |
4e481c3a | 118 | print " - "; |
2d0adb74 | 119 | print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>"; |
af433268 | 120 | print "<br></center>"; |
7cbdd31d | 121 | print "<iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>"; |
3961e831 AF |
122 | } |
123 | ||
124 | # Generate the CPU Graph for the current period of time for values given by | |
4e481c3a | 125 | # collectd we are now able to handle any kind of cpucount |
3961e831 AF |
126 | |
127 | sub updatecpugraph { | |
0d08de33 | 128 | my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`; |
4e481c3a CS |
129 | my $period = $_[0]; |
130 | my @command = ( | |
a249ccd2 | 131 | @GRAPH_ARGS, |
4e481c3a CS |
132 | "-", |
133 | "--start", | |
134 | "-1".$period, | |
4e481c3a CS |
135 | "-l 0", |
136 | "-u 100", | |
137 | "-r", | |
527a5a77 | 138 | "-t ".$Lang::tr{'cpu usage per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
139 | "-v ".$Lang::tr{'percentage'}, |
140 | "--color=SHADEA".$color{"color19"}, | |
141 | "--color=SHADEB".$color{"color19"}, | |
2d281532 CS |
142 | "--color=BACK".$color{"color21"}, |
143 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), | |
144 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
145 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
146 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
147 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" | |
4e481c3a CS |
148 | ); |
149 | ||
150 | my $nice = "CDEF:nice="; | |
151 | my $interrupt = "CDEF:interrupt="; | |
152 | my $steal = "CDEF:steal="; | |
153 | my $user = "CDEF:user="; | |
154 | my $system = "CDEF:system="; | |
155 | my $idle = "CDEF:idle="; | |
156 | my $iowait = "CDEF:iowait="; | |
157 | my $irq = "CDEF:irq="; | |
158 | my $addstring = ""; | |
159 | ||
160 | for(my $i = 0; $i < $cpucount; $i++) { | |
bcad0fd0 CS |
161 | push(@command,"DEF:iowait".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-wait.rrd:value:AVERAGE" |
162 | ,"DEF:nice".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-nice.rrd:value:AVERAGE" | |
163 | ,"DEF:interrupt".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-interrupt.rrd:value:AVERAGE" | |
164 | ,"DEF:steal".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-steal.rrd:value:AVERAGE" | |
165 | ,"DEF:user".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-user.rrd:value:AVERAGE" | |
166 | ,"DEF:system".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-system.rrd:value:AVERAGE" | |
167 | ,"DEF:idle".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-idle.rrd:value:AVERAGE" | |
168 | ,"DEF:irq".$i."=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpu-".$i."/cpu-softirq.rrd:value:AVERAGE"); | |
169 | ||
4e481c3a CS |
170 | $nice .= "nice".$i.","; |
171 | $interrupt .= "interrupt".$i.","; | |
172 | $steal .= "steal".$i.","; | |
173 | $user .= "user".$i.","; | |
174 | $system .= "system".$i.","; | |
175 | $idle .= "idle".$i.","; | |
176 | $iowait .= "iowait".$i.","; | |
177 | $irq .= "irq".$i.","; | |
0950b1ec | 178 | } |
4e481c3a CS |
179 | |
180 | for(my $i = 2; $i < $cpucount; $i++) { | |
6fc36255 | 181 | $addstring .= "ADDNAN,"; |
0950b1ec | 182 | } |
4e481c3a | 183 | |
0ed623d0 CS |
184 | if ( $cpucount > 1){ |
185 | $addstring .= "+"; | |
186 | push(@command,$nice.$addstring | |
187 | ,$interrupt.$addstring | |
188 | ,$steal.$addstring | |
189 | ,$user.$addstring | |
190 | ,$system.$addstring | |
191 | ,$idle.$addstring | |
192 | ,$iowait.$addstring | |
193 | ,$irq.$addstring); | |
194 | }else{ | |
195 | chop($nice),chop($interrupt),chop($steal),chop($user),chop($system),chop($idle),chop($iowait),chop($irq); | |
196 | push(@command,$nice,$interrupt,$steal,$user,$system,$idle,$iowait,$irq); | |
197 | } | |
bcad0fd0 | 198 | |
6fc36255 | 199 | push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN,ADDNAN" |
bcad0fd0 CS |
200 | ,"CDEF:userpct=100,user,total,/,*" |
201 | ,"CDEF:nicepct=100,nice,total,/,*" | |
202 | ,"CDEF:interruptpct=100,interrupt,total,/,*" | |
203 | ,"CDEF:stealpct=100,steal,total,/,*" | |
204 | ,"CDEF:systempct=100,system,total,/,*" | |
205 | ,"CDEF:idlepct=100,idle,total,/,*" | |
206 | ,"CDEF:iowaitpct=100,iowait,total,/,*" | |
207 | ,"CDEF:irqpct=100,irq,total,/,*" | |
208 | ,"AREA:iowaitpct".$color{"color14"}.":".sprintf("%-25s",$Lang::tr{'cpu iowait usage'}) | |
209 | ,"GPRINT:iowaitpct:MAX:%3.2lf%%" | |
210 | ,"GPRINT:iowaitpct:AVERAGE:%3.2lf%%" | |
211 | ,"GPRINT:iowaitpct:MIN:%3.2lf%%" | |
212 | ,"GPRINT:iowaitpct:LAST:%3.2lf%%\\j" | |
213 | ,"STACK:irqpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'cpu irq usage'}) | |
214 | ,"GPRINT:irqpct:MAX:%3.2lf%%" | |
215 | ,"GPRINT:irqpct:AVERAGE:%3.2lf%%" | |
216 | ,"GPRINT:irqpct:MIN:%3.2lf%%" | |
217 | ,"GPRINT:irqpct:LAST:%3.2lf%%\\j" | |
218 | ,"STACK:nicepct".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr{'cpu nice usage'}) | |
219 | ,"GPRINT:nicepct:MAX:%3.2lf%%" | |
220 | ,"GPRINT:nicepct:AVERAGE:%3.2lf%%" | |
221 | ,"GPRINT:nicepct:MIN:%3.2lf%%" | |
222 | ,"GPRINT:nicepct:LAST:%3.2lf%%\\j" | |
223 | ,"STACK:interruptpct".$color{"color15"}."A0:".sprintf("%-25s",$Lang::tr{'cpu interrupt usage'}) | |
224 | ,"GPRINT:interruptpct:MAX:%3.2lf%%" | |
225 | ,"GPRINT:interruptpct:AVERAGE:%3.2lf%%" | |
226 | ,"GPRINT:interruptpct:MIN:%3.2lf%%" | |
227 | ,"GPRINT:interruptpct:LAST:%3.2lf%%\\j" | |
228 | ,"STACK:stealpct".$color{"color18"}."A0:".sprintf("%-25s",$Lang::tr{'cpu steal usage'}) | |
229 | ,"GPRINT:stealpct:MAX:%3.2lf%%" | |
230 | ,"GPRINT:stealpct:AVERAGE:%3.2lf%%" | |
231 | ,"GPRINT:stealpct:MIN:%3.2lf%%" | |
232 | ,"GPRINT:stealpct:LAST:%3.2lf%%\\j" | |
233 | ,"STACK:userpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'cpu user usage'}) | |
33954320 | 234 | ,"GPRINT:userpct:MAX:%3.1lf%%" |
bcad0fd0 CS |
235 | ,"GPRINT:userpct:AVERAGE:%3.2lf%%" |
236 | ,"GPRINT:userpct:MIN:%3.2lf%%" | |
237 | ,"GPRINT:userpct:LAST:%3.2lf%%\\j" | |
cb614898 | 238 | ,"STACK:systempct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cpu system usage'}) |
bcad0fd0 CS |
239 | ,"GPRINT:systempct:MAX:%3.2lf%%" |
240 | ,"GPRINT:systempct:AVERAGE:%3.2lf%%" | |
241 | ,"GPRINT:systempct:MIN:%3.2lf%%" | |
242 | ,"GPRINT:systempct:LAST:%3.2lf%%\\j" | |
243 | ,"STACK:idlepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'cpu idle usage'}) | |
244 | ,"GPRINT:idlepct:MAX:%3.2lf%%" | |
245 | ,"GPRINT:idlepct:AVERAGE:%3.2lf%%" | |
246 | ,"GPRINT:idlepct:MIN:%3.2lf%%" | |
247 | ,"GPRINT:idlepct:LAST:%3.2lf%%\\j"); | |
0950b1ec AF |
248 | |
249 | RRDs::graph (@command); | |
4e481c3a CS |
250 | $ERROR = RRDs::error; |
251 | print "Error in RRD::graph for cpu: ".$ERROR."\n" if $ERROR; | |
0950b1ec AF |
252 | } |
253 | ||
3961e831 AF |
254 | # Generate the Load Graph for the current period of time for values given by collecd |
255 | ||
256 | sub updateloadgraph { | |
4e481c3a CS |
257 | my $period = $_[0]; |
258 | RRDs::graph( | |
a249ccd2 | 259 | @GRAPH_ARGS, |
4e481c3a CS |
260 | "-", |
261 | "--start", | |
262 | "-1".$period, | |
4e481c3a CS |
263 | "-l 0", |
264 | "-r", | |
a0774e3c | 265 | "-t ".$Lang::tr{'uptime load average'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
266 | "-v ".$Lang::tr{'processes'}, |
267 | "--color=SHADEA".$color{"color19"}, | |
268 | "--color=SHADEB".$color{"color19"}, | |
269 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 CS |
270 | "DEF:load1=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:shortterm:AVERAGE", |
271 | "DEF:load5=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:midterm:AVERAGE", | |
272 | "DEF:load15=".$mainsettings{'RRDLOG'}."/collectd/localhost/load/load.rrd:longterm:AVERAGE", | |
b6adeb23 | 273 | "AREA:load1".$color{"color13"}."A0:1 ".$Lang::tr{'minute'}, |
4e481c3a | 274 | "GPRINT:load1:LAST:%5.2lf", |
b6adeb23 | 275 | "AREA:load5".$color{"color18"}."A0:5 ".$Lang::tr{'minutes'}, |
4e481c3a | 276 | "GPRINT:load5:LAST:%5.2lf", |
b6adeb23 | 277 | "AREA:load15".$color{"color14"}."A0:15 ".$Lang::tr{'minutes'}, |
4e481c3a CS |
278 | "GPRINT:load15:LAST:%5.2lf\\j", |
279 | "LINE1:load5".$color{"color13"}, | |
280 | "LINE1:load1".$color{"color18"}, | |
281 | ); | |
282 | $ERROR = RRDs::error; | |
283 | print "Error in RRD::graph for load: ".$ERROR."\n" if $ERROR; | |
284 | } | |
285 | ||
286 | # Generate the Memory Graph for the current period of time for values given by collecd | |
287 | ||
288 | sub updatememorygraph { | |
289 | my $period = $_[0]; | |
290 | RRDs::graph( | |
a249ccd2 | 291 | @GRAPH_ARGS, |
4e481c3a CS |
292 | "-", |
293 | "--start", | |
294 | "-1".$period, | |
4e481c3a CS |
295 | "-l 0", |
296 | "-u 100", | |
297 | "-r", | |
527a5a77 | 298 | "-t ".$Lang::tr{'memory usage per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
299 | "-v ".$Lang::tr{'percentage'}, |
300 | "--color=SHADEA".$color{"color19"}, | |
301 | "--color=SHADEB".$color{"color19"}, | |
302 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 CS |
303 | "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-used.rrd:value:AVERAGE", |
304 | "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-free.rrd:value:AVERAGE", | |
305 | "DEF:buffer=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-buffered.rrd:value:AVERAGE", | |
306 | "DEF:cache=".$mainsettings{'RRDLOG'}."/collectd/localhost/memory/memory-cached.rrd:value:AVERAGE", | |
4e481c3a CS |
307 | "CDEF:total=used,free,cache,buffer,+,+,+", |
308 | "CDEF:usedpct=used,total,/,100,*", | |
309 | "CDEF:bufferpct=buffer,total,/,100,*", | |
310 | "CDEF:cachepct=cache,total,/,100,*", | |
311 | "CDEF:freepct=free,total,/,100,*", | |
312 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), | |
313 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
314 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
315 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
316 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
317 | "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used memory'}), | |
318 | "GPRINT:usedpct:MAX:%3.2lf%%", | |
319 | "GPRINT:usedpct:AVERAGE:%3.2lf%%", | |
320 | "GPRINT:usedpct:MIN:%3.2lf%%", | |
321 | "GPRINT:usedpct:LAST:%3.2lf%%\\j", | |
322 | "STACK:bufferpct".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'buffered memory'}), | |
323 | "GPRINT:bufferpct:MAX:%3.2lf%%", | |
324 | "GPRINT:bufferpct:AVERAGE:%3.2lf%%", | |
325 | "GPRINT:bufferpct:MIN:%3.2lf%%", | |
326 | "GPRINT:bufferpct:LAST:%3.2lf%%\\j", | |
327 | "STACK:cachepct".$color{"color14"}."A0:".sprintf("%-25s",$Lang::tr{'cached memory'}), | |
328 | "GPRINT:cachepct:MAX:%3.2lf%%", | |
329 | "GPRINT:cachepct:AVERAGE:%3.2lf%%", | |
330 | "GPRINT:cachepct:MIN:%3.2lf%%", | |
331 | "GPRINT:cachepct:LAST:%3.2lf%%\\j", | |
332 | "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free memory'}), | |
333 | "GPRINT:freepct:MAX:%3.2lf%%", | |
334 | "GPRINT:freepct:AVERAGE:%3.2lf%%", | |
335 | "GPRINT:freepct:MIN:%3.2lf%%", | |
336 | "GPRINT:freepct:LAST:%3.2lf%%\\j", | |
337 | ); | |
338 | $ERROR = RRDs::error; | |
339 | print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; | |
340 | } | |
341 | ||
342 | # Generate the Swap Graph for the current period of time for values given by collecd | |
343 | ||
344 | sub updateswapgraph { | |
345 | my $period = $_[0]; | |
346 | RRDs::graph( | |
a249ccd2 | 347 | @GRAPH_ARGS, |
4e481c3a CS |
348 | "-", |
349 | "--start", | |
350 | "-1".$period, | |
4e481c3a CS |
351 | "-l 0", |
352 | "-u 100", | |
353 | "-r", | |
527a5a77 | 354 | "-t ".$Lang::tr{'swap usage per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
355 | "-v ".$Lang::tr{'percentage'}, |
356 | "--color=SHADEA".$color{"color19"}, | |
357 | "--color=SHADEB".$color{"color19"}, | |
358 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 | 359 | "DEF:free=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-free.rrd:value:AVERAGE", |
8999c884 | 360 | "DEF:used=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-used.rrd:value:AVERAGE", |
bcad0fd0 | 361 | "DEF:cached=".$mainsettings{'RRDLOG'}."/collectd/localhost/swap/swap-cached.rrd:value:AVERAGE", |
4e481c3a CS |
362 | "CDEF:total=used,free,cached,+,+", |
363 | "CDEF:usedpct=100,used,total,/,*", | |
364 | "CDEF:freepct=100,free,total,/,*", | |
365 | "CDEF:cachedpct=100,cached,total,/,*", | |
366 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), | |
367 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
368 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
369 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
370 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
371 | "AREA:usedpct".$color{"color11"}."A0:".sprintf("%-25s",$Lang::tr{'used swap'}), | |
372 | "GPRINT:usedpct:MAX:%3.2lf%%", | |
373 | "GPRINT:usedpct:AVERAGE:%3.2lf%%", | |
374 | "GPRINT:usedpct:MIN:%3.2lf%%", | |
375 | "GPRINT:usedpct:LAST:%3.2lf%%\\j", | |
4e481c3a CS |
376 | "STACK:cachedpct".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'cached swap'}), |
377 | "GPRINT:cachedpct:MAX:%3.2lf%%", | |
378 | "GPRINT:cachedpct:AVERAGE:%3.2lf%%", | |
379 | "GPRINT:cachedpct:MIN:%3.2lf%%", | |
380 | "GPRINT:cachedpct:LAST:%3.2lf%%\\j", | |
8999c884 CS |
381 | "STACK:freepct".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'free swap'}), |
382 | "GPRINT:freepct:MAX:%3.2lf%%", | |
383 | "GPRINT:freepct:AVERAGE:%3.2lf%%", | |
384 | "GPRINT:freepct:MIN:%3.2lf%%", | |
385 | "GPRINT:freepct:LAST:%3.2lf%%\\j", | |
4e481c3a CS |
386 | ); |
387 | $ERROR = RRDs::error; | |
388 | print "Error in RRD::graph for memory: ".$ERROR."\n" if $ERROR; | |
389 | } | |
390 | ||
391 | # Generate the Process Cpu Graph for the current period of time for values given by collecd | |
392 | ||
393 | sub updateprocessescpugraph { | |
1c163c04 | 394 | my @processesgraph = getprocesses(); |
4e481c3a CS |
395 | my $period = $_[0]; |
396 | my $count="0"; | |
397 | ||
398 | my @command = ( | |
a249ccd2 | 399 | @GRAPH_ARGS, |
4e481c3a CS |
400 | "-", |
401 | "--start", | |
402 | "-1".$period, | |
4e481c3a CS |
403 | "-l 0", |
404 | "-r", | |
527a5a77 | 405 | "-t ".$Lang::tr{'processes'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
406 | "--color=SHADEA".$color{"color19"}, |
407 | "--color=SHADEB".$color{"color19"}, | |
408 | "--color=BACK".$color{"color21"} | |
409 | ); | |
410 | ||
411 | foreach(@processesgraph){ | |
412 | chomp($_);my @name=split(/\-/,$_);chop($name[1]); | |
413 | push(@command,"DEF:".$name[1]."user=".$_."ps_cputime.rrd:user:AVERAGE"); | |
414 | push(@command,"DEF:".$name[1]."system=".$_."ps_cputime.rrd:syst:AVERAGE"); | |
415 | push(@command,"CDEF:".$name[1]."=".$name[1]."user,".$name[1]."system,+"); | |
416 | } | |
417 | ||
418 | push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j"); | |
419 | ||
e06986e8 | 420 | my $colorIndex = 0; |
4e481c3a | 421 | foreach(@processesgraph){ |
e06986e8 AH |
422 | my $colorIndex = 10 + $count % 15; |
423 | my $color="$color{\"color$colorIndex\"}"; | |
4e481c3a CS |
424 | chomp($_);my @name=split(/\-/,$_);chop($name[1]); |
425 | if ($count eq "0"){ | |
e06986e8 | 426 | push(@command,"AREA:".$name[1].$color."A0:".$name[1]); |
4e481c3a | 427 | }else{ |
e06986e8 | 428 | push(@command,"STACK:".$name[1].$color."A0:".$name[1]); |
4e481c3a CS |
429 | } |
430 | $count++; | |
431 | } | |
432 | ||
433 | RRDs::graph (@command); | |
434 | $ERROR = RRDs::error; | |
435 | print "Error in RRD::graph for processes: ".$ERROR."\n" if $ERROR; | |
3961e831 AF |
436 | } |
437 | ||
4e481c3a CS |
438 | # Generate the Process Memory Graph for the current period of time for values given by collecd |
439 | ||
440 | sub updateprocessesmemorygraph { | |
1c163c04 | 441 | my @processesgraph = getprocesses(); |
4e481c3a CS |
442 | my $period = $_[0]; |
443 | my $count="0"; | |
444 | ||
445 | my @command = ( | |
a249ccd2 | 446 | @GRAPH_ARGS, |
4e481c3a CS |
447 | "-", |
448 | "--start", | |
449 | "-1".$period, | |
4e481c3a CS |
450 | "-l 0", |
451 | "-r", | |
527a5a77 | 452 | "-t ".$Lang::tr{'processes'}." ".$Lang::tr{'memory'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
453 | "-v ".$Lang::tr{'bytes'}, |
454 | "--color=SHADEA".$color{"color19"}, | |
455 | "--color=SHADEB".$color{"color19"}, | |
456 | "--color=BACK".$color{"color21"} | |
457 | ); | |
458 | ||
459 | foreach(@processesgraph){ | |
460 | chomp($_);my @name=split(/\-/,$_);chop($name[1]); | |
461 | push(@command,"DEF:".$name[1]."=".$_."ps_rss.rrd:value:AVERAGE"); | |
462 | } | |
463 | ||
464 | push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j"); | |
465 | ||
e06986e8 | 466 | my $colorIndex = 0; |
4e481c3a CS |
467 | foreach(@processesgraph){ |
468 | chomp($_);my @name=split(/\-/,$_);chop($name[1]); | |
e06986e8 AH |
469 | my $colorIndex = 10 + $count % 15; |
470 | my $color="$color{\"color$colorIndex\"}"; | |
4e481c3a | 471 | if ($count eq "0"){ |
e06986e8 | 472 | push(@command,"AREA:".$name[1].$color."A0:".$name[1]); |
4e481c3a | 473 | }else{ |
e06986e8 | 474 | push(@command,"STACK:".$name[1].$color."A0:".$name[1]); |
4e481c3a CS |
475 | } |
476 | $count++; | |
477 | } | |
0950b1ec | 478 | |
4e481c3a CS |
479 | RRDs::graph (@command); |
480 | $ERROR = RRDs::error; | |
481 | print "Error in RRD::graph for processesmemory: ".$ERROR."\n" if $ERROR; | |
3961e831 AF |
482 | } |
483 | ||
484 | # Generate the Disk Graph for the current period of time for values given by collecd | |
485 | ||
486 | sub updatediskgraph { | |
4e481c3a CS |
487 | my $disk = $_[0]; |
488 | my $period = $_[1]; | |
489 | RRDs::graph( | |
a249ccd2 | 490 | @GRAPH_ARGS, |
4e481c3a CS |
491 | "-", |
492 | "--start", | |
493 | "-1".$period, | |
4e481c3a | 494 | "-r", |
03dd66d6 | 495 | "-t ".$disk." ".$Lang::tr{'disk access'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
496 | "-v ".$Lang::tr{'bytes per second'}, |
497 | "--color=SHADEA".$color{"color19"}, | |
498 | "--color=SHADEB".$color{"color19"}, | |
499 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 CS |
500 | "DEF:read=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:read:AVERAGE", |
501 | "DEF:write=".$mainsettings{'RRDLOG'}."/collectd/localhost/disk-$disk/disk_octets.rrd:write:AVERAGE", | |
4e481c3a | 502 | "CDEF:writen=write,-1,*", |
bcad0fd0 | 503 | "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-".$disk.".rrd:standby:AVERAGE", |
4e481c3a | 504 | "CDEF:st=standby,INF,*", |
b6adeb23 | 505 | "CDEF:st1=standby,NEGINF,*", |
4e481c3a CS |
506 | "COMMENT:".sprintf("%-25s",$Lang::tr{'caption'}), |
507 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
508 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
509 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
510 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
511 | "AREA:st".$color{"color20"}."A0:", | |
512 | "AREA:st1".$color{"color20"}."A0:standby\\j", | |
513 | "AREA:read".$color{"color12"}."A0:".sprintf("%-25s",$Lang::tr{'read bytes'}), | |
514 | "GPRINT:read:MAX:%8.1lf %sBps", | |
515 | "GPRINT:read:AVERAGE:%8.1lf %sBps", | |
516 | "GPRINT:read:MIN:%8.1lf %sBps", | |
517 | "GPRINT:read:LAST:%8.1lf %sBps\\j", | |
518 | "AREA:writen".$color{"color13"}."A0:".sprintf("%-25s",$Lang::tr{'written bytes'}), | |
519 | "GPRINT:write:MAX:%8.1lf %sBps", | |
520 | "GPRINT:write:AVERAGE:%8.1lf %sBps", | |
521 | "GPRINT:write:MIN:%8.1lf %sBps", | |
522 | "GPRINT:write:LAST:%8.1lf %sBps\\j", | |
523 | ); | |
524 | $ERROR = RRDs::error; | |
525 | print "Error in RRD::graph for ".$disk.": ".$ERROR."\n" if $ERROR; | |
3961e831 AF |
526 | } |
527 | ||
528 | # Generate the Interface Graph for the current period of time for values given by collecd | |
529 | ||
530 | sub updateifgraph { | |
4e481c3a CS |
531 | my $interface = $_[0]; |
532 | my $period = $_[1]; | |
533 | RRDs::graph( | |
a249ccd2 | 534 | @GRAPH_ARGS, |
4e481c3a CS |
535 | "-", |
536 | "--start", | |
537 | "-1".$period, | |
4e481c3a | 538 | "-r", |
527a5a77 | 539 | "-t ".$Lang::tr{'traffic on'}." ".$interface." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
540 | "-v ".$Lang::tr{'bytes per second'}, |
541 | "--color=SHADEA".$color{"color19"}, | |
542 | "--color=SHADEB".$color{"color19"}, | |
543 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 CS |
544 | "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface/if_octets-".$interface.".rrd:rx:AVERAGE", |
545 | "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/interface/if_octets-".$interface.".rrd:tx:AVERAGE", | |
4e481c3a CS |
546 | "CDEF:outgoingn=outgoing,-1,*", |
547 | "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}), | |
548 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
549 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
550 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
551 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
552 | "AREA:incoming".$color{"color12"}."A0:".sprintf("%-20s",$Lang::tr{'incoming traffic in bytes per second'}), | |
553 | "GPRINT:incoming:MAX:%8.1lf %sBps", | |
554 | "GPRINT:incoming:AVERAGE:%8.1lf %sBps", | |
555 | "GPRINT:incoming:MIN:%8.1lf %sBps", | |
556 | "GPRINT:incoming:LAST:%8.1lf %sBps\\j", | |
5795fc1b AM |
557 | "AREA:outgoingn".$color{"color13"}."A0:".sprintf("%-20s",$Lang::tr{'outgoing traffic in bytes per second'}), |
558 | "GPRINT:outgoing:MAX:%8.1lf %sBps", | |
559 | "GPRINT:outgoing:AVERAGE:%8.1lf %sBps", | |
560 | "GPRINT:outgoing:MIN:%8.1lf %sBps", | |
561 | "GPRINT:outgoing:LAST:%8.1lf %sBps\\j", | |
562 | ); | |
563 | $ERROR = RRDs::error; | |
564 | print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; | |
565 | } | |
c9ac8b80 | 566 | |
5795fc1b AM |
567 | sub updatevpngraph { |
568 | my $interface = $_[0]; | |
569 | my $period = $_[1]; | |
570 | RRDs::graph( | |
a249ccd2 | 571 | @GRAPH_ARGS, |
5795fc1b AM |
572 | "-", |
573 | "--start", | |
574 | "-1".$period, | |
5795fc1b AM |
575 | "-r", |
576 | "-t ".$Lang::tr{'traffic on'}." ".$interface." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, | |
577 | "-v ".$Lang::tr{'bytes per second'}, | |
578 | "--color=SHADEA".$color{"color19"}, | |
579 | "--color=SHADEB".$color{"color19"}, | |
580 | "--color=BACK".$color{"color21"}, | |
c9ac8b80 AM |
581 | "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive.rrd:rx:AVERAGE", |
582 | "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive.rrd:tx:AVERAGE", | |
5795fc1b AM |
583 | "CDEF:outgoingn=outgoing,-1,*", |
584 | "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}), | |
585 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
586 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
587 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
588 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
c9ac8b80 | 589 | "AREA:incoming#00dd00:".sprintf("%-20s",$Lang::tr{'incoming traffic in bytes per second'}), |
5795fc1b AM |
590 | "GPRINT:incoming:MAX:%8.1lf %sBps", |
591 | "GPRINT:incoming:AVERAGE:%8.1lf %sBps", | |
592 | "GPRINT:incoming:MIN:%8.1lf %sBps", | |
593 | "GPRINT:incoming:LAST:%8.1lf %sBps\\j", | |
c9ac8b80 AM |
594 | "AREA:outgoingn#dd0000:".sprintf("%-20s",$Lang::tr{'outgoing traffic in bytes per second'}), |
595 | "GPRINT:outgoing:MAX:%8.1lf %sBps", | |
596 | "GPRINT:outgoing:AVERAGE:%8.1lf %sBps", | |
597 | "GPRINT:outgoing:MIN:%8.1lf %sBps", | |
598 | "GPRINT:outgoing:LAST:%8.1lf %sBps\\j", | |
599 | ); | |
600 | $ERROR = RRDs::error; | |
601 | print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; | |
602 | } | |
603 | ||
604 | sub updatevpnn2ngraph { | |
605 | my $interface = $_[0]; | |
606 | my $period = $_[1]; | |
607 | RRDs::graph( | |
a249ccd2 | 608 | @GRAPH_ARGS, |
c9ac8b80 AM |
609 | "-", |
610 | "--start", | |
611 | "-1".$period, | |
c9ac8b80 AM |
612 | "-r", |
613 | "-t ".$Lang::tr{'traffic on'}." ".$interface." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, | |
614 | "-v ".$Lang::tr{'bytes per second'}, | |
615 | "--color=SHADEA".$color{"color19"}, | |
616 | "--color=SHADEB".$color{"color19"}, | |
617 | "--color=BACK".$color{"color21"}, | |
618 | "DEF:incoming=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-traffic.rrd:rx:AVERAGE", | |
619 | "DEF:outgoing=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-traffic.rrd:tx:AVERAGE", | |
620 | "DEF:overhead_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-overhead.rrd:rx:AVERAGE", | |
621 | "DEF:overhead_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/if_octets_derive-overhead.rrd:tx:AVERAGE", | |
622 | "DEF:compression_in=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression_derive-data_in.rrd:uncompressed:AVERAGE", | |
623 | "DEF:compression_out=".$mainsettings{'RRDLOG'}."/collectd/localhost/openvpn-$interface/compression_derive-data_out.rrd:uncompressed:AVERAGE", | |
624 | "CDEF:outgoingn=outgoing,-1,*", | |
625 | "CDEF:overhead_outn=overhead_out,-1,*", | |
626 | "CDEF:compression_outn=compression_out,-1,*", | |
627 | "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}), | |
628 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
629 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
630 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
631 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
5c3b3bd8 | 632 | "AREA:incoming#00dd00:".sprintf("%-23s",$Lang::tr{'incoming traffic in bytes per second'}), |
c9ac8b80 AM |
633 | "GPRINT:incoming:MAX:%8.1lf %sBps", |
634 | "GPRINT:incoming:AVERAGE:%8.1lf %sBps", | |
635 | "GPRINT:incoming:MIN:%8.1lf %sBps", | |
636 | "GPRINT:incoming:LAST:%8.1lf %sBps\\j", | |
5c3b3bd8 | 637 | "STACK:overhead_in#116B11:".sprintf("%-23s",$Lang::tr{'incoming overhead in bytes per second'}), |
c9ac8b80 AM |
638 | "GPRINT:overhead_in:MAX:%8.1lf %sBps", |
639 | "GPRINT:overhead_in:AVERAGE:%8.1lf %sBps", | |
640 | "GPRINT:overhead_in:MIN:%8.1lf %sBps", | |
641 | "GPRINT:overhead_in:LAST:%8.1lf %sBps\\j", | |
5c3b3bd8 | 642 | "LINE1:compression_in#ff00ff:".sprintf("%-23s",$Lang::tr{'incoming compression in bytes per second'}), |
c9ac8b80 AM |
643 | "GPRINT:compression_in:MAX:%8.1lf %sBps", |
644 | "GPRINT:compression_in:AVERAGE:%8.1lf %sBps", | |
645 | "GPRINT:compression_in:MIN:%8.1lf %sBps", | |
646 | "GPRINT:compression_in:LAST:%8.1lf %sBps\\j", | |
5c3b3bd8 | 647 | "AREA:outgoingn#dd0000:".sprintf("%-23s",$Lang::tr{'outgoing traffic in bytes per second'}), |
4e481c3a CS |
648 | "GPRINT:outgoing:MAX:%8.1lf %sBps", |
649 | "GPRINT:outgoing:AVERAGE:%8.1lf %sBps", | |
650 | "GPRINT:outgoing:MIN:%8.1lf %sBps", | |
651 | "GPRINT:outgoing:LAST:%8.1lf %sBps\\j", | |
5c3b3bd8 | 652 | "STACK:overhead_outn#870C0C:".sprintf("%-23s",$Lang::tr{'outgoing overhead in bytes per second'}), |
c9ac8b80 AM |
653 | "GPRINT:overhead_out:MAX:%8.1lf %sBps", |
654 | "GPRINT:overhead_out:AVERAGE:%8.1lf %sBps", | |
655 | "GPRINT:overhead_out:MIN:%8.1lf %sBps", | |
656 | "GPRINT:overhead_out:LAST:%8.1lf %sBps\\j", | |
5c3b3bd8 | 657 | "LINE1:compression_outn#000000:".sprintf("%-23s",$Lang::tr{'outgoing compression in bytes per second'}), |
c9ac8b80 AM |
658 | "GPRINT:compression_out:MAX:%8.1lf %sBps", |
659 | "GPRINT:compression_out:AVERAGE:%8.1lf %sBps", | |
660 | "GPRINT:compression_out:MIN:%8.1lf %sBps", | |
661 | "GPRINT:compression_out:LAST:%8.1lf %sBps\\j", | |
4e481c3a CS |
662 | ); |
663 | $ERROR = RRDs::error; | |
664 | print "Error in RRD::graph for ".$interface.": ".$ERROR."\n" if $ERROR; | |
3961e831 AF |
665 | } |
666 | ||
667 | # Generate the Firewall Graph for the current period of time for values given by collecd | |
668 | ||
669 | sub updatefwhitsgraph { | |
4e481c3a CS |
670 | my $period = $_[0]; |
671 | RRDs::graph( | |
a249ccd2 | 672 | @GRAPH_ARGS, |
4e481c3a CS |
673 | "-", |
674 | "--start", | |
675 | "-1".$period, | |
4e481c3a | 676 | "-r", |
527a5a77 | 677 | "-t ".$Lang::tr{'firewall hits per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
678 | "-v ".$Lang::tr{'bytes per second'}, |
679 | "--color=SHADEA".$color{"color19"}, | |
680 | "--color=SHADEB".$color{"color19"}, | |
681 | "--color=BACK".$color{"color21"}, | |
94ea1f03 AM |
682 | "DEF:output=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYOUT/ipt_bytes-DROP_OUTPUT.rrd:value:AVERAGE", |
683 | "DEF:input=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYIN/ipt_bytes-DROP_INPUT.rrd:value:AVERAGE", | |
684 | "DEF:forward=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-POLICYFWD/ipt_bytes-DROP_FORWARD.rrd:value:AVERAGE", | |
bcad0fd0 CS |
685 | "DEF:newnotsyn=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-NEWNOTSYN/ipt_bytes-DROP_NEWNOTSYN.rrd:value:AVERAGE", |
686 | "DEF:portscan=".$mainsettings{'RRDLOG'}."/collectd/localhost/iptables-filter-PSCAN/ipt_bytes-DROP_PScan.rrd:value:AVERAGE", | |
94ea1f03 | 687 | "COMMENT:".sprintf("%-26s",$Lang::tr{'caption'}), |
4e481c3a CS |
688 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), |
689 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
94ea1f03 | 690 | "COMMENT:".sprintf("%14s",$Lang::tr{'minimal'}), |
4e481c3a | 691 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", |
e01c49b4 | 692 | "AREA:output".$color{"color25"}."A0:".sprintf("%-25s",$Lang::tr{'firewallhits'}." (OUTPUT)"), |
94ea1f03 AM |
693 | "GPRINT:output:MAX:%8.1lf %sBps", |
694 | "GPRINT:output:AVERAGE:%8.1lf %sBps", | |
695 | "GPRINT:output:MIN:%8.1lf %sBps", | |
696 | "GPRINT:output:LAST:%8.1lf %sBps\\j", | |
e01c49b4 | 697 | "STACK:forward".$color{"color23"}."A0:".sprintf("%-25s",$Lang::tr{'firewallhits'}." (FORWARD)"), |
94ea1f03 AM |
698 | "GPRINT:forward:MAX:%8.1lf %sBps", |
699 | "GPRINT:forward:AVERAGE:%8.1lf %sBps", | |
700 | "GPRINT:forward:MIN:%8.1lf %sBps", | |
701 | "GPRINT:forward:LAST:%8.1lf %sBps\\j", | |
e01c49b4 | 702 | "STACK:input".$color{"color24"}."A0:".sprintf("%-25s",$Lang::tr{'firewallhits'}." (INPUT)"), |
9468a6f7 AM |
703 | "GPRINT:input:MAX:%8.1lf %sBps", |
704 | "GPRINT:input:AVERAGE:%8.1lf %sBps", | |
705 | "GPRINT:input:MIN:%8.1lf %sBps", | |
706 | "GPRINT:input:LAST:%8.1lf %sBps\\j", | |
992f944b | 707 | "STACK:newnotsyn".$color{"color14"}."A0:".sprintf("%-25s","NewNotSYN"), |
94ea1f03 | 708 | "GPRINT:newnotsyn:MAX:%8.1lf %sBps", |
94ea1f03 | 709 | "GPRINT:newnotsyn:AVERAGE:%8.1lf %sBps", |
79131c6e | 710 | "GPRINT:newnotsyn:MIN:%8.1lf %sBps", |
94ea1f03 | 711 | "GPRINT:newnotsyn:LAST:%8.1lf %sBps\\j", |
cb614898 | 712 | "STACK:portscan".$color{"color16"}."A0:".sprintf("%-25s",$Lang::tr{'portscans'}), |
4e481c3a | 713 | "GPRINT:portscan:MAX:%8.1lf %sBps", |
4e481c3a | 714 | "GPRINT:portscan:AVERAGE:%8.1lf %sBps", |
79131c6e | 715 | "GPRINT:portscan:MIN:%8.1lf %sBps", |
4e481c3a CS |
716 | "GPRINT:portscan:LAST:%8.1lf %sBps\\j", |
717 | ); | |
718 | $ERROR = RRDs::error; | |
719 | print "Error in RRD::graph for firewallhits: ".$ERROR."\n" if $ERROR; | |
3961e831 AF |
720 | } |
721 | ||
722 | # Generate the Line Quality Graph for the current period of time for values given by collecd | |
723 | ||
cee25dda | 724 | sub updatepinggraph { |
4e481c3a CS |
725 | my $period = $_[1]; |
726 | my $host = $_[0]; | |
727 | RRDs::graph( | |
a249ccd2 | 728 | @GRAPH_ARGS, |
4e481c3a CS |
729 | "-", |
730 | "--start", | |
731 | "-1".$period, | |
4e481c3a CS |
732 | "-l 0", |
733 | "-r", | |
527a5a77 | 734 | "-t ".$Lang::tr{'linkq'}." ".$host." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
735 | "-v ms", |
736 | "--color=SHADEA".$color{"color19"}, | |
737 | "--color=SHADEB".$color{"color19"}, | |
738 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 | 739 | "DEF:roundtrip=".$mainsettings{'RRDLOG'}."/collectd/localhost/ping/ping-".$host.".rrd:ping:AVERAGE", |
4e481c3a CS |
740 | "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'})."\\j", |
741 | "CDEF:roundavg=roundtrip,PREV(roundtrip),+,2,/", | |
742 | "CDEF:r0=roundtrip,30,MIN", | |
743 | "CDEF:r1=roundtrip,70,MIN", | |
744 | "CDEF:r2=roundtrip,150,MIN", | |
745 | "CDEF:r3=roundtrip,300,MIN", | |
746 | "AREA:roundtrip".$color{"color25"}."A0:>300 ms", | |
747 | "AREA:r3".$color{"color18"}."A0:150-300 ms", | |
748 | "AREA:r2".$color{"color14"}."A0:70-150 ms", | |
749 | "AREA:r1".$color{"color17"}."A0:30-70 ms", | |
750 | "AREA:r0".$color{"color12"}."A0:<30 ms\\j", | |
751 | "COMMENT:$Lang::tr{'maximal'}", | |
752 | "COMMENT:$Lang::tr{'average'}", | |
753 | "COMMENT:$Lang::tr{'minimal'}","COMMENT:$Lang::tr{'current'}\\j", | |
754 | "LINE1:roundtrip#707070:", | |
755 | "GPRINT:roundtrip:MAX:%3.2lf ms", | |
756 | "GPRINT:roundtrip:AVERAGE:%3.2lf ms", | |
757 | "GPRINT:roundtrip:MIN:%3.2lf ms", | |
758 | "GPRINT:roundtrip:LAST:%3.2lf ms\\j", | |
759 | ); | |
760 | $ERROR = RRDs::error; | |
761 | print "Error in RRD::graph for link quality: ".$ERROR."\n" if $ERROR; | |
3961e831 AF |
762 | } |
763 | ||
4e481c3a CS |
764 | sub updatewirelessgraph { |
765 | my $period = $_[1]; | |
766 | my $interface = $_[0]; | |
767 | RRDs::graph( | |
a249ccd2 | 768 | @GRAPH_ARGS, |
4e481c3a CS |
769 | "-", |
770 | "--start", | |
771 | "-1".$period, | |
527a5a77 | 772 | "-t Wireless ".$interface." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
4e481c3a CS |
773 | "-v dBm", |
774 | "--color=SHADEA".$color{"color19"}, | |
775 | "--color=SHADEB".$color{"color19"}, | |
776 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 CS |
777 | "DEF:noise=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_noise.rrd:value:AVERAGE", |
778 | "DEF:power=".$mainsettings{'RRDLOG'}."/collectd/localhost/wireless-".$interface."/signal_power.rrd:value:AVERAGE", | |
4e481c3a CS |
779 | "COMMENT:".sprintf("%-20s",$Lang::tr{'caption'}), |
780 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
781 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
782 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
783 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j", | |
784 | "LINE1:noise".$color{"color11"}."A0:".sprintf("%-20s","Signal Noise Ratio"), | |
785 | "GPRINT:noise:MAX:%5.1lf %sdBm", | |
786 | "GPRINT:noise:AVERAGE:%5.1lf %sdBm", | |
787 | "GPRINT:noise:MIN:%5.1lf %sdBm", | |
788 | "GPRINT:noise:LAST:%5.1lf %sdBm\\j", | |
789 | "LINE1:power".$color{"color12"}."A0:".sprintf("%-20s","Signal Power Ratio"), | |
790 | "GPRINT:power:MAX:%5.1lf %sdBm", | |
791 | "GPRINT:power:AVERAGE:%5.1lf %sdBm", | |
792 | "GPRINT:power:MIN:%5.1lf %sdBm", | |
793 | "GPRINT:power:LAST:%5.1lf %sdBm\\j", | |
794 | ); | |
795 | $ERROR = RRDs::error; | |
796 | print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; | |
797 | } | |
798 | ||
2d281532 | 799 | # Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors |
4e481c3a | 800 | |
2d281532 CS |
801 | sub updatehddgraph { |
802 | my $disk = $_[0]; | |
803 | my $period = $_[1]; | |
804 | RRDs::graph( | |
a249ccd2 | 805 | @GRAPH_ARGS, |
2d281532 CS |
806 | "-", |
807 | "--start", | |
808 | "-1".$period, | |
2d281532 | 809 | "-r", |
527a5a77 | 810 | "-t ".$disk." ".$Lang::tr{'harddisk temperature'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
2d281532 CS |
811 | "-v Celsius", |
812 | "--color=SHADEA".$color{"color19"}, | |
813 | "--color=SHADEB".$color{"color19"}, | |
814 | "--color=BACK".$color{"color21"}, | |
bcad0fd0 CS |
815 | "DEF:temperature=".$mainsettings{'RRDLOG'}."/hddtemp-$disk.rrd:temperature:AVERAGE", |
816 | "DEF:standby=".$mainsettings{'RRDLOG'}."/hddshutdown-$disk.rrd:standby:AVERAGE", | |
2d281532 CS |
817 | "CDEF:st=standby,INF,*", |
818 | "AREA:st".$color{"color20"}."A0:standby", | |
cc573a98 | 819 | "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} °C\\j", |
2d281532 CS |
820 | "COMMENT:$Lang::tr{'maximal'}", |
821 | "COMMENT:$Lang::tr{'average'}", | |
822 | "COMMENT:$Lang::tr{'minimal'}", | |
823 | "COMMENT:$Lang::tr{'current'}\\j", | |
cc573a98 MF |
824 | "GPRINT:temperature:MAX:%3.0lf °C", |
825 | "GPRINT:temperature:AVERAGE:%3.0lf °C", | |
826 | "GPRINT:temperature:MIN:%3.0lf °C", | |
827 | "GPRINT:temperature:LAST:%3.0lf °C\\j", | |
2d281532 CS |
828 | ); |
829 | $ERROR = RRDs::error; | |
830 | print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; | |
831 | } | |
4e481c3a | 832 | |
2d281532 | 833 | # Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors |
4e481c3a | 834 | |
2d281532 CS |
835 | sub updatehwtempgraph { |
836 | my $period = $_[0]; | |
4e481c3a | 837 | |
2d281532 | 838 | my @command = ( |
a249ccd2 | 839 | @GRAPH_ARGS, |
2d281532 CS |
840 | "-", |
841 | "--start", | |
842 | "-1".$period, | |
2d281532 | 843 | "-r", |
527a5a77 | 844 | "-t ".$Lang::tr{'mbmon temp'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
cc573a98 | 845 | "-v Celsius", |
2d281532 CS |
846 | "--color=SHADEA".$color{"color19"}, |
847 | "--color=SHADEB".$color{"color19"}, | |
848 | "--color=BACK".$color{"color21"}, | |
849 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), | |
850 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
851 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
852 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
853 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" | |
854 | ); | |
4e481c3a | 855 | |
2d281532 CS |
856 | foreach(@sensorsgraphs){ |
857 | chomp($_); | |
858 | if ( $_ =~ /temperature/ ) { | |
859 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
860 | my $label = $2.$3;$label=~ s/-//g; | |
861 | if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} | |
862 | push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); | |
863 | } | |
864 | } | |
4e481c3a | 865 | |
2d281532 CS |
866 | foreach(@sensorsgraphs){ |
867 | chomp($_); | |
868 | if ( $_ =~ /temperature/ ){ | |
869 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
870 | my $label = $2.$3;$label=~ s/-//g; | |
871 | if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} | |
cc573a98 | 872 | 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",); |
2d281532 CS |
873 | } |
874 | } | |
4e481c3a | 875 | |
2d281532 CS |
876 | RRDs::graph (@command); |
877 | $ERROR = RRDs::error; | |
878 | print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; | |
879 | } | |
4e481c3a | 880 | |
2d281532 CS |
881 | # Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors |
882 | ||
883 | sub updatehwfangraph { | |
884 | my $period = $_[0]; | |
885 | ||
886 | my @command = ( | |
a249ccd2 | 887 | @GRAPH_ARGS, |
2d281532 CS |
888 | "-", |
889 | "--start", | |
890 | "-1".$period, | |
2d281532 | 891 | "-r", |
527a5a77 | 892 | "-t ".$Lang::tr{'mbmon fan'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
2d281532 CS |
893 | "--color=SHADEA".$color{"color19"}, |
894 | "--color=SHADEB".$color{"color19"}, | |
895 | "--color=BACK".$color{"color21"}, | |
896 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), | |
897 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
898 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
899 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
900 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" | |
901 | ); | |
902 | ||
903 | foreach(@sensorsgraphs){ | |
904 | chomp($_); | |
905 | if ( $_ =~ /fanspeed/ ) { | |
906 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
907 | my $label = $2.$3;$label=~ s/-//g; | |
908 | if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} | |
909 | push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); | |
910 | } | |
911 | } | |
912 | ||
913 | foreach(@sensorsgraphs){ | |
914 | chomp($_); | |
915 | if ( $_ =~ /fanspeed/ ){ | |
916 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
917 | my $label = $2.$3;$label=~ s/-//g; | |
918 | if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} | |
919 | 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",); | |
920 | } | |
921 | } | |
922 | ||
923 | RRDs::graph (@command); | |
924 | $ERROR = RRDs::error; | |
925 | print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; | |
926 | } | |
927 | ||
928 | # Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors | |
929 | ||
930 | sub updatehwvoltgraph { | |
931 | my $period = $_[0]; | |
932 | ||
933 | my @command = ( | |
a249ccd2 | 934 | @GRAPH_ARGS, |
2d281532 CS |
935 | "-", |
936 | "--start", | |
937 | "-1".$period, | |
2d281532 | 938 | "-r", |
527a5a77 | 939 | "-t ".$Lang::tr{'mbmon volt'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
2d281532 CS |
940 | "--color=SHADEA".$color{"color19"}, |
941 | "--color=SHADEB".$color{"color19"}, | |
942 | "--color=BACK".$color{"color21"}, | |
943 | "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), | |
944 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
945 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
946 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
947 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" | |
948 | ); | |
949 | ||
950 | foreach(@sensorsgraphs){ | |
951 | chomp($_); | |
952 | if ( $_ =~ /voltage/ ) { | |
953 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
954 | my $label = $2.$3;$label=~ s/-//g; | |
955 | if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} | |
956 | push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); | |
957 | } | |
958 | } | |
959 | ||
960 | foreach(@sensorsgraphs){ | |
961 | chomp($_); | |
962 | if ( $_ =~ /voltage/ ){ | |
963 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
964 | my $label = $2.$3;$label=~ s/-//g; | |
965 | if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} | |
966 | 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",); | |
967 | } | |
968 | } | |
969 | ||
970 | RRDs::graph (@command); | |
971 | $ERROR = RRDs::error; | |
972 | print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; | |
973 | } | |
4e481c3a CS |
974 | |
975 | ||
3961e831 AF |
976 | # Generate the QoS Graph for the current period of time |
977 | ||
4e481c3a | 978 | sub updateqosgraph { |
3961e831 | 979 | |
bcad0fd0 CS |
980 | my $period = $_[1]; |
981 | my %qossettings = (); | |
982 | &General::readhash("${General::swroot}/qos/settings", \%qossettings); | |
983 | ||
984 | my $classentry = ""; | |
985 | my @classes = (); | |
986 | my @classline = (); | |
987 | my $classfile = "/var/ipfire/qos/classes"; | |
988 | ||
989 | $qossettings{'DEV'} = $_[0]; | |
3961e831 AF |
990 | if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) { |
991 | $qossettings{'CLASSPRFX'} = '1'; | |
992 | } else { | |
993 | $qossettings{'CLASSPRFX'} = '2'; | |
994 | } | |
995 | ||
3961e831 AF |
996 | my $ERROR=""; |
997 | my $count="1"; | |
00db2d83 | 998 | my %colorMap = (); # maps traffic classes to graph colors |
bcad0fd0 CS |
999 | |
1000 | my @command = ( | |
a249ccd2 | 1001 | @GRAPH_ARGS, |
bcad0fd0 CS |
1002 | "-", |
1003 | "--start", | |
1004 | "-1".$period, | |
bcad0fd0 | 1005 | "-r", |
527a5a77 | 1006 | "-t ".$Lang::tr{'Utilization on'}." (".$qossettings{'DEV'}.") ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
bcad0fd0 CS |
1007 | "-v ".$Lang::tr{'bytes per second'}, |
1008 | "--color=SHADEA".$color{"color19"}, | |
1009 | "--color=SHADEB".$color{"color19"}, | |
1010 | "--color=BACK".$color{"color21"}, | |
3961e831 AF |
1011 | "COMMENT:".sprintf("%-28s",$Lang::tr{'caption'}), |
1012 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), | |
1013 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
1014 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
bcad0fd0 | 1015 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" |
3961e831 | 1016 | ); |
3961e831 | 1017 | |
bcad0fd0 CS |
1018 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; |
1019 | @classes = <FILE>; | |
1020 | close FILE; | |
1021 | ||
1022 | foreach $classentry (sort @classes){ | |
1023 | @classline = split( /\;/, $classentry ); | |
00db2d83 LAH |
1024 | |
1025 | # create class <-> color mapping | |
1026 | my $colorKey = uc $classline[8]; # upper case class name as key | |
1027 | if(! exists $colorMap{$colorKey}) { | |
1028 | # add missing color to table, use colors 11-25 | |
1029 | my $colorIndex = 11 + ((scalar keys %colorMap) % 15); | |
1030 | $colorMap{$colorKey} = "$color{\"color$colorIndex\"}"; | |
1031 | } | |
1032 | ||
bcad0fd0 | 1033 | if ( $classline[0] eq $qossettings{'DEV'} ){ |
bcad0fd0 CS |
1034 | push(@command, "DEF:$classline[1]=$mainsettings{'RRDLOG'}/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE"); |
1035 | ||
00db2d83 LAH |
1036 | # get color to be used for this graph |
1037 | my $graphColor = $colorMap{$colorKey}; | |
1038 | ||
bcad0fd0 | 1039 | if ($count eq "1") { |
00db2d83 | 1040 | push(@command, "AREA:$classline[1]$graphColor:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8])); |
bcad0fd0 | 1041 | } else { |
00db2d83 | 1042 | push(@command, "STACK:$classline[1]$graphColor:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8])); |
bcad0fd0 CS |
1043 | } |
1044 | ||
1045 | push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps" | |
1046 | , "GPRINT:$classline[1]:AVERAGE:%8.1lf %sBps" | |
1047 | , "GPRINT:$classline[1]:MIN:%8.1lf %sBps" | |
1048 | , "GPRINT:$classline[1]:LAST:%8.1lf %sBps\\j"); | |
1049 | $count++; | |
3961e831 | 1050 | } |
3961e831 | 1051 | } |
bcad0fd0 CS |
1052 | RRDs::graph (@command); |
1053 | $ERROR = RRDs::error; | |
1054 | print "Error in RRD::graph for qos device ".$qossettings{'DEV'}.": ".$ERROR."\n" if $ERROR; | |
1055 | } | |
1056 | ||
1057 | # Generate the CPU Frequency Graph for the current period of time for values given by collectd an lm_sensors | |
1058 | ||
1059 | sub updatecpufreqgraph { | |
0d08de33 | 1060 | my $cpucount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/cpu-*/ 2>/dev/null | wc -l`; |
bcad0fd0 CS |
1061 | my $period = $_[0]; |
1062 | my @command = ( | |
a249ccd2 | 1063 | @GRAPH_ARGS, |
bcad0fd0 CS |
1064 | "-", |
1065 | "--start", | |
1066 | "-1".$period, | |
bcad0fd0 | 1067 | "-r", |
527a5a77 | 1068 | "-t ".$Lang::tr{'cpu frequency per'}." ".$Lang::tr{$period."-graph"}, |
bcad0fd0 CS |
1069 | "-v MHz", |
1070 | "--color=SHADEA".$color{"color19"}, | |
1071 | "--color=SHADEB".$color{"color19"}, | |
1072 | "--color=BACK".$color{"color21"}, | |
3e966054 | 1073 | "COMMENT:".sprintf("%-10s",$Lang::tr{'caption'}), |
bcad0fd0 CS |
1074 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), |
1075 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
1076 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
1077 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" | |
1078 | ); | |
1079 | ||
1080 | for(my $i = 0; $i < $cpucount; $i++) { | |
5dcc7ad7 | 1081 | my $j=$i+1; |
bcad0fd0 CS |
1082 | push(@command,"DEF:cpu".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpufreq/cpufreq-".$i.".rrd:value:AVERAGE" |
1083 | ,"CDEF:cpu".$i."=cpu".$i."_,1000000,/" | |
5dcc7ad7 | 1084 | ,"LINE1:cpu".$i.$color{"color1$j"}."A0:cpu ".$i." " |
bcad0fd0 CS |
1085 | ,"GPRINT:cpu".$i.":MAX:%3.0lf Mhz" |
1086 | ,"GPRINT:cpu".$i.":AVERAGE:%3.0lf Mhz" | |
1087 | ,"GPRINT:cpu".$i.":MIN:%3.0lf Mhz" | |
1088 | ,"GPRINT:cpu".$i.":LAST:%3.0lf Mhz\\j"); | |
3961e831 | 1089 | } |
bcad0fd0 | 1090 | |
3961e831 AF |
1091 | RRDs::graph (@command); |
1092 | $ERROR = RRDs::error; | |
bcad0fd0 | 1093 | print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR; |
3961e831 AF |
1094 | } |
1095 | ||
30189c50 AF |
1096 | # Generate the Thermal Zone Temp CPU Graph |
1097 | ||
1098 | sub updatethermaltempgraph { | |
0d08de33 | 1099 | my $thermalcount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* 2>/dev/null | wc -l`; |
30189c50 AF |
1100 | my $period = $_[0]; |
1101 | my @command = ( | |
a249ccd2 | 1102 | @GRAPH_ARGS, |
30189c50 AF |
1103 | "-", |
1104 | "--start", | |
1105 | "-1".$period, | |
30189c50 | 1106 | "-r", |
fa088214 | 1107 | "-t ".$Lang::tr{'acpitemp'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
cc573a98 | 1108 | "-v Celsius", |
30189c50 AF |
1109 | "--color=SHADEA".$color{"color19"}, |
1110 | "--color=SHADEB".$color{"color19"}, | |
1111 | "--color=BACK".$color{"color21"}, | |
3e966054 | 1112 | "COMMENT:".sprintf("%-10s",$Lang::tr{'caption'}), |
30189c50 AF |
1113 | "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), |
1114 | "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), | |
1115 | "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), | |
1116 | "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" | |
1117 | ); | |
1118 | ||
1119 | for(my $i = 0; $i < $thermalcount; $i++) { | |
1120 | my $j=$i+1; | |
1121 | push(@command,"DEF:temp".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/thermal-thermal_zone".$i."/temperature-temperature.rrd:value:AVERAGE" | |
1122 | ,"CDEF:temp".$i."=temp".$i."_,1,/" | |
3e966054 | 1123 | ,"LINE3:temp".$i.$color{"color1$j"}."A0:Temp ".$i." " |
cc573a98 MF |
1124 | ,"GPRINT:temp".$i.":MAX:%3.0lf °C" |
1125 | ,"GPRINT:temp".$i.":AVERAGE:%3.0lf °C" | |
1126 | ,"GPRINT:temp".$i.":MIN:%3.0lf °C" | |
1127 | ,"GPRINT:temp".$i.":LAST:%3.0lf °C\\j"); | |
30189c50 AF |
1128 | } |
1129 | ||
1130 | RRDs::graph (@command); | |
1131 | $ERROR = RRDs::error; | |
1132 | print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR; | |
1133 | } | |
1134 | ||
30189c50 | 1135 | |
3961e831 AF |
1136 | # Generate a random color, used by Qos Graph to be independent from the amount of values |
1137 | ||
1138 | sub random_hex_color { | |
4e481c3a CS |
1139 | my $size = shift; |
1140 | $size = 6 if $size !~ /^3|6$/; | |
1141 | my @hex = ( 0 .. 9, 'a' .. 'f' ); | |
1142 | my @color; | |
1143 | push @color, @hex[rand(@hex)] for 1 .. $size; | |
1144 | return join('', '#', @color); | |
3961e831 | 1145 | } |
1c163c04 CS |
1146 | |
1147 | sub getprocesses { | |
0d08de33 | 1148 | my @processesgraph = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/processes-*/ 2>/dev/null`; |
1c163c04 CS |
1149 | return @processesgraph; |
1150 | } | |
15b023b9 MT |
1151 | |
1152 | sub updateentropygraph { | |
1153 | my $period = $_[0]; | |
1154 | my @command = ( | |
a249ccd2 | 1155 | @GRAPH_ARGS, |
15b023b9 MT |
1156 | "-", |
1157 | "--start", | |
1158 | "-1".$period, | |
15b023b9 MT |
1159 | "-r", |
1160 | "--lower-limit","0", | |
2bba6509 | 1161 | "-t ".$Lang::tr{'entropy'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period."-graph"}, |
15b023b9 MT |
1162 | "-v $Lang::tr{'bit'}", |
1163 | "DEF:entropy=$mainsettings{'RRDLOG'}/collectd/localhost/entropy/entropy.rrd:entropy:AVERAGE", | |
15b023b9 MT |
1164 | "LINE3:entropy#ff0000:" . sprintf("%-15s", $Lang::tr{'entropy'}), |
1165 | "VDEF:entrmin=entropy,MINIMUM", | |
1166 | "VDEF:entrmax=entropy,MAXIMUM", | |
1167 | "VDEF:entravg=entropy,AVERAGE", | |
1168 | "GPRINT:entrmax:" . sprintf("%12s\\: %%5.0lf", $Lang::tr{'maximum'}), | |
1169 | "GPRINT:entrmin:" . sprintf("%12s\\: %%5.0lf", $Lang::tr{'minimum'}), | |
1170 | "GPRINT:entravg:" . sprintf("%12s\\: %%5.0lf", $Lang::tr{'average'}) . "\\n", | |
a249ccd2 | 1171 | "--color=BACK".$color{"color21"}, |
15b023b9 MT |
1172 | ); |
1173 | ||
1174 | RRDs::graph (@command); | |
1175 | $ERROR = RRDs::error; | |
1176 | ||
1177 | print "Error in RRD::graph for entropy: ".$ERROR."\n" if $ERROR; | |
1178 | } | |
8ffdc78c MT |
1179 | |
1180 | sub updateconntrackgraph { | |
1181 | my $period = $_[0]; | |
1182 | my @command = ( | |
1183 | @GRAPH_ARGS, | |
1184 | "-", | |
1185 | "--start", | |
1186 | "-1" . $period, | |
1187 | "-r", | |
1188 | "--lower-limit","0", | |
1189 | "-t $Lang::tr{'connection tracking'}", | |
1190 | "-v $Lang::tr{'open connections'}", | |
1191 | "DEF:conntrack=$mainsettings{'RRDLOG'}/collectd/localhost/conntrack/conntrack.rrd:entropy:AVERAGE", | |
1192 | "LINE3:conntrack#ff0000:" . sprintf("%-15s", $Lang::tr{'open connections'}), | |
1193 | "VDEF:ctmin=conntrack,MINIMUM", | |
1194 | "VDEF:ctmax=conntrack,MAXIMUM", | |
1195 | "VDEF:ctavg=conntrack,AVERAGE", | |
1196 | "GPRINT:ctmax:" . sprintf("%15s\\: %%5.0lf", $Lang::tr{'maximum'}), | |
1197 | "GPRINT:ctmin:" . sprintf("%15s\\: %%5.0lf", $Lang::tr{'minimum'}), | |
1198 | "GPRINT:ctavg:" . sprintf("%15s\\: %%5.0lf", $Lang::tr{'average'}) . "\\n", | |
1199 | "--color=BACK" . $color{"color21"}, | |
1200 | ); | |
1201 | ||
1202 | RRDs::graph(@command); | |
1203 | $ERROR = RRDs::error; | |
1204 | ||
1205 | print STDERR "Error in RRD::Graph for conntrack: " . $ERROR . "\n" if $ERROR; | |
1206 | } |