]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/makegraphs
5369ab9d9e78102e4add650a74cd0983a5fb31d5
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";
33 $ENV{PATH
}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
36 my $path_smartctl = "/usr/sbin/smartctl";
39 my %mainsettings = ();
40 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
41 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
47 my @array = split(/\//,$disk);
49 if ( ! -e
"$mainsettings{'RRDLOG'}/hddshutdown-".$array[$#array].".rrd"){
50 # database did not exist -> create
51 RRDs
::create
("$mainsettings{'RRDLOG'}/hddshutdown-".$array[$#array].".rrd", "--step=300",
52 "DS:standby:GAUGE:600:0:1",
53 "RRA:AVERAGE:0.5:1:576",
54 "RRA:AVERAGE:0.5:6:672",
55 "RRA:AVERAGE:0.5:24:732",
56 "RRA:AVERAGE:0.5:144:1460");
58 print "Error in RRD::create for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR;
61 if (-e
"/tmp/hddshutdown-".$array[$#array]) {$standby = 1;}
64 RRDs
::update
("$mainsettings{'RRDLOG'}/hddshutdown-".$array[$#array].".rrd", "-t", "standby", "N:$standby");
66 print "Error in RRD::update for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR;
68 if ( ! -e
"$mainsettings{'RRDLOG'}/hddtemp-".$array[$#array].".rrd"){
69 # database did not exist -> create
70 RRDs
::create
("$mainsettings{'RRDLOG'}/hddtemp-".$array[$#array].".rrd", "--step=300",
71 "DS:temperature:GAUGE:600:0:100",
72 "RRA:AVERAGE:0.5:1:576",
73 "RRA:AVERAGE:0.5:6:672",
74 "RRA:AVERAGE:0.5:24:732",
75 "RRA:AVERAGE:0.5:144:1460");
77 print "Error in RRD::create for hdd-".$array[$#array].": $ERROR\n" if $ERROR;
80 # Temperaturlesen w�rde die Platte aufwecken!!!
83 my $smart_output = '';
84 system("$path_smartctl -iHA -d ata /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
85 if ( -e
"/var/log/smartctl_out_hddtemp-".$array[$#array] ){
86 my $hdd_output = `cat /var/log/smartctl_out_hddtemp-$array[$#array] | grep Temperature_`;
87 my @t = split(/\s+/,$hdd_output);
90 print "Temperature for ".$array[$#array]."->".$temp."<-\n";
91 # Nur ins RDD wenn nicht 0 (sonst klappt die min Anzeige nicht)
93 RRDs
::update
("$mainsettings{'RRDLOG'}/hddtemp-".$array[$#array].".rrd", "-t", "temperature", "N:$temp");
95 print "Error in RRD::update for hdd-".$array[$#array].": $ERROR\n" if $ERROR;
101 #system ('/usr/sbin/fetchipac');
103 system ('/usr/bin/vnstat -u');
105 my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
106 system("unlink /tmp/hddstatus && touch /tmp/hddstatus");
110 print "Working on disk ".$disk.".\n";
114 my $newdiskstats = "";
115 my @array = split(/\//,$disk);
117 $diskstats = `cat /tmp/hddstats-$array[$#array]`;
119 my $newdiskstats = `/usr/bin/iostat -d -t $disk | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
121 my $status = `hdparm -C /dev/$disk | tail -1 | cut -d: -f2`;
124 if ($status !~/standby/ || $diskstats ne $newdiskstats){
125 if (-e
"/tmp/hddshutdown-".$array[$#array]){system("unlink /tmp/hddshutdown-".$array[$#array]);}
128 if (-e
"/tmp/hddshutdown-".$array[$#array]){$status = " standby\n";}
129 else{$status = " active\n";}
131 open(DATEI
, ">>/tmp/hddstatus") || die "Datei nicht gefunden";
132 print DATEI
$disk."-".$status;
135 updatehdddata
($disk);