mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
ADD: Adds additional parameters to the SSH call as specified.
git-svn-id: https://svn.fhem.de/fhem/trunk@26358 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b74141899f
commit
89f4413274
@ -53,7 +53,7 @@ use Data::Dumper;
|
||||
my $missingModulRemote;
|
||||
eval "use Net::Telnet;1" or $missingModulRemote .= "Net::Telnet ";
|
||||
|
||||
my $VERSION = "2.3.5";
|
||||
my $VERSION = "2.3.7";
|
||||
|
||||
use constant {
|
||||
PERL_VERSION => "perl_version",
|
||||
@ -147,11 +147,13 @@ SYSMON_Initialize($)
|
||||
$hash->{GetFn} = "SYSMON_Get";
|
||||
$hash->{SetFn} = "SYSMON_Set";
|
||||
$hash->{AttrFn} = "SYSMON_Attr";
|
||||
$hash->{NotifyFn} = "SYSMON_Notify";
|
||||
$hash->{AttrList} = "filesystems network-interfaces user-defined disable:0,1 nonblocking:0,1 ".
|
||||
"telnet-time-out ".
|
||||
"user-fn2 user-fn ".
|
||||
"telnet-prompt-regx telnet-login-prompt-regx ".
|
||||
"exclude ".
|
||||
"ssh-params ".
|
||||
$readingFnAttributes;
|
||||
}
|
||||
### attr NAME user-defined osUpdates:1440:Aktualisierungen:cat ./updates.txt [,<readingsName>:<Interval_Minutes>:<Comment>:<Cmd>]
|
||||
@ -216,14 +218,18 @@ SYSMON_Define($$)
|
||||
SYSMON_setInterval($hash, undef);
|
||||
}
|
||||
|
||||
$hash->{STATE} = "Initialized";
|
||||
$hash->{NOTIFYDEV} = "global,TYPE=SYSMON";
|
||||
#$hash->{STATE} = "Initialized";
|
||||
$hash->{STATE} = "Loaded";
|
||||
|
||||
#$hash->{DEF_TIME} = time() unless defined($hash->{DEF_TIME});
|
||||
|
||||
#SYSMON_updateCurrentReadingsMap($hash);
|
||||
|
||||
RemoveInternalTimer($hash);
|
||||
InternalTimer(gettimeofday()+$hash->{INTERVAL_BASE}, "SYSMON_Update", $hash, 0);
|
||||
if($init_done) {
|
||||
RemoveInternalTimer($hash);
|
||||
InternalTimer(gettimeofday()+$hash->{INTERVAL_BASE}, "SYSMON_Update", $hash, 0);
|
||||
}
|
||||
|
||||
#$hash->{LOCAL} = 1;
|
||||
#SYSMON_Update($hash); #-> so nicht. hat im Startvorgang gelegentlich (oft) den Server 'aufgehaengt'
|
||||
@ -232,6 +238,22 @@ SYSMON_Define($$)
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub SYSMON_Notify() {
|
||||
my ($hash,$dev) = @_;
|
||||
|
||||
if( $dev->{NAME} eq "global" ) {
|
||||
if( grep(m/^(INITIALIZED|REREADCFG)$/, @{$dev->{CHANGED}}) ) {
|
||||
#Log3($hash->{NAME},5,"SYSMON:DEBUG:> [$hash->{NAME}] notify for global ".Dumper(@{$dev->{CHANGED}}));
|
||||
# FHEM (re)Start
|
||||
RemoveInternalTimer($hash);
|
||||
InternalTimer(gettimeofday()+5+$hash->{INTERVAL_BASE}, "SYSMON_Update", $hash, 0);
|
||||
$hash->{STATE} = "Initialized";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
SYSMON_setInterval($@)
|
||||
{
|
||||
@ -863,8 +885,7 @@ SYSMON_Attr($$$)
|
||||
|
||||
#my $u_first_mark = undef;
|
||||
|
||||
sub
|
||||
SYSMON_Update($;$)
|
||||
sub SYSMON_Update($;$)
|
||||
{
|
||||
my ($hash, $refresh_all) = @_;
|
||||
|
||||
@ -879,6 +900,8 @@ SYSMON_Update($;$)
|
||||
InternalTimer(gettimeofday()+$hash->{INTERVAL_BASE}, "SYSMON_Update", $hash, 1);
|
||||
}
|
||||
|
||||
return unless($init_done);
|
||||
|
||||
if( AttrVal($name, "disable", "") eq "1" )
|
||||
{
|
||||
#SYSMON_Log($hash, 5, "disabled");
|
||||
@ -916,7 +939,6 @@ SYSMON_Update($;$)
|
||||
$hash->{helper}{READOUT_RUNNING_PID} = BlockingCall("SYSMON_blockingCall", $name."|".$refresh_all, "SYSMON_blockingFinish", 55, "SYSMON_blockingAbort", $hash);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -981,8 +1003,8 @@ sub SYSMON_blockingCall($) {
|
||||
# Nur wenn ein gueltiges Value vorliegt
|
||||
if(defined $value) {
|
||||
# Zeichen maskieren
|
||||
$value=~s/#/§²§/g;
|
||||
$value=~s/\|/§³§/g;
|
||||
$value=~s/#/§²§/g;
|
||||
$value=~s/\|/§³§/g;
|
||||
$ret.="|".$aName."|".$value;
|
||||
}
|
||||
}
|
||||
@ -1013,7 +1035,7 @@ sub SYSMON_test() {
|
||||
my $value = $map->{$aName};
|
||||
# Nur wenn ein gueltiges Value vorliegt
|
||||
if(defined $value) {
|
||||
$value=~s/#/§²§/g;
|
||||
$value=~s/#/§²§/g;
|
||||
$ret.="|".$aName."|".$value;
|
||||
}
|
||||
}
|
||||
@ -1089,8 +1111,8 @@ sub SYSMON_updateReadings($$) {
|
||||
# Nur aktualisieren, wenn ein gueltiges Value vorliegt
|
||||
if(defined $value) {
|
||||
# Maskierte Zeichen zuruechersetzen
|
||||
$value=~s/§²§/#/g;
|
||||
$value=~s/§³§/\|/g;
|
||||
$value=~s/§²§/#/g;
|
||||
$value=~s/§³§/\|/g;
|
||||
readingsBulkUpdate($hash,$aName,$value);
|
||||
}
|
||||
}
|
||||
@ -2737,12 +2759,12 @@ sub SYSMON_getNetworkInfo ($$$) {
|
||||
@dataThroughput = (
|
||||
"eth0 Link encap:Ethernet Hardware Adresse b8:27:eb:47:a9:8d",
|
||||
" inet Adresse:192.168.2.118 Bcast:192.168.2.255 Maske:255.255.255.0",
|
||||
" inet6-Adresse: 2003:46:b6b:3100:ba27:ebff:fe47:a98d/64 Gültigkeitsbereich:Global",
|
||||
" inet6-Adresse: fe80::ba27:ebff:fe47:a98d/64 Gültigkeitsbereich:Verbindung",
|
||||
" inet6-Adresse: 2003:46:b6b:3100:ba27:ebff:fe47:a98d/64 Gültigkeitsbereich:Global",
|
||||
" inet6-Adresse: fe80::ba27:ebff:fe47:a98d/64 Gültigkeitsbereich:Verbindung",
|
||||
" UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1",
|
||||
" RX packets:1224709 errors:0 dropped:0 overruns:0 frame:0",
|
||||
" TX packets:1156620 errors:0 dropped:0 overruns:0 carrier:0",
|
||||
" Kollisionen:0 Sendewarteschlangenlänge:1000",
|
||||
" Kollisionen:0 Sendewarteschlangenlänge:1000",
|
||||
" RX bytes:180806073 (172.4 MiB) TX bytes:108919337 (103.8 MiB)");
|
||||
}
|
||||
#--- DEBUG ---
|
||||
@ -3260,7 +3282,7 @@ sub SYSMON_getFBCRCFEC($$) {
|
||||
# Systemparameter als HTML-Tabelle ausgeben
|
||||
# Parameter: Name des SYSMON-Geraetes (muss existieren, kann auch anderer Modul genutzt werden), dessen Daten zur Anzeige gebracht werden sollen.
|
||||
# (optional) Liste der anzuzeigenden Werte (ReadingName[:Comment:[Postfix[:FormatString]]],...)
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesHTML('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesHTML('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
#------------------------------------------------------------------------------
|
||||
sub SYSMON_ShowValuesHTML ($;@)
|
||||
{
|
||||
@ -3273,7 +3295,7 @@ sub SYSMON_ShowValuesHTML ($;@)
|
||||
# Parameter: Name des SYSMON-Geraetes (muss existieren, kann auch anderer Modul genutzt werden), dessen Daten zur Anzeige gebracht werden sollen.
|
||||
# Title: Ueberschrift (Text)
|
||||
# (optional) Liste der anzuzeigenden Werte (ReadingName[:Comment:[Postfix[:FormatString]]],...)
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesHTML('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesHTML('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
#------------------------------------------------------------------------------
|
||||
sub SYSMON_ShowValuesHTMLTitled ($;$@)
|
||||
{
|
||||
@ -3287,7 +3309,7 @@ sub SYSMON_ShowValuesHTMLTitled ($;$@)
|
||||
# Systemparameter im Textformat ausgeben
|
||||
# Parameter: Name des SYSMON-Geraetes (muss existieren, kann auch anderer Modul genutzt werden), dessen Daten zur Anzeige gebracht werden sollen.
|
||||
# (optional) Liste der anzuzeigenden Werte (ReadingName[:Comment:[Postfix[:FormatString]]],...)
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesText('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesText('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
#------------------------------------------------------------------------------
|
||||
sub SYSMON_ShowValuesText ($;@)
|
||||
{
|
||||
@ -3300,7 +3322,7 @@ sub SYSMON_ShowValuesText ($;@)
|
||||
# Parameter: Name des SYSMON-Geraetes (muss existieren, kann auch anderer Modul genutzt werden), dessen Daten zur Anzeige gebracht werden sollen.
|
||||
# Title: Ueberschrift (Text)
|
||||
# (optional) Liste der anzuzeigenden Werte (ReadingName[:Comment:[Postfix[:FormatString]]],...)
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesText('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
# Beispiel: define sysv weblink htmlCode {SYSMON_ShowValuesText('sysmon', ('date:Datum', 'cpu_temp:CPU Temperatur: °C', 'cpu_freq:CPU Frequenz: MHz'))}
|
||||
#------------------------------------------------------------------------------
|
||||
sub SYSMON_ShowValuesTextTitled ($;$@)
|
||||
{
|
||||
@ -3336,7 +3358,7 @@ sub SYSMON_ShowValuesFmt ($$$;@)
|
||||
my @dataDescription = @data;
|
||||
if(scalar(@data)<=0) {
|
||||
# Array mit anzuzeigenden Parametern (Prefix, Name (in Map), Postfix)
|
||||
my $deg = "°";
|
||||
my $deg = "°";
|
||||
if($format == 1) {
|
||||
$deg = "°";
|
||||
}
|
||||
@ -3743,7 +3765,7 @@ sub SYSMON_PowerBatInfo($$) {
|
||||
$map->{"power_".$type."_text"}=$type.": ".(($d_present eq "1") ? "present" : "absent")." / ".($d_online eq "1" ? "online" : "offline").", voltage: ".$d_voltage." V, current: ".$d_current." mA, ".(int(($d_voltage*$d_current/100+0.5))/10)." W, "."capacity: ".$d_capacity." %";
|
||||
|
||||
if($d_present eq "1") {
|
||||
# Zusaetzlich: technology, capacity, status, health, temp (/10 => °C)
|
||||
# Zusaetzlich: technology, capacity, status, health, temp (/10 => °C)
|
||||
my $d_technology = trim(SYSMON_execute($hash, $base."technology 2>/dev/null"));
|
||||
my $d_status = trim(SYSMON_execute($hash, $base."status 2>/dev/null"));
|
||||
my $d_health = trim(SYSMON_execute($hash, $base."health 2>/dev/null"));
|
||||
@ -4203,6 +4225,8 @@ SYSMON_Exec_Ssh($$)
|
||||
|
||||
my $msg;
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
my $host = $hash->{HOST};#AttrVal( $name, "remote_host", undef );
|
||||
if(!defined $host) {
|
||||
$msg="Error: no remote host provided";
|
||||
@ -4223,8 +4247,14 @@ SYSMON_Exec_Ssh($$)
|
||||
|
||||
SYSMON_Log($hash, 5, "Execute '".$cmd."' by SSH");
|
||||
my $p_tmp = '';
|
||||
|
||||
my $sshParam = AttrVal($name,"ssh-params",undef);
|
||||
if(defined($sshParam)) {
|
||||
$p_tmp = $p_tmp.' '.$sshParam.' ';
|
||||
}
|
||||
|
||||
if(defined($port)) {
|
||||
$p_tmp = ' -p '.$port.' ';
|
||||
$p_tmp = $p_tmp.' -p '.$port.' ';
|
||||
}
|
||||
|
||||
my $call = "ssh ".$p_tmp.$user."\@".$host." ".'"'.$cmd.'"';
|
||||
@ -4691,6 +4721,10 @@ sub SYSMON_Log($$$) {
|
||||
fbwlan, fbnightctrl, fbnewmessages, fbdecttemp, fbversion, fbdsl, powerinfo
|
||||
</li>
|
||||
<br>
|
||||
<li>ssh-param<br>
|
||||
Adds additional parameters to the SSH call as specified.
|
||||
</li>
|
||||
<br>
|
||||
</ul>
|
||||
<br>
|
||||
<b>Plots:</b><br><br>
|
||||
@ -4912,7 +4946,7 @@ sub SYSMON_Log($$$) {
|
||||
<br>
|
||||
Bei SSH-Anmeldung mit Passwort muss 'sshpass' installiert sein (Achtung! Sicherheitstechnisch nicht empfehlenswert! Besser Public-Key-Verfahren benutzen).
|
||||
Damit SSH-Anmeldung funktioniert, muss ggf. einmalig eine manuelle SSH-Verbindung an die Remote-Machine von dem FHEM-Acount
|
||||
(unter dessen Rechten FHEM läuft) durchgeführt und fingerprint bestätigt werden.
|
||||
(unter dessen Rechten FHEM läuft) durchgeführt und fingerprint bestätigt werden.
|
||||
<br>
|
||||
<br>
|
||||
<b>Readings:</b>
|
||||
@ -5261,11 +5295,15 @@ sub SYSMON_Log($$$) {
|
||||
<br>
|
||||
<li>exclude<br>
|
||||
Erlaubt das Abfragen bestimmten Informationen zu unterbinden. <br>
|
||||
Mögliche Werte: user-defined (s. user-defined und user-fn), cpucount, uptime, fhemuptime,
|
||||
Mögliche Werte: user-defined (s. user-defined und user-fn), cpucount, uptime, fhemuptime,
|
||||
loadavg, cputemp, cpufreq, cpuinfo, diskstat, cpustat, ramswap, filesystem, network,
|
||||
fbwlan, fbnightctrl, fbnewmessages, fbdecttemp, fbversion, fbdsl, powerinfo
|
||||
</li>
|
||||
<br>
|
||||
<li>ssh-param<br>
|
||||
Fügt dem SSH-Aufruf zusätzliche Prameter, wie angegeben hinzu.
|
||||
</li>
|
||||
<br>
|
||||
</ul>
|
||||
<br>
|
||||
<b>Plots:</b><br><br>
|
||||
|
Loading…
Reference in New Issue
Block a user