]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/scripts/makegraphs
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";
35 my $rrdlog = '/var/log/rrd';
37 my $path_smartctl = "/usr/sbin/smartctl";
40 my %mainsettings = ();
41 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
42 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
48 my @array = split(/\//,$disk);
50 if ( ! -e
"$rrdlog/hddshutdown-".$array[$#array].".rrd"){
51 # database did not exist -> create
52 RRDs
::create
("$rrdlog/hddshutdown-".$array[$#array].".rrd", "--step=300",
53 "DS:standby:GAUGE:600:0:1",
54 "RRA:AVERAGE:0.5:1:576",
55 "RRA:AVERAGE:0.5:6:672",
56 "RRA:AVERAGE:0.5:24:732",
57 "RRA:AVERAGE:0.5:144:1460");
59 print "Error in RRD::create for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR;
62 if (-e
"/tmp/hddshutdown-".$array[$#array]) {$standby = 1;}
65 RRDs
::update
("$rrdlog/hddshutdown-".$array[$#array].".rrd", "-t", "standby", "N:$standby");
67 print "Error in RRD::update for hddshutdown-".$array[$#array].": $ERROR\n" if $ERROR;
69 if ( ! -e
"$rrdlog/hddtemp-".$array[$#array].".rrd"){
70 # database did not exist -> create
71 RRDs
::create
("$rrdlog/hddtemp-".$array[$#array].".rrd", "--step=300",
72 "DS:temperature:GAUGE:600:0:100",
73 "RRA:AVERAGE:0.5:1:576",
74 "RRA:AVERAGE:0.5:6:672",
75 "RRA:AVERAGE:0.5:24:732",
76 "RRA:AVERAGE:0.5:144:1460");
78 print "Error in RRD::create for hdd-".$array[$#array].": $ERROR\n" if $ERROR;
81 # Temperaturlesen w�rde die Platte aufwecken!!!
84 my $smart_output = '';
85 system("$path_smartctl -iHA -d ata /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
86 if ( -e
"/var/log/smartctl_out_hddtemp-".$array[$#array] ){
87 my $hdd_output = `cat /var/log/smartctl_out_hddtemp-$array[$#array] | grep Temperature_`;
88 my @t = split(/\s+/,$hdd_output);
91 print "Temperature for ".$array[$#array]."->".$temp."<-\n";
92 # Nur ins RDD wenn nicht 0 (sonst klappt die min Anzeige nicht)
94 RRDs
::update
("$rrdlog/hddtemp-".$array[$#array].".rrd", "-t", "temperature", "N:$temp");
96 print "Error in RRD::update for hdd-".$array[$#array].": $ERROR\n" if $ERROR;
102 #system ('/usr/sbin/fetchipac');
104 system ('/usr/bin/vnstat -u');
106 my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
107 system("unlink /tmp/hddstatus && touch /tmp/hddstatus");
111 print "Working on disk ".$disk.".\n";
115 my $newdiskstats = "";
116 my @array = split(/\//,$disk);
118 $diskstats = `cat /tmp/hddstats-$array[$#array]`;
120 my $newdiskstats = `/usr/bin/iostat -d -t $disk | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
122 my $status = `hdparm -C /dev/$disk | tail -1 | cut -d: -f2`;
125 if ($status !~/standby/ || $diskstats ne $newdiskstats){
126 if (-e
"/tmp/hddshutdown-".$array[$#array]){system("unlink /tmp/hddshutdown-".$array[$#array]);}
129 if (-e
"/tmp/hddshutdown-".$array[$#array]){$status = " standby\n";}
130 else{$status = " active\n";}
132 open(DATEI
, ">>/tmp/hddstatus") || die "Datei nicht gefunden";
133 print DATEI
$disk."-".$status;
136 updatehdddata
($disk);