]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | #!/usr/bin/perl |
2 | ||
3 | ############################################################################ | |
4 | # # | |
5 | # This file is part of the IPCop Firewall. # | |
6 | # # | |
7 | # IPCop is free software; you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation; either version 2 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # IPCop is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with IPCop; if not, write to the Free Software # | |
19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # | |
20 | # # | |
21 | # Copyright (C) 2004-01-19 Mark Wormgoor <mark@wormgoor.com>. # | |
22 | # # | |
23 | ############################################################################ | |
24 | # | |
25 | # $Id: makegraphs,v 1.19.2.18 2006/01/08 13:41:04 eoberlander Exp $ | |
26 | # | |
27 | use strict; | |
28 | #use warnings; | |
29 | ||
30 | use RRDs; | |
31 | require "CONFIG_ROOT/general-functions.pl"; | |
32 | require "${General::swroot}/lang.pl"; | |
33 | ||
34 | my (%settings, @ipacsum, $iface, $ERROR); | |
35 | &General::readhash("${General::swroot}/ethernet/settings", \%settings); | |
36 | ||
37 | # Added for conversion of utf-8 characters | |
38 | use Encode 'from_to'; | |
39 | my %tr=(); | |
40 | ||
41 | # Force language back to English (ugly hack!) | |
42 | # Modified to only force if we are unable to convert charset | |
43 | # from utf-8 | |
44 | if ((${Lang::language} eq 'el') || | |
45 | (${Lang::language} eq 'fa') || | |
46 | (${Lang::language} eq 'ru') || | |
47 | (${Lang::language} eq 'th') || | |
48 | (${Lang::language} eq 'vi') || | |
49 | (${Lang::language} eq 'zh') || | |
50 | (${Lang::language} eq 'zt')) { | |
51 | eval `/bin/cat "${General::swroot}/langs/en.pl"`; | |
52 | } else { | |
53 | %tr=%Lang::tr; # use translated version for other languages | |
54 | } | |
55 | ||
56 | # Settings | |
57 | my $rrdlog = "/var/log/rrd"; | |
58 | my $graphs = "/home/httpd/html/graphs"; | |
59 | $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; | |
60 | ||
61 | sub gettraffic { | |
62 | my $interface = $_[0]; | |
63 | ||
64 | my $bytesin=0; | |
65 | my $bytesout=0; | |
66 | ||
67 | foreach (@ipacsum) | |
68 | { | |
69 | # Incoming... | |
70 | $bytesin += $1 if (/^[\* ]\s+incoming\s+${interface}.+\:\s+(\d+)/); | |
71 | ||
72 | # Forwarded Incoming... | |
73 | $bytesin += $1 if (/^[\* ]\s+forwarded\s+incoming\s+${interface}.+\:\s+(\d+)/); | |
74 | ||
75 | # Outgoing... | |
76 | $bytesout += $1 if (/^[* ]\s+outgoing\s+${interface}.+\:\s+(\d+)/); | |
77 | ||
78 | # Forwarded Outgoing... | |
79 | $bytesout += $1 if (/^[* ]\s+forwarded\s+outgoing\s+${interface}.+\:\s+(\d+)/); | |
80 | } | |
81 | return "$bytesin:$bytesout"; | |
82 | } | |
83 | ||
84 | sub updatecpugraph { | |
85 | my $period = $_[0]; | |
86 | ||
87 | RRDs::graph ("$graphs/cpu-$period.png", | |
88 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
89 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
90 | "--color", "SHADEA#EAE9EE", | |
91 | "--color", "SHADEB#EAE9EE", | |
92 | "--color", "BACK#EAE9EE", | |
93 | "-t $tr{'cpu usage per'} $tr{$period}", | |
94 | "DEF:user=$rrdlog/cpu.rrd:user:AVERAGE", | |
95 | "DEF:system=$rrdlog/cpu.rrd:system:AVERAGE", | |
96 | "DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE", | |
97 | "CDEF:total=user,system,idle,+,+", | |
98 | "CDEF:userpct=100,user,total,/,*", | |
99 | "CDEF:systempct=100,system,total,/,*", | |
100 | "CDEF:idlepct=100,idle,total,/,*", | |
101 | "AREA:userpct#0000FF:$tr{'user cpu usage'}\\j", | |
102 | "STACK:systempct#FF0000:$tr{'system cpu usage'}\\j", | |
103 | "STACK:idlepct#00FF00:$tr{'idle cpu usage'}\\j", | |
104 | "GPRINT:userpct:MAX:$tr{'maximal'} $tr{'user cpu'}\\:%3.2lf%%", | |
105 | "GPRINT:userpct:AVERAGE:$tr{'average'} $tr{'user cpu'}\\:%3.2lf%%", | |
106 | "GPRINT:userpct:LAST:$tr{'current'} $tr{'user cpu'}\\:%3.2lf%%\\j", | |
107 | "GPRINT:systempct:MAX:$tr{'maximal'} $tr{'system cpu'}\\:%3.2lf%%", | |
108 | "GPRINT:systempct:AVERAGE:$tr{'average'} $tr{'system cpu'}\\:%3.2lf%%", | |
109 | "GPRINT:systempct:LAST:$tr{'current'} $tr{'system cpu'}\\:%3.2lf%%\\j", | |
110 | "GPRINT:idlepct:MAX:$tr{'maximal'} $tr{'idle cpu'}\\:%3.2lf%%", | |
111 | "GPRINT:idlepct:AVERAGE:$tr{'average'} $tr{'idle cpu'}\\:%3.2lf%%", | |
112 | "GPRINT:idlepct:LAST:$tr{'current'} $tr{'idle cpu'}\\:%3.2lf%%\\j"); | |
113 | $ERROR = RRDs::error; | |
114 | print "Error in RRD::graph for cpu: $ERROR\n" if $ERROR; | |
115 | } | |
116 | ||
117 | sub updatecpudata { | |
118 | if ( ! -e "$rrdlog/cpu.rrd") { | |
119 | RRDs::create ("$rrdlog/cpu.rrd", "--step=300", | |
120 | "DS:user:COUNTER:600:0:500000000", | |
121 | "DS:system:COUNTER:600:0:500000000", | |
122 | "DS:idle:COUNTER:600:0:500000000", | |
123 | "RRA:AVERAGE:0.5:1:576", | |
124 | "RRA:AVERAGE:0.5:6:672", | |
125 | "RRA:AVERAGE:0.5:24:732", | |
126 | "RRA:AVERAGE:0.5:144:1460"); | |
127 | $ERROR = RRDs::error; | |
128 | print "Error in RRD::create for cpu: $ERROR\n" if $ERROR; | |
129 | } | |
130 | ||
131 | my ($cpu, $user, $nice, $system, $idle); | |
132 | ||
133 | open STAT, "/proc/stat"; | |
134 | while(<STAT>) { | |
135 | chomp; | |
136 | /^cpu\s/ or next; | |
137 | ($cpu, $user, $nice, $system, $idle) = split /\s+/; | |
138 | last; | |
139 | } | |
140 | close STAT; | |
141 | $user += $nice; | |
142 | ||
143 | RRDs::update ("$rrdlog/cpu.rrd", | |
144 | "-t", "user:system:idle", | |
145 | "N:$user:$system:$idle"); | |
146 | $ERROR = RRDs::error; | |
147 | print "Error in RRD::update for cpu: $ERROR\n" if $ERROR; | |
148 | ||
149 | } | |
150 | ||
151 | sub updatememgraph { | |
152 | my $period = $_[0]; | |
153 | ||
154 | RRDs::graph ("$graphs/memory-$period.png", | |
155 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
156 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
157 | "--color", "SHADEA#EAE9EE", | |
158 | "--color", "SHADEB#EAE9EE", | |
159 | "--color", "BACK#EAE9EE", | |
160 | "-t $tr{'memory usage per'} $tr{$period}", | |
161 | "DEF:used=$rrdlog/mem.rrd:memused:AVERAGE", | |
162 | "DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE", | |
163 | "DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE", | |
164 | "DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE", | |
165 | "DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE", | |
166 | "CDEF:total=used,free,+", | |
167 | "CDEF:used2=used,buffer,cache,shared,+,+,-", | |
168 | "CDEF:usedpct=100,used2,total,/,*", | |
169 | "CDEF:sharedpct=100,shared,total,/,*", | |
170 | "CDEF:bufferpct=100,buffer,total,/,*", | |
171 | "CDEF:cachepct=100,cache,total,/,*", | |
172 | "CDEF:freepct=100,free,total,/,*", | |
173 | "AREA:usedpct#0000FF:$tr{'used memory'}\\j", | |
174 | "STACK:sharedpct#FF0000:$tr{'shared memory'}\\j", | |
175 | "STACK:bufferpct#FF00FF:$tr{'buffered memory'}\\j", | |
176 | "STACK:cachepct#FFFF00:$tr{'cached memory'}\\j", | |
177 | "STACK:freepct#00FF00:$tr{'free memory'}\\j", | |
178 | "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used memory'}\\:%3.2lf%%", | |
179 | "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used memory'}\\:%3.2lf%%", | |
180 | "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used memory'}\\:%3.2lf%%\\j", | |
181 | "GPRINT:sharedpct:MAX:$tr{'maximal'} $tr{'shared memory'}\\:%3.2lf%%", | |
182 | "GPRINT:sharedpct:AVERAGE:$tr{'average'} $tr{'shared memory'}\\:%3.2lf%%", | |
183 | "GPRINT:sharedpct:LAST:$tr{'current'} $tr{'shared memory'}\\:%3.2lf%%\\j", | |
184 | "GPRINT:bufferpct:MAX:$tr{'maximal'} $tr{'buffered memory'}\\:%3.2lf%%", | |
185 | "GPRINT:bufferpct:AVERAGE:$tr{'average'} $tr{'buffered memory'}\\:%3.2lf%%", | |
186 | "GPRINT:bufferpct:LAST:$tr{'current'} $tr{'buffered memory'}\\:%3.2lf%%\\j", | |
187 | "GPRINT:cachepct:MAX:$tr{'maximal'} $tr{'cached memory'}\\:%3.2lf%%", | |
188 | "GPRINT:cachepct:AVERAGE:$tr{'average'} $tr{'cached memory'}\\:%3.2lf%%", | |
189 | "GPRINT:cachepct:LAST:$tr{'current'} $tr{'cached memory'}\\:%3.2lf%%\\j", | |
190 | "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free memory'}\\:%3.2lf%%", | |
191 | "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free memory'}\\:%3.2lf%%", | |
192 | "GPRINT:freepct:LAST:$tr{'current'} $tr{'free memory'}\\:%3.2lf%%\\j"); | |
193 | $ERROR = RRDs::error; | |
194 | print "Error in RRD::graph for mem: $ERROR\n" if $ERROR; | |
195 | ||
196 | RRDs::graph ("$graphs/swap-$period.png", | |
197 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
198 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-u 100", "-r", | |
199 | "--color", "SHADEA#EAE9EE", | |
200 | "--color", "SHADEB#EAE9EE", | |
201 | "--color", "BACK#EAE9EE", | |
202 | "-t $tr{'swap usage per'} $tr{$period}", | |
203 | "DEF:used=$rrdlog/mem.rrd:swapused:AVERAGE", | |
204 | "DEF:free=$rrdlog/mem.rrd:swapfree:AVERAGE", | |
205 | "CDEF:total=used,free,+", | |
206 | "CDEF:usedpct=100,used,total,/,*", | |
207 | "CDEF:freepct=100,free,total,/,*", | |
208 | "AREA:usedpct#0000FF:$tr{'used swap'}\\j", | |
209 | "STACK:freepct#00FF00:$tr{'free swap'}\\j", | |
210 | "GPRINT:usedpct:MAX:$tr{'maximal'} $tr{'used swap'}\\:%3.2lf%%", | |
211 | "GPRINT:usedpct:AVERAGE:$tr{'average'} $tr{'used swap'}\\:%3.2lf%%", | |
212 | "GPRINT:usedpct:LAST:$tr{'current'} $tr{'used swap'}\\:%3.2lf%%\\j", | |
213 | "GPRINT:freepct:MAX:$tr{'maximal'} $tr{'free swap'}\\:%3.2lf%%", | |
214 | "GPRINT:freepct:AVERAGE:$tr{'average'} $tr{'free swap'}\\:%3.2lf%%", | |
215 | "GPRINT:freepct:LAST:$tr{'current'} $tr{'free swap'}\\:%3.2lf%%\\j"); | |
216 | $ERROR = RRDs::error; | |
217 | print "Error in RRD::graph for swap: $ERROR\n" if $ERROR; | |
218 | } | |
219 | ||
220 | sub updatememdata { | |
221 | my ($memused, $memfree, $memshared, $membuffers, $memcache, $swapused, $swapfree); | |
222 | if ( ! -e "$rrdlog/mem.rrd") { | |
223 | RRDs::create ("$rrdlog/mem.rrd", "--step=300", | |
224 | "DS:memused:ABSOLUTE:600:0:5000000000", | |
225 | "DS:memfree:ABSOLUTE:600:0:5000000000", | |
226 | "DS:memshared:ABSOLUTE:600:0:5000000000", | |
227 | "DS:membuffers:ABSOLUTE:600:0:5000000000", | |
228 | "DS:memcache:ABSOLUTE:600:0:5000000000", | |
229 | "DS:swapused:ABSOLUTE:600:0:5000000000", | |
230 | "DS:swapfree:ABSOLUTE:600:0:5000000000", | |
231 | "RRA:AVERAGE:0.5:1:576", | |
232 | "RRA:AVERAGE:0.5:6:672", | |
233 | "RRA:AVERAGE:0.5:24:732", | |
234 | "RRA:AVERAGE:0.5:144:1460"); | |
235 | $ERROR = RRDs::error; | |
236 | print "Error in RRD::create for mem: $ERROR\n" if $ERROR; | |
237 | } | |
238 | ||
239 | open MEM, "/proc/meminfo"; | |
240 | while(<MEM>) { | |
241 | chomp; | |
242 | if ($_ =~ /^Mem:/) { | |
243 | my @temp = split (/\s+/, $_); | |
244 | $memused = $temp[2]; | |
245 | $memfree = $temp[3]; | |
246 | $memshared = $temp[4]; | |
247 | $membuffers = $temp[5]; | |
248 | $memcache = $temp[6]; | |
249 | } elsif ($_ =~ /^Swap:/) { | |
250 | my @temp = split (/\s+/, $_); | |
251 | $swapused = $temp[2]; | |
252 | $swapfree = $temp[3]; | |
253 | } | |
254 | } | |
255 | close MEM; | |
256 | ||
257 | RRDs::update ("$rrdlog/mem.rrd", | |
258 | "-t", "memused:memfree:memshared:membuffers:memcache:swapused:swapfree", | |
259 | "N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree"); | |
260 | $ERROR = RRDs::error; | |
261 | print "Error in RRD::update for mem: $ERROR\n" if $ERROR; | |
262 | } | |
263 | ||
264 | sub updatediskgraph { | |
265 | my $period = $_[0]; | |
266 | ||
267 | RRDs::graph ("$graphs/disk-$period.png", | |
268 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
269 | "--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r", | |
270 | "--color", "SHADEA#EAE9EE", | |
271 | "--color", "SHADEB#EAE9EE", | |
272 | "--color", "BACK#EAE9EE", | |
273 | "-t $tr{'disk access per'} $tr{$period}", | |
274 | "DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE", | |
275 | "DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE", | |
276 | "AREA:read#0000FF:$tr{'sectors read from disk per second'}\\j", | |
277 | "STACK:write#00FF00:$tr{'sectors written to disk per second'}\\j", | |
278 | "GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf", | |
279 | "GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf", | |
280 | "GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j", | |
281 | "GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf", | |
282 | "GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf", | |
283 | "GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j"); | |
284 | $ERROR = RRDs::error; | |
285 | print "Error in RRD::graph for disk: $ERROR\n" if $ERROR; | |
286 | } | |
287 | ||
288 | sub updatediskdata { | |
289 | my ($readwritereq, $readreq, $readsect, $writereq, $writesect); | |
290 | if ( ! -e "$rrdlog/disk.rrd") { | |
291 | RRDs::create ("$rrdlog/disk.rrd", "--step=300", | |
292 | "DS:readsect:COUNTER:600:0:5000000000", | |
293 | "DS:writesect:COUNTER:600:0:5000000000", | |
294 | "RRA:AVERAGE:0.5:1:576", | |
295 | "RRA:AVERAGE:0.5:6:672", | |
296 | "RRA:AVERAGE:0.5:24:732", | |
297 | "RRA:AVERAGE:0.5:144:1460"); | |
298 | $ERROR = RRDs::error; | |
299 | print "Error in RRD::create for disk: $ERROR\n" if $ERROR; | |
300 | } | |
301 | ||
302 | my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, | |
303 | $atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/harddisk"); | |
304 | ||
305 | my $major = $rdev >> 8; | |
306 | my $minor = $rdev & 0xFF; | |
307 | ||
308 | open STAT, "/proc/stat"; | |
309 | my @diskstat = <STAT>; | |
310 | close (STAT); | |
311 | foreach my $line (@diskstat) | |
312 | { | |
313 | chomp ($line); | |
314 | my @temp = split(/\:\ /,$line); | |
315 | if ($temp[1]) { | |
316 | my @devicestat = split(/\ /,$temp[1]); | |
317 | foreach my $stats (@devicestat) | |
318 | { | |
319 | chomp ($stats); | |
320 | my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats); | |
321 | if ($major eq $fields[1] and $minor eq $fields[2]) | |
322 | { | |
323 | $readwritereq = $fields[3]; | |
324 | $readreq = $fields[4]; | |
325 | $readsect = $fields[5]; | |
326 | $writereq = $fields[6]; | |
327 | $writesect = $fields[7]; | |
328 | } | |
329 | } | |
330 | } | |
331 | } | |
332 | ||
333 | if ($readsect && $writesect) { | |
334 | RRDs::update ("$rrdlog/disk.rrd", | |
335 | "-t", "readsect:writesect", | |
336 | "N:$readsect:$writesect"); | |
337 | $ERROR = RRDs::error; | |
338 | print "Error in RRD::update for disk: $ERROR\n" if $ERROR; | |
339 | } else { | |
340 | print "Error in RRD::update for disk: no data available\n"; | |
341 | } | |
342 | } | |
343 | ||
344 | sub updateifgraph { | |
345 | my $interface = $_[0]; | |
346 | my $period = $_[1]; | |
347 | ||
348 | RRDs::graph ("$graphs/$interface-$period.png", | |
349 | "--start", "-1$period", "-aPNG", "-i", "-z", | |
350 | "--alt-y-grid", "-w 600", "-h 100", | |
351 | "--color", "SHADEA#EAE9EE", | |
352 | "--color", "SHADEB#EAE9EE", | |
353 | "--color", "BACK#EAE9EE", | |
354 | "-t $tr{'traffic on'} $interface ($tr{'graph per'} $tr{$period})", | |
355 | "-v$tr{'bytes per second'}", | |
356 | "DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE", | |
357 | "DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE", | |
358 | "AREA:incoming#00FF00:$tr{'incoming traffic in bytes per second'}\\j", | |
359 | "LINE1:outgoing#0000FF:$tr{'outgoing traffic in bytes per second'}\\j", | |
360 | "GPRINT:incoming:MAX:$tr{'maximal'} $tr{'in'}\\:%8.3lf %sBps", | |
361 | "GPRINT:incoming:AVERAGE:$tr{'average'} $tr{'in'}\\:%8.3lf %sBps", | |
362 | "GPRINT:incoming:LAST:$tr{'current'} $tr{'in'}\\:%8.3lf %sBps\\j", | |
363 | "GPRINT:outgoing:MAX:$tr{'maximal'} $tr{'out'}\\:%8.3lf %sBps", | |
364 | "GPRINT:outgoing:AVERAGE:$tr{'average'} $tr{'out'}\\:%8.3lf %sBps", | |
365 | "GPRINT:outgoing:LAST:$tr{'current'} $tr{'out'}\\:%8.3lf %sBps\\j"); | |
366 | $ERROR = RRDs::error; | |
367 | print "Error in RRD::graph for $interface: $ERROR\n" if $ERROR; | |
368 | } | |
369 | ||
370 | sub updateifdata { | |
371 | my $interface = $_[0]; | |
372 | ||
373 | if ( ! -e "$rrdlog/$interface.rrd") { | |
374 | RRDs::create ("$rrdlog/$interface.rrd", "--step=300", | |
375 | "DS:incoming:ABSOLUTE:600:0:12500000", | |
376 | "DS:outgoing:ABSOLUTE:600:0:12500000", | |
377 | "RRA:AVERAGE:0.5:1:576", | |
378 | "RRA:AVERAGE:0.5:6:672", | |
379 | "RRA:AVERAGE:0.5:24:732", | |
380 | "RRA:AVERAGE:0.5:144:1460"); | |
381 | $ERROR = RRDs::error; | |
382 | print "Error in RRD::create for $interface: $ERROR\n" if $ERROR; | |
383 | } | |
384 | ||
385 | my $traffic = gettraffic ($interface); | |
386 | RRDs::update ("$rrdlog/$interface.rrd", | |
387 | "-t", "incoming:outgoing", | |
388 | "N:$traffic"); | |
389 | $ERROR = RRDs::error; | |
390 | print "Error in RRD::update for $interface: $ERROR\n" if $ERROR; | |
391 | } | |
392 | ||
393 | ## Update ipac logs | |
394 | system ('/usr/sbin/fetchipac'); | |
395 | sleep 8; | |
396 | ||
397 | ### | |
398 | ### Squid Graphs | |
399 | ### | |
400 | if ( -e "/var/log/squid/access.log") { | |
401 | system ("/usr/bin/squid-graph -o=/home/httpd/html/sgraph --tcp-only < /var/log/squid/access.log >/dev/null 2>&1"); | |
402 | } | |
403 | ||
404 | ### | |
405 | ### utf8 conversion | |
406 | ### | |
407 | if ((${Lang::language} eq 'cs') || | |
408 | (${Lang::language} eq 'hu') || | |
409 | (${Lang::language} eq 'pl') || | |
410 | (${Lang::language} eq 'sk')) { | |
411 | # Czech, Hungarian, Polish and Slovak character set | |
412 | foreach my $key(keys %Lang::tr) { | |
413 | from_to($tr{$key}, "utf-8", "iso-8859-2"); | |
414 | } | |
415 | } elsif (${Lang::language} eq 'tr') { | |
416 | # Turkish | |
417 | foreach my $key(keys %Lang::tr) { | |
418 | from_to($tr{$key}, "utf-8", "iso-8859-9"); | |
419 | } | |
420 | } else { | |
421 | foreach my $key(keys %Lang::tr) { | |
422 | from_to($tr{$key}, "utf-8", "iso-8859-1"); | |
423 | } | |
424 | } | |
425 | ||
426 | ### | |
427 | ### System graphs | |
428 | ### | |
429 | updatecpudata(); | |
430 | updatecpugraph ("day"); | |
431 | updatecpugraph ("week"); | |
432 | updatecpugraph ("month"); | |
433 | updatecpugraph ("year"); | |
434 | ||
435 | updatememdata(); | |
436 | updatememgraph ("day"); | |
437 | updatememgraph ("week"); | |
438 | updatememgraph ("month"); | |
439 | updatememgraph ("year"); | |
440 | ||
441 | updatediskdata(); | |
442 | updatediskgraph ("day"); | |
443 | updatediskgraph ("week"); | |
444 | updatediskgraph ("month"); | |
445 | updatediskgraph ("year"); | |
446 | ||
447 | ### | |
448 | ### Network Graphs | |
449 | ### | |
450 | @ipacsum = `/usr/sbin/ipacsum --exact -s 5m 2>/dev/null`; | |
451 | if (@ipacsum) { | |
452 | updateifdata ("GREEN"); | |
453 | updateifdata ("RED"); | |
454 | if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ ) { | |
455 | updateifdata ("ORANGE"); | |
456 | } | |
457 | if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ ) { | |
458 | updateifdata ("BLUE"); | |
459 | } | |
460 | } | |
461 | if ( -e "$rrdlog/GREEN.rrd") { | |
462 | updateifgraph ("GREEN", "day"); | |
463 | updateifgraph ("GREEN", "week"); | |
464 | updateifgraph ("GREEN", "month"); | |
465 | updateifgraph ("GREEN", "year"); | |
466 | } | |
467 | ||
468 | if ( -e "$rrdlog/RED.rrd") { | |
469 | updateifgraph ("RED", "day"); | |
470 | updateifgraph ("RED", "week"); | |
471 | updateifgraph ("RED", "month"); | |
472 | updateifgraph ("RED", "year"); | |
473 | } | |
474 | ||
475 | if ($settings{'CONFIG_TYPE'} =~ /^(1|3|5|7)$/ && -e "$rrdlog/ORANGE.rrd") { | |
476 | updateifgraph ("ORANGE", "day"); | |
477 | updateifgraph ("ORANGE", "week"); | |
478 | updateifgraph ("ORANGE", "month"); | |
479 | updateifgraph ("ORANGE", "year"); | |
480 | } | |
481 | ||
482 | if ($settings{'CONFIG_TYPE'} =~ /^(4|5|6|7)$/ && -e "$rrdlog/BLUE.rrd") { | |
483 | updateifgraph ("BLUE", "day"); | |
484 | updateifgraph ("BLUE", "week"); | |
485 | updateifgraph ("BLUE", "month"); | |
486 | updateifgraph ("BLUE", "year"); | |
487 | } |