mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
SYSSTAT: allow (remote) monitoring raspberry pi on cpu frequency
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@3228 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3c17d4e179
commit
586d2f5e3a
1
CHANGED
1
CHANGED
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII
|
# Add changes at the top of the list. Keep it in ASCII
|
||||||
- SVN
|
- SVN
|
||||||
|
- feature: SYSSTAT: allow (remote) monitoring raspberry pi on cpu frequency
|
||||||
- feature: MANTAINER.txt added
|
- feature: MANTAINER.txt added
|
||||||
- feature: PRESENCE: new mode "shellscript" to use own
|
- feature: PRESENCE: new mode "shellscript" to use own
|
||||||
scripts or binaries for presence recognition
|
scripts or binaries for presence recognition
|
||||||
|
@ -15,7 +15,7 @@ SYSSTAT_Initialize($)
|
|||||||
$hash->{UndefFn} = "SYSSTAT_Undefine";
|
$hash->{UndefFn} = "SYSSTAT_Undefine";
|
||||||
$hash->{GetFn} = "SYSSTAT_Get";
|
$hash->{GetFn} = "SYSSTAT_Get";
|
||||||
$hash->{AttrFn} = "SYSSTAT_Attr";
|
$hash->{AttrFn} = "SYSSTAT_Attr";
|
||||||
$hash->{AttrList} = "filesystems raspberrytemperature:0,1,2 showpercent:1 useregex:1 ssh_user loglevel:0,1,2,3,4,5,6 ".
|
$hash->{AttrList} = "filesystems raspberrycpufreq:1 raspberrytemperature:0,1,2 showpercent:1 useregex:1 ssh_user loglevel:0,1,2,3,4,5,6 ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +121,7 @@ SYSSTAT_Attr($$$)
|
|||||||
my $orig = $attrVal;
|
my $orig = $attrVal;
|
||||||
$attrVal= "1" if($attrName eq "useregex");
|
$attrVal= "1" if($attrName eq "useregex");
|
||||||
$attrVal= "1" if($attrName eq "showpercent");
|
$attrVal= "1" if($attrName eq "showpercent");
|
||||||
|
$attrVal= "1" if($attrName eq "raspberrycpufreq");
|
||||||
|
|
||||||
if( $attrName eq "filesystems") {
|
if( $attrName eq "filesystems") {
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
@ -209,6 +210,11 @@ SYSSTAT_GetUpdate($)
|
|||||||
readingsSingleUpdate($hash,"temperature",$temp,defined($hash->{LOCAL} ? 0 : 1));
|
readingsSingleUpdate($hash,"temperature",$temp,defined($hash->{LOCAL} ? 0 : 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( AttrVal($name, "raspberrycpufreq", "0") > 0 ) {
|
||||||
|
my $freq = SYSSTAT_getPiFreq($hash);
|
||||||
|
readingsSingleUpdate($hash,"cpufreq",$freq,defined($hash->{LOCAL} ? 0 : 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@ -280,6 +286,37 @@ SYSSTAT_getPiTemp( $ )
|
|||||||
return $temp / 1000;
|
return $temp / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
SYSSTAT_getPiFreq( $ )
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
my $filename = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq";
|
||||||
|
|
||||||
|
my $freq = 0;
|
||||||
|
if( defined($hash->{HOST}) ) {
|
||||||
|
my $cmd = qx(which ssh);
|
||||||
|
chomp( $cmd );
|
||||||
|
my $user = AttrVal($hash->{NAME}, "ssh_user", undef );
|
||||||
|
$cmd .= ' ';
|
||||||
|
$cmd .= $user."\@" if( defined($user) );
|
||||||
|
$cmd .= $hash->{HOST}." cat ". $filename ." 2>/dev/null";
|
||||||
|
if( open(my $fh, "$cmd|" ) ) {
|
||||||
|
$freq = <$fh>;
|
||||||
|
close($fh);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if( open( my $fh, '<', $filename ) )
|
||||||
|
{
|
||||||
|
$freq = <$fh>;
|
||||||
|
|
||||||
|
close($fh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $freq / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
@ -370,6 +407,9 @@ SYSSTAT_getPiTemp( $ )
|
|||||||
<li>raspberrytemperature<br>
|
<li>raspberrytemperature<br>
|
||||||
If set and > 0 the raspberry pi on chip termal sensor is read.<br>
|
If set and > 0 the raspberry pi on chip termal sensor is read.<br>
|
||||||
If set to 2 a geometric average over the last 4 values is created.</li>
|
If set to 2 a geometric average over the last 4 values is created.</li>
|
||||||
|
<li>raspberrycpufreq<br>
|
||||||
|
If set and > 0 the raspberry pi on chip termal sensor is read.<br>
|
||||||
|
If set to 2 a geometric average over the last 4 values is created.</li>
|
||||||
<li>useregex<br>
|
<li>useregex<br>
|
||||||
If set the entries of the filesystems list are treated as regex.</li>
|
If set the entries of the filesystems list are treated as regex.</li>
|
||||||
<li>ssh_user<br>
|
<li>ssh_user<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user