mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-24 09:52:58 +02:00
Hddstatus auf der Media CGI nochmal ueberarbeitet
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@796 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
@@ -12,23 +12,10 @@
|
||||
my @proc = `cat /proc/diskstats`;
|
||||
my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
|
||||
my %diskstatus = "";
|
||||
my %diskstate = "";
|
||||
my $debug = 1;
|
||||
my $status = "unknown";
|
||||
|
||||
if ( @ARGV[0] eq "state" ){
|
||||
my $hdd = @ARGV[1];
|
||||
$status = `hdparm -C /dev/$hdd | tail -1 | cut -d: -f2`;
|
||||
|
||||
if ( $status=~/standby/){
|
||||
my $ftime = localtime((stat("/tmp/hddshutdown-$hdd"))[9]);
|
||||
print"<B>Disk $hdd status: <font color=#00FF00>standby</font></B> (since $ftime)";
|
||||
}
|
||||
else{
|
||||
print"<B>Disk $hdd status: <font color=#FF0000>active</font></B>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($debug){print "### Reading Diskstats ###\n";}
|
||||
|
||||
foreach (@proc){
|
||||
@@ -54,4 +41,5 @@ $status = `hdparm -C /dev/$_ | tail -1 | cut -d: -f2`;
|
||||
if ( -e "/tmp/hddshutdown-$_" ) { system("unlink /tmp/hddshutdown-$_"); }
|
||||
}
|
||||
}
|
||||
|
||||
# end
|
||||
|
||||
@@ -415,7 +415,6 @@ sub updatehdddata
|
||||
$ERROR = RRDs::error;
|
||||
print "Error in RRD::create for hdd-$disk: $ERROR\n" if $ERROR;
|
||||
}
|
||||
|
||||
$temp = 0;
|
||||
my $hdd_output = '';
|
||||
my $smart_output = '';
|
||||
@@ -564,14 +563,22 @@ updatememdata();
|
||||
### HDD graphs
|
||||
###
|
||||
|
||||
|
||||
my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
|
||||
system("unlink /tmp/hddstatus && touch /tmp/hddstatus");
|
||||
print "\nFound following amount of disks:".@disks."\n";
|
||||
foreach (@disks){
|
||||
my $disk = $_;
|
||||
chomp $disk;
|
||||
print "Working on disk ".$disk.".\n";
|
||||
|
||||
updatediskdata($disk);
|
||||
updatehdddata($disk);
|
||||
|
||||
my $status = `hdparm -C /dev/$disk | tail -1 | cut -d: -f2`;
|
||||
open(DATEI, ">>/tmp/hddstatus") || die "Datei nicht gefunden";
|
||||
print DATEI $disk."-".$status;
|
||||
close(DATEI);
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
Reference in New Issue
Block a user