Hinzugefügt:

* HDDGraphs für mehrere Festplatten
  * Höhere Baudrate in pppsetup.cgi
Geändert:
  * Sprachen auf DE und EN reduziert.


git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@162 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
ms
2006-06-05 17:35:00 +00:00
parent 2175773794
commit 6c666a3b18
15 changed files with 536 additions and 104 deletions

117
src/scripts/hddshutdown Normal file
View File

@@ -0,0 +1,117 @@
#!/usr/bin/perl
#
# IPFire HDD Shutdown
#
# This code is distributed under the terms of the GPL
#
# 13.05.2006 Arne Fitzenreiter
#
# begin
sub shutdown_hdd {
my $hdd = $_[0];
my $hdddev = "/dev/$_[0]";
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = stat($hdddev);
my $major = $rdev >> 8;
my $minor = ($rdev & 0xFF) >> 6;
open STAT, "/tmp/hddshutdown-stat";
my @diskstat = <STAT>;
close (STAT);
foreach my $line (@diskstat)
{
chomp ($line);
my @temp = split(/\:\ /,$line);
if ($temp[1]) {
my @devicestat = split(/\ /,$temp[1]);
foreach my $stats (@devicestat)
{
chomp ($stats);
my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
if ($major eq $fields[1] and $minor eq $fields[2])
{
$lastreadwritereq = $fields[3];
}
}
}
}
open STAT, "/proc/stat";
my @diskstat = <STAT>;
close (STAT);
foreach my $line (@diskstat)
{
chomp ($line);
my @temp = split(/\:\ /,$line);
if ($temp[1]) {
my @devicestat = split(/\ /,$temp[1]);
foreach my $stats (@devicestat)
{
chomp ($stats);
my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
if ($major eq $fields[1] and $minor eq $fields[2])
{
$readwritereq = $fields[3];
}
}
}
}
if (! -e "/tmp/hddshutdown-$hdd" ) { system("echo 0 > /tmp/hddshutdown-$hdd"); }
if ($readwritereq==$lastreadwritereq) {
open STAT,"/tmp/hddshutdown-$hdd";
my $lastsleepstate = <STAT>;
close (STAT);
if (! ($lastsleepstate==$readwritereq)) {
system("hdparm -y $hdddev");
system("logger -t ipcop Shuting down $hdddev !");
system("echo $readwritereq > /tmp/hddshutdown-$hdd");
}
}
}
if ( -e "/tmp/hddshutdown-stat" ) {
if (open STAT,"/dev/hda") {
close STAT;
shutdown_hdd("hda");
}
if (open STAT,"/dev/hdb") {
close STAT;
shutdown_hdd("hdb");
}
if (open STAT,"/dev/hdc") {
close STAT;
shutdown_hdd("hdc");
}
if (open STAT,"/dev/hdd") {
close STAT;
shutdown_hdd("hdd");
}
if (open STAT,"/dev/hde") {
close STAT;
shutdown_hdd("hde");
}
if (open STAT,"/dev/hdf") {
close STAT;
shutdown_hdd("hdf");
}
if (open STAT,"/dev/hdg") {
close STAT;
shutdown_hdd("hdg");
}
if (open STAT,"/dev/hdh") {
close STAT;
shutdown_hdd("hdh");
}
}
system("cp /proc/stat /tmp/hddshutdown-stat");
# end

View File

@@ -0,0 +1,63 @@
#!/usr/bin/perl
#
# IPFire HDD Shutdown state reader
#
# This code is distributed under the terms of the GPL
#
# 11.05.2006 Arne Fitzenreiter
#
# begin
my $hdd = @ARGV[0];
my $hdddev = "/dev/$hdd";
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = stat($hdddev);
my $major = $rdev >> 8;
my $minor = ($rdev & 0xFF) >> 6;
open STAT, "/proc/stat";
my @diskstat = <STAT>;
close (STAT);
foreach my $line (@diskstat)
{
chomp ($line);
my @temp = split(/\:\ /,$line);
if ($temp[1]) {
my @devicestat = split(/\ /,$temp[1]);
foreach my $stats (@devicestat)
{
chomp ($stats);
my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
if ($major eq $fields[1] and $minor eq $fields[2])
{
$readwritereq = $fields[3];
}
}
}
}
if (! -e "/tmp/hddshutdown-$hdd" ) {
print"<B>Disk $hdddev status:</B> unknown"
}
if ( -e "/tmp/hddshutdown-$hdd" ) {
open STAT,"/tmp/hddshutdown-$hdd";
my $lastsleepstate = <STAT>;
close (STAT);
my $ftime = localtime((stat("/tmp/hddshutdown-$hdd"))[9]);
if (! ($lastsleepstate==$readwritereq)) {
print"<B>Disk $hdddev status: <font color=#FF0000>active</font></B>";
}
if ( ($lastsleepstate==$readwritereq)) {
print"<B>Disk $hdddev status: <font color=#00FF00>standby</font></B> (since $ftime)";
}
}
# end

View File

@@ -341,6 +341,107 @@ sub updatediskdata {
}
}
sub updatediskgraphnew {
my $disk = $_[0];
my $period = $_[1];
RRDs::graph ("$graphs/disk-$disk-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-z",
"--alt-y-grid", "-w 600", "-h 100", "-l 0", "-r",
"--color", "SHADEA#EAE9EE",
"--color", "SHADEB#EAE9EE",
"--color", "BACK#FFFFFF",
"-t $tr{'disk access per'} $tr{$period}",
"DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE",
"DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE",
"DEF:sleep=$rrdlog/disk-$disk.rrd:sleeping:AVERAGE",
"CDEF:sl_state=sleep,INF,*",
"AREA:sl_state#a0a0a0:disk standby\\j",
"AREA:read#0000FF:$tr{'sectors read from disk per second'}\\j",
"STACK:write#00FF00:$tr{'sectors written to disk per second'}\\j",
"GPRINT:read:MAX:$tr{'maximal'} $tr{'read sectors'}\\:%8.0lf",
"GPRINT:read:AVERAGE:$tr{'average'} $tr{'read sectors'}\\:%8.0lf",
"GPRINT:read:LAST:$tr{'current'} $tr{'read sectors'}\\:%8.0lf\\j",
"GPRINT:write:MAX:$tr{'maximal'} $tr{'written sectors'}\\:%8.0lf",
"GPRINT:write:AVERAGE:$tr{'average'} $tr{'written sectors'}\\:%8.0lf",
"GPRINT:write:LAST:$tr{'current'} $tr{'written sectors'}\\:%8.0lf\\j");
$ERROR = RRDs::error;
print "Error in RRD::graph for disk-$disk: $ERROR\n" if $ERROR;
}
sub updatediskdatanew {
my $disk = $_[0];
my ($readwritereq, $readreq, $readsect, $writereq, $writesect);
if ( ! -e "$rrdlog/disk-$disk.rrd") {
RRDs::create ("$rrdlog/disk-$disk.rrd", "--step=300",
"DS:readsect:COUNTER:600:0:5000000000",
"DS:writesect:COUNTER:600:0:5000000000",
"DS:sleeping:GAUGE:600:0:1",
"RRA:AVERAGE:0.5:1:576",
"RRA:AVERAGE:0.5:6:672",
"RRA:AVERAGE:0.5:24:732",
"RRA:AVERAGE:0.5:144:1460");
$ERROR = RRDs::error;
print "Error in RRD::create for disk-$disk: $ERROR\n" if $ERROR;
}
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime, $mtime, $ctime, $blksize, $blocks) = stat("/dev/$disk");
my $major = $rdev >> 8;
my $minor = ($rdev & 0xFF) >>6;
open STAT, "/proc/stat";
my @diskstat = <STAT>;
close (STAT);
foreach my $line (@diskstat)
{
chomp ($line);
my @temp = split(/\:\ /,$line);
if ($temp[1]) {
my @devicestat = split(/\ /,$temp[1]);
foreach my $stats (@devicestat)
{
chomp ($stats);
my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
if ($major eq $fields[1] and $minor eq $fields[2])
{
$readwritereq = $fields[3];
$readreq = $fields[4];
$readsect = $fields[5];
$writereq = $fields[6];
$writesect = $fields[7];
}
}
}
}
my $sleeping=0;
my $lastsleepstate=0;
if ( -e "/tmp/hddshutdown-$disk" ) {
open STAT,"/tmp/hddshutdown-$disk";
$lastsleepstate = <STAT>;
close (STAT);
if ($lastsleepstate==$readwritereq) {
$sleeping=1;
}
}
if ($readsect && $writesect) {
RRDs::update ("$rrdlog/disk-$disk.rrd",
"-t", "readsect:writesect:sleeping",
"N:$readsect:$writesect:$sleeping");
$ERROR = RRDs::error;
print "Error in RRD::update for disk-$disk: $ERROR\n" if $ERROR;
} else {
print "Error in RRD::update for disk-$disk: no data available\n";
}
}
sub updateifgraph {
my $interface = $_[0];
my $period = $_[1];
@@ -627,6 +728,110 @@ updatediskgraph ("week");
updatediskgraph ("month");
updatediskgraph ("year");
if (open STAT,"/dev/hda") {
close STAT;
updatediskdatanew ("hda");
updatediskgraphnew ("hda","day");
updatediskgraphnew ("hda","week");
updatediskgraphnew ("hda","month");
updatediskgraphnew ("hda","year");
} else {
if (-e "$graphs/disk-hda-day.png") {
system("rm $graphs/disk-hda-day.png");
}
}
if (open STAT,"/dev/hdb") {
close STAT;
updatediskdatanew ("hdb");
updatediskgraphnew ("hdb","day");
updatediskgraphnew ("hdb","week");
updatediskgraphnew ("hdb","month");
updatediskgraphnew ("hdb","year");
} else {
if (-e "$graphs/disk-hdb-day.png") {
system("rm $graphs/disk-hdb-day.png");
}
}
if (open STAT,"/dev/hdc") {
close STAT;
updatediskdatanew ("hdc");
updatediskgraphnew ("hdc","day");
updatediskgraphnew ("hdc","week");
updatediskgraphnew ("hdc","month");
updatediskgraphnew ("hdc","year");
} else {
if (-e "$graphs/disk-hdc-day.png") {
system("rm $graphs/disk-hdc-day.png");
}
}
if (open STAT,"/dev/hdd") {
close STAT;
updatediskdatanew ("hdd");
updatediskgraphnew ("hdd","day");
updatediskgraphnew ("hdd","week");
updatediskgraphnew ("hdd","month");
updatediskgraphnew ("hdd","year");
} else {
if (-e "$graphs/disk-hdd-day.png") {
system("rm $graphs/disk-hdd-day.png");
}
}
if (open STAT,"/dev/hde") {
close STAT;
updatediskdatanew ("hde");
updatediskgraphnew ("hde","day");
updatediskgraphnew ("hde","week");
updatediskgraphnew ("hde","month");
updatediskgraphnew ("hde","year");
} else {
if (-e "$graphs/disk-hde-day.png") {
system("rm $graphs/disk-hde-day.png");
}
}
if (open STAT,"/dev/hdf") {
close STAT;
updatediskdatanew ("hdf");
updatediskgraphnew ("hdf","day");
updatediskgraphnew ("hdf","week");
updatediskgraphnew ("hdf","month");
updatediskgraphnew ("hdf","year");
} else {
if (-e "$graphs/disk-hdf-day.png") {
system("rm $graphs/disk-hdf-day.png");
}
}
if (open STAT,"/dev/hdg") {
close STAT;
updatediskdatanew ("hdg");
updatediskgraphnew ("hdg","day");
updatediskgraphnew ("hdg","week");
updatediskgraphnew ("hdg","month");
updatediskgraphnew ("hdg","year");
} else {
if (-e "$graphs/disk-hdg-day.png") {
system("rm $graphs/disk-hdg-day.png");
}
}
if (open STAT,"/dev/hdh") {
close STAT;
updatediskdatanew ("hdh");
updatediskgraphnew ("hdh","day");
updatediskgraphnew ("hdh","week");
updatediskgraphnew ("hdh","month");
updatediskgraphnew ("hdh","year");
} else {
if (-e "$graphs/disk-hdh-day.png") {
system("rm $graphs/disk-hdh-day.png");
}
}
###
### Firewallhits
###