2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-28 02:44:53 +00:00

added option do display uptime in seconds

git-svn-id: https://svn.fhem.de/fhem/trunk@3563 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2013-07-31 18:51:30 +00:00
parent f871813150
commit e3e75a2d85

@ -17,7 +17,7 @@ SYSSTAT_Initialize($)
$hash->{UndefFn} = "SYSSTAT_Undefine";
$hash->{GetFn} = "SYSSTAT_Get";
$hash->{AttrFn} = "SYSSTAT_Attr";
$hash->{AttrList} = "filesystems raspberrycpufreq:1 raspberrytemperature:0,1,2 showpercent:1 uptime:1 useregex:1 ssh_user loglevel:0,1,2,3,4,5,6 ".
$hash->{AttrList} = "filesystems raspberrycpufreq:1 raspberrytemperature:0,1,2 showpercent:1 uptime:1,2 useregex:1 ssh_user loglevel:0,1,2,3,4,5,6 ".
$readingFnAttributes;
}
@ -352,12 +352,25 @@ sub
SYSSTAT_getUptime($)
{
my ($hash) = @_;
my $name = $hash->{NAME};
my $uptime = SYSSTAT_readCmd($hash,"uptime",0);
$uptime = $1 if( $uptime =~ m/up\s((\d+\D+,\s)?[\d:]+)/ );
$uptime = $1 if( $uptime =~ m/up\s+(((\d+)\D+,\s+)?(\d+):(\d+))/ );
$uptime = "0 days, $uptime" if( !$2);
if( AttrVal($name, "uptime", "0") == 2 ) {
my $days = $3?$3:0;
my $hours = $4;
my $minutes = $5;
$uptime = $days * 24;
$uptime += $hours;
$uptime *= 60;
$uptime += $minutes;
$uptime *= 60;
}
return $uptime;
}
@ -456,6 +469,7 @@ SYSSTAT_getUptime($)
If set to 2 a geometric average over the last 4 values is created.</li>
<li>uptime<br>
If set and > 0 the system uptime is read.<br>
If set to 2 the uptime is displayed in seconds.</li>
<li>useregex<br>
If set the entries of the filesystems list are treated as regex.</li>
<li>ssh_user<br>