]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/scripts/makegraphs
4e628b87a824a76f464af47d51d44f532c4c42f0
3 ############################################################################
5 # This file is part of the IPCop Firewall. #
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. #
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. #
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 #
21 # Copyright (C) 2004-01-19 Mark Wormgoor <mark@wormgoor.com>. #
23 ############################################################################
29 require "/var/ipfire/general-functions.pl";
30 require "${General::swroot}/lang.pl";
32 my (%settings, @ipacsum, $iface, $ERROR);
33 &General
::readhash
("${General::swroot}/ethernet/settings", \
%settings);
34 my %mbmon_settings = ();
35 &General
::readhash
("${General::swroot}/mbmon/settings", \
%mbmon_settings);
37 # Added for conversion of utf-8 characters
41 system("chmod 777 /srv/web/ipfire/html/graphs");
43 # Force language back to English (ugly hack!)
44 # Modified to only force if we are unable to convert charset
46 if((${Lang
::language
} eq 'el') ||
47 (${Lang
::language
} eq 'fa') ||
48 (${Lang
::language
} eq 'ru') ||
49 (${Lang
::language
} eq 'th') ||
50 (${Lang
::language
} eq 'vi') ||
51 (${Lang
::language
} eq 'zh') ||
52 (${Lang
::language
} eq 'zt')) {
53 eval `/bin/cat "${General::swroot}/langs/en.pl"`;
55 #use translated version for other languages
60 my $rrdlog = "/var/log/rrd";
61 my $graphs = "/srv/web/ipfire/html/graphs";
62 $ENV{PATH
}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
63 my $hdd_device = "/dev/harddisk";
65 my %mbmon_values = ();
72 my $path_smartctl = "/usr/sbin/smartctl";
73 my $path_hddtemp = "/usr/sbin/hddtemp";
76 my %mainsettings = ();
77 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
78 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
80 open(MBMON_OUT
, ">/var/log/mbmon-values");
81 open(FD
, "/usr/bin/mbmon -rc1|" ) || die "ERROR: Cannot run mbmon\n" ;
85 next unless( /^([A-Za-z][^:\s]+)\s*:\s*([+\-]{0,1}[\d\.]+)/ ) ;
89 $mbmon_values{$key} = $value;
90 print(MBMON_OUT
"$key=$value\n");
99 my @array = split(/\//,$disk);
101 if ( ! -e
"$rrdlog/hddshutdown-".$array[$#array].".rrd"){
102 # database did not exist -> create
103 RRDs
::create
("$rrdlog/hddshutdown-".$array[$#array].".rrd", "--step=300",
104 "DS:standby:GAUGE:600:0:1",
105 "RRA:AVERAGE:0.5:1:576",
106 "RRA:AVERAGE:0.5:6:672",
107 "RRA:AVERAGE:0.5:24:732",
108 "RRA:AVERAGE:0.5:144:1460");
109 $ERROR = RRDs
::error
;
110 print "Error in RRD::create for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR;
113 if (-e
"/tmp/hddshutdown-".$array[$#array]) {$standby = 1;}
116 RRDs
::update
("$rrdlog/hddshutdown-".$array[$#array].".rrd", "-t", "standby", "N:$standby");
117 $ERROR = RRDs
::error
;
118 print "Error in RRD::update for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR;
120 if ( ! -e
"$rrdlog/hddtemp-".$array[$#array].".rrd"){
121 # database did not exist -> create
122 RRDs
::create
("$rrdlog/hddtemp-".$array[$#array].".rrd", "--step=300",
123 "DS:temperature:GAUGE:600:0:100",
124 "RRA:AVERAGE:0.5:1:576",
125 "RRA:AVERAGE:0.5:6:672",
126 "RRA:AVERAGE:0.5:24:732",
127 "RRA:AVERAGE:0.5:144:1460");
128 $ERROR = RRDs
::error
;
129 print "Error in RRD::create for hdd-".$array[$#array].": $ERROR\n" if $ERROR;
132 # Temperaturlesen wÃrde die Platte aufwecken!!!
136 my $smart_output = '';
137 if ( -e
"$path_smartctl" ){system("$path_smartctl -iHA -d ata /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");}
138 if ( -e
"/var/log/smartctl_out_hddtemp-".$array[$#array] ){
139 $hdd_output = `cat /var/log/smartctl_out_hddtemp-$array[$#array] | grep Temperature_`;
140 my @t = split(/\s+/,$hdd_output);
143 print "Temperature for ".$array[$#array]."->".$temp."<-\n";
144 system("echo \"Temperature for $array[$#array] -> $temp <-\n\" >>/tmp/debug");
145 # Nur ins RDD wenn nicht 0 (sonst klappt die min Anzeige nicht)
147 RRDs
::update
("$rrdlog/hddtemp-".$array[$#array].".rrd", "-t", "temperature", "N:$temp");
148 $ERROR = RRDs
::error
;
149 print "Error in RRD::update for hdd-".$array[$#array].": $ERROR\n" if $ERROR;
156 if ( ! -e
"$rrdlog/mbmon.rrd" ){
157 # database did not exist -> create
159 @args = ("$rrdlog/mbmon.rrd");
160 push(@args, "--step=300");
161 foreach $key ( sort(keys %mbmon_values) ){push(@args, "DS:$key:GAUGE:600:U:U");}
162 push(@args, "RRA:AVERAGE:0.5:1:576");
163 push(@args, "RRA:AVERAGE:0.5:6:672");
164 push(@args, "RRA:AVERAGE:0.5:24:732");
165 push(@args, "RRA:AVERAGE:0.5:144:1460");
167 print("create ". join( ", ", @args)) if ( $dbg );
168 RRDs
::create
(@args);
169 $ERROR = RRDs
::error
;
170 print("Error in RRD::create for mbmon: $ERROR\n") if $ERROR;
177 foreach $key ( sort(keys %mbmon_values) ){
179 push(@val, $mbmon_values{$key});
182 $template = join(':', @ds);
183 $value = "N:".join(':', @val);
185 print("update template = '$template'\n") if ( $dbg );
186 print("update value = '$value'\n") if ( $dbg );
188 RRDs
::update
("$rrdlog/mbmon.rrd", "-t", $template, $value);
189 $ERROR = RRDs
::error
;
190 print("Error in RRD::update for mbmon: $ERROR\n") if $ERROR;
194 system ('/usr/sbin/fetchipac');
200 if ( -e
"/var/log/squid/access.log") {system ("/usr/bin/squid-graph -o=/srv/web/ipfire/html/sgraph --tcp-only < /var/log/squid/access.log >/dev/null 2>&1");}
205 if ((${Lang
::language
} eq 'cs') || (${Lang
::language
} eq 'hu') || (${Lang
::language
} eq 'pl') || (${Lang
::language
} eq 'sk')) {
206 # Czech, Hungarian, Polish and Slovak character set
207 foreach my $key(keys %Lang::tr
) {from_to
($tr{$key}, "utf-8", "iso-8859-2");}
208 } elsif (${Lang
::language
} eq 'tr') {
210 foreach my $key(keys %Lang::tr
) {from_to
($tr{$key}, "utf-8", "iso-8859-9");}
212 foreach my $key(keys %Lang::tr
) {from_to
($tr{$key}, "utf-8", "iso-8859-1");}
220 my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
221 system("unlink /tmp/hddstatus && touch /tmp/hddstatus");
222 print "\nFound following amount of disks:".@disks."\n";
226 print "Working on disk ".$disk.".\n";
230 my $newdiskstats = "";
231 my @array = split(/\//,$disk);
233 $diskstats = `cat /tmp/hddstats-$array[$#array]`;
235 my $newdiskstats = `/usr/bin/iostat -d -t $disk | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
237 my $status = `hdparm -C /dev/$disk | tail -1 | cut -d: -f2`;
240 if ($status !~/standby/ || $diskstats ne $newdiskstats){
241 if (-e
"/tmp/hddshutdown-".$array[$#array]){system("unlink /tmp/hddshutdown-".$array[$#array]);}
244 if (-e
"/tmp/hddshutdown-".$array[$#array]){$status = " standby\n";}
245 else{$status = " active\n";}
247 open(DATEI
, ">>/tmp/hddstatus") || die "Datei nicht gefunden";
248 print DATEI
$disk."-".$status;
251 updatehdddata
($disk);