mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
allow (remote) monitoring of raspberry pi on chip temperature
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@3108 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
39340f2e93
commit
309dae89b8
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 chip temperature
|
||||||
- feature: HUEDevice: use webCmdFn for colorpicker
|
- feature: HUEDevice: use webCmdFn for colorpicker
|
||||||
added jscolor for colorpicker
|
added jscolor for colorpicker
|
||||||
- feature: FHEMWEB: module specific summaryFn/detailFn + defineable webCmdFn
|
- feature: FHEMWEB: module specific summaryFn/detailFn + defineable webCmdFn
|
||||||
|
@ -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 showpercent:1 useregex:1 ssh_user loglevel:0,1,2,3,4,5,6 ".
|
$hash->{AttrList} = "filesystems raspberrytemperature:1 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 "raspberrytemperature");
|
||||||
|
|
||||||
if( $attrName eq "filesystems") {
|
if( $attrName eq "filesystems") {
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
@ -143,6 +144,7 @@ SYSSTAT_Attr($$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub SYSSTAT_getLoadAVG( $ );
|
sub SYSSTAT_getLoadAVG( $ );
|
||||||
|
sub SYSSTAT_getPiTemp( $ );
|
||||||
sub
|
sub
|
||||||
SYSSTAT_GetUpdate($)
|
SYSSTAT_GetUpdate($)
|
||||||
{
|
{
|
||||||
@ -197,9 +199,15 @@ SYSSTAT_GetUpdate($)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( AttrVal($hash->{NAME}, "raspberrytemperature", "") ne "" ) {
|
||||||
|
my $temp = SYSSTAT_getPiTemp($hash);
|
||||||
|
readingsSingleUpdate($hash,"temperature",$temp,defined($hash->{LOCAL} ? 0 : 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub SYSSTAT_getLoadAVG( $ )
|
sub
|
||||||
|
SYSSTAT_getLoadAVG( $ )
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
@ -236,6 +244,37 @@ sub SYSSTAT_getLoadAVG( $ )
|
|||||||
return $hash->{loadavg}->get;
|
return $hash->{loadavg}->get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
SYSSTAT_getPiTemp( $ )
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
|
||||||
|
my $filename = "/sys/class/thermal/thermal_zone0/temp";
|
||||||
|
|
||||||
|
my $temp;
|
||||||
|
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|" ) ) {
|
||||||
|
$temp = <$fh>;
|
||||||
|
close($fh);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if( open( my $fh, '<', $filename ) )
|
||||||
|
{
|
||||||
|
$temp = <$fh>;
|
||||||
|
|
||||||
|
close($fh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $temp / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
@ -323,6 +362,8 @@ sub SYSSTAT_getLoadAVG( $ )
|
|||||||
</ul></li></lu>
|
</ul></li></lu>
|
||||||
<li>showpercent<br>
|
<li>showpercent<br>
|
||||||
If set the usage is shown in percent. If not set the remaining free space in bytes is shown.</li>
|
If set the usage is shown in percent. If not set the remaining free space in bytes is shown.</li>
|
||||||
|
<li>raspberrytemperature<br>
|
||||||
|
If set the raspberry pi on chip termal sensor is read.</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