diff --git a/fhem/CHANGED b/fhem/CHANGED index 806877d1c..52c3b4bcd 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: SYSSTAT: added mibs attribute for snmp monitoring - bugfix: Dashboard: fixed CSS height issue for rows (top, center, bottom) - feature: FB_CALLLIST: new attribute "external-mapping", new column for external_connection reading (see commandref for details, by Michael) diff --git a/fhem/FHEM/32_SYSSTAT.pm b/fhem/FHEM/32_SYSSTAT.pm index 5cccb6890..dbd210908 100644 --- a/fhem/FHEM/32_SYSSTAT.pm +++ b/fhem/FHEM/32_SYSSTAT.pm @@ -42,7 +42,7 @@ SYSSTAT_Initialize($) $hash->{GetFn} = "SYSSTAT_Get"; $hash->{AttrFn} = "SYSSTAT_Attr"; $hash->{AttrList} = "disable:1 disabledForIntervals raspberrycpufreq:1 raspberrytemperature:0,1,2 synologytemperature:0,1,2 stat:1 uptime:1,2 ssh_user "; - $hash->{AttrList} .= " snmp:1"; + $hash->{AttrList} .= " snmp:1 mibs" if( $SYSSTAT_hasSNMP ); $hash->{AttrList} .= " filesystems showpercent"; $hash->{AttrList} .= " useregex:1" if( $SYSSTAT_hasSysStatistics ); $hash->{AttrList} .= " $readingFnAttributes"; @@ -285,24 +285,27 @@ SYSSTAT_GetUpdate($) push @snmpoids, sprintf( ".1.3.6.1.2.1.25.2.3.1.6.%i", $id ); } my $response = SYSSTAT_readOIDs($hash,\@snmpoids); - for my $id (@{$hash->{filesystems}}) { - my $unit = $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.4.%i", $id )}; - my $free = $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.5.%i", $id )} - $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.6.%i", $id )}; + if( $response ) { + for my $id (@{$hash->{filesystems}}) { + my $unit = $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.4.%i", $id )}; + my $free = $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.5.%i", $id )} - $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.6.%i", $id )}; - if( $showpercent ) { - $free = 100 * $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.6.%i", $id )} / $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.5.%i", $id )}; - $free = sprintf( "%.1f", $free ); - } else { - $free *= $unit; - } - my $name = $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.3.%i", $id )}; - if( $name =~ m/^([[:alpha:]]:\\)/ ) { - $name = $1 - } else { - $name =~ s/ //g; + if( $showpercent ) { + $free = 100 * $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.6.%i", $id )} / $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.5.%i", $id )}; + $free = sprintf( "%.1f", $free ); + } else { + $free *= $unit; + } + my $name = $response->{sprintf( ".1.3.6.1.2.1.25.2.3.1.3.%i", $id )}; + if( $name =~ m/^([[:alpha:]]:\\)/ ) { + $name = $1; + $name =~ s.\\./.g; + } else { + $name =~ s/ //g; + } + + readingsBulkUpdate($hash,$name,$free); } - - readingsBulkUpdate($hash,$name,$free); } } elsif( defined($hash->{diskusage} ) ) { @@ -349,6 +352,25 @@ SYSSTAT_GetUpdate($) } } + if( $hash->{USE_SNMP} && defined($hash->{session}) ) { + if( my $mibs = AttrVal($name, "mibs", undef) ) { + my @snmpoids; + foreach my $entry (split(' ,', $mibs)) { + my($mib,undef) = split(':', $entry ); + push @snmpoids, $mib; + } + + my $response = SYSSTAT_readOIDs($hash,\@snmpoids); + + foreach my $entry (split(' ,', $mibs)) { + my($mib,$reading) = split(':', $entry ); + + my $result = $response->{$mib}; + readingsBulkUpdate($hash,$reading,$result); + } + } + } + if( AttrVal($name, "raspberrycpufreq", 0) > 0 ) { my $freq = SYSSTAT_getPiFreq($hash); readingsBulkUpdate($hash,"cpufreq",$freq); @@ -783,6 +805,8 @@ SYSSTAT_getStat($) attr sysstat filesystems 1,3,5
  • disabledForIntervals HH:MM-HH:MM HH:MM-HH-MM...
  • +
  • mibs
    + space separated list of <mib>:<reding> pairs that sould be polled.
  • showpercent
    If set the usage is shown in percent. If not set the remaining free space in bytes is shown.
  • snmp
    @@ -906,6 +930,8 @@ SYSSTAT_getStat($) attr sysstat filesystems /dev/.*
    attr sysstat filesystems 1,3,5
  • +
  • mibs
    + Leerzeichen getrennte Liste aus <mib>:<reding> Paaren die abgefragt werden sollen.
  • showpercent
    Wenn gesetzt, wird die Nutzung in Prozent angegeben. Wenn nicht gesetzt, wird der verfübare Platz in Bytes angezeigt.