]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/scripts/hddshutdown-state
3 # IPFire HDD Shutdown state reader
5 # This code is distributed under the terms of the GPL
7 # 11.05.2006 Arne Fitzenreiter
13 my $hdddev = "/dev/$hdd";
15 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
16 $atime, $mtime, $ctime, $blksize, $blocks) = stat($hdddev);
18 my $major = $rdev >> 8;
19 my $minor = ($rdev & 0xFF) >> 6;
21 open STAT
, "/proc/stat";
22 my @diskstat = <STAT
>;
24 foreach my $line (@diskstat)
27 my @temp = split(/\:\ /,$line);
29 my @devicestat = split(/\ /,$temp[1]);
30 foreach my $stats (@devicestat)
33 my @fields = split(/\((\d+),(\d+)\):\((\d+),(\d+),(\d+),(\d+),(\d+)/,$stats);
34 if ($major eq $fields[1] and $minor eq $fields[2])
36 $readwritereq = $fields[3];
42 if (! -e
"/tmp/hddshutdown-$hdd" ) {
43 print"<B>Disk $hdddev status:</B> unknown"
47 if ( -e
"/tmp/hddshutdown-$hdd" ) {
48 open STAT
,"/tmp/hddshutdown-$hdd";
49 my $lastsleepstate = <STAT
>;
51 my $ftime = localtime((stat("/tmp/hddshutdown-$hdd"))[9]);
52 if (! ($lastsleepstate==$readwritereq)) {
53 print"<B>Disk $hdddev status: <font color=#FF0000>active</font></B>";
55 if ( ($lastsleepstate==$readwritereq)) {
56 print"<B>Disk $hdddev status: <font color=#00FF00>standby</font></B> (since $ftime)";