SMARTMON - ein Frontend für smartctl

Begonnen von hexenmeister, 15 Dezember 2014, 23:47:45

Vorheriges Thema - Nächstes Thema

budy

Moin!

Super, funktioniert wie erwartet.  :D
Debian stretch, FHEM 5.9.
HM-CC-RT-DN, HM-ES-PMSw1-Pl, HM-LC-Dim1TPBU-FM, HMUARTLGW, HMLAN, HM-SEC-KEY, HM-SEC-RHS, HM-SEC-SC-2, HM-SEC-SCo, HM-SEC-SD-2, HM-OU-CFM-TW, div. HUEs, Wifilight, Ring Video Pro

Icinger

Alexander, planst du eigentlich die Telnet-Version (wie beim SYSMON) auch beim SMARTMON einzubinden?

lg, Ici
Verwende deine Zeit nicht mit Erklärungen. Die Menschen hören (lesen) nur, was sie hören (lesen) wollen. (c) Paulo Coelho

hexenmeister

Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy

CQuadrat

#18
Hallo Alexander,

obwohl schon länger hier nichts mehr geschrieben wurde, scheint dies der einzige Thread zu SMARTMON zu sein; darum schreibe ich dann mal hier.

Ich nutze SMARTMON zur Überwachung von NAS-Festplatten, die bei längerem Nichtzugriff in den Spin-Down gehen. Daher benutze ich SMARTMON mit dem Eintrag -n standby im parameters-Attribut, damit SMARTMON die Platten nicht aufweckt.

So wie ich es sehe, werden dann die Readings, da sie ja nicht gelesen werden können, gelöscht. Soweit so gut. Einen gesonderten Trigger scheint es für diesen Fall nicht zu geben. Richtig?

Frage/Bitte: Ist es möglich, das SMARTMON-Modul so zu erweitern, dass der Status der Platte in einem Reading abgebildet wird?

Rufe ich während eines Spin-Downs auf der Konsole z.B. smartctl --all -n standby /dev/sdb auf, erhalte ich als Ausgabe:

Device is in STANDBY mode, exit(2)

So etwas schwebt mir als zusätzliches Reading vor. Ggf. einfach auch nur den Exit-Code übernehmen.


Danke und Grüße

Christoph


Nachtrag: Hier der Aufbau der RETURN VALUES von smartctl:

RETURN VALUES
       The return values of smartctl are defined by a bitmask. If all is well
       with the disk, the return value (exit status) of smartctl  is  0  (all
       bits  turned  off).  If a problem occurs, or an error, potential error,
       or fault is detected, then a non-zero  status  is  returned.   In  this
       case,  the  eight different bits in the return value have the following
       meanings for ATA disks; some of these values may also be returned  for
       SCSI disks.

       Bit 0: Command line did not parse.

       Bit 1: Device  open  failed,  device  did not return an IDENTIFY DEVICE
      structure, or device is in a low-power  mode  (see  '-n' option
      above).

       Bit 2: Some  SMART  command to the disk failed, or there was a checksum
      error in a SMART data structure (see '-b' option above).

       Bit 3: SMART status check returned "DISK FAILING".

       Bit 4: We found prefail Attributes <= threshold.

       Bit 5: SMART status check returned "DISK OK" but we  found  that  some
      (usage  or  prefail)  Attributes have been <= threshold at some
      time in the past.

       Bit 6: The device error log contains records of errors.

       Bit 7: The device self-test log contains records of errors.  [ATA only]
      Failed  self-tests  outdated  by a  newer  successful  extended
      self-test are ignored.

       To test within the shell for whether or not  the  different  bits  are
       turned  on or off, you can use the following type of construction (this
       is bash syntax):
       smartstat=$(($? & 8))
       This looks at only at bit 3 of the exit status $?  (since 8=2^3).   The
       shell  variable $smartstat  will  be  nonzero  if  SMART  status check
       returned "disk failing" and zero otherwise.

       This bash script prints all status bits:
       status=$?
       for ((i=0; i<8; i++)); do
echo "Bit $i: $((status & 2**i && 1))"
       done
FHEM auf Mini-ITX-Server mit Intel Quad-Core J1900:
+ HM: HM-LAN, HM-USB, HM-MOD-UART mit div. HM-Komponenten
+ RFXtrx: Funkwetterstation Bresser mit ext. Thermometer, Regenmesser und Windmesser
+ TUL (KNX-Anbindung), KM271 (per ser2net), SONOS (div. Gimmicks), OneWire, Hue

hexenmeister

Schaue mir an, bin gerade wegen anderen Projekten zeittechnisch etwas knapp.
Grüße
Alexander
Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy

CQuadrat

Danke!

Ist aber nicht so eilig; ich konnte mir mit userReadings selber etwas basteln.
FHEM auf Mini-ITX-Server mit Intel Quad-Core J1900:
+ HM: HM-LAN, HM-USB, HM-MOD-UART mit div. HM-Komponenten
+ RFXtrx: Funkwetterstation Bresser mit ext. Thermometer, Regenmesser und Windmesser
+ TUL (KNX-Anbindung), KM271 (per ser2net), SONOS (div. Gimmicks), OneWire, Hue

CQuadrat

Hallo Alexander,

ich bin es nochmal.

In Zeile 484 gibt es eine kleine Unsauberkeit.
Logauszug:

2017.01.11 15:12:14.586 1: PERL WARNING: Argument "18686h+12m+37.450s" isn't numeric in division (/) at ./FHEM/42_SMARTMON.pm line 484.


Dies kommt daher, dass im  entsprechenden Reading power_on_hours ein String steht:

fhem> list SM_sda power_on_hours
SM_sda               2017-01-11 15:12:14    18686h+12m+37.450s


Daher produziert die Division in Zeile 484 die obige Log-Meldung.

Man könnte das beheben, wenn man Zeile 484

my $d=int($t/24);
$t = $t-($d*24);

durch

$t =~ /([0-9]*)h/;
my $d=int($1/24);
$t = $1-($d*24);

ersetzen würde.


Viele Grüße

Christoph
FHEM auf Mini-ITX-Server mit Intel Quad-Core J1900:
+ HM: HM-LAN, HM-USB, HM-MOD-UART mit div. HM-Komponenten
+ RFXtrx: Funkwetterstation Bresser mit ext. Thermometer, Regenmesser und Windmesser
+ TUL (KNX-Anbindung), KM271 (per ser2net), SONOS (div. Gimmicks), OneWire, Hue

hexenmeister

Hallo Christoph,

es hat gedauert, aber heute habe ich mir daran gesetzt.
Ich habe jetzt eingebaut, dass Exit-Code in einem Reading ausgegeben wird: last_exit_code
Man kann auch ein Attribut einbauen, das verhindert, dass readings gelöscht werden. Brauchst du das? Dann baue ich noch ein.
Bei 'power_on_hours' kann ich das so bei mir nicht nachvollziehen, aus meinem System werden rein numerische werte geliefert:

fhem> list sm power_on_hours
sm                   2017-02-11 03:04:14    20043


Ich habe Deinen VOrschlag leicht abgewandelt eingebaut.
Teste Bitte die Version im Anhang, ob das so in Deinem Sinne funktioniert.

Grüße
Alexander

Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy

CQuadrat

Hallo Alexander,

sorry! Ich habe Deine Antwort eben erst gesehen, nachdem durch ein Update meine eigene Anpassung wieder weg war.

Ich werde es heute Abend testen und Dir Rückmeldung geben.


Danke und Gruß

Christoph
FHEM auf Mini-ITX-Server mit Intel Quad-Core J1900:
+ HM: HM-LAN, HM-USB, HM-MOD-UART mit div. HM-Komponenten
+ RFXtrx: Funkwetterstation Bresser mit ext. Thermometer, Regenmesser und Windmesser
+ TUL (KNX-Anbindung), KM271 (per ser2net), SONOS (div. Gimmicks), OneWire, Hue

CQuadrat

Die ursprüngliche Log-Meldung ist weg.

Dafür bekomme ich jetzt das:

2017.05.31 15:09:10.280 1: PERL WARNING: Use of uninitialized value $dev_health in concatenation (.) or string at ./FHEM/42_SMARTMON.pm line 316.
2017.05.31 15:09:10.280 1: PERL WARNING: Use of uninitialized value $dev_health in pattern match (m//) at ./FHEM/42_SMARTMON.pm line 317.
FHEM auf Mini-ITX-Server mit Intel Quad-Core J1900:
+ HM: HM-LAN, HM-USB, HM-MOD-UART mit div. HM-Komponenten
+ RFXtrx: Funkwetterstation Bresser mit ext. Thermometer, Regenmesser und Windmesser
+ TUL (KNX-Anbindung), KM271 (per ser2net), SONOS (div. Gimmicks), OneWire, Hue

hexenmeister

Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy

CQuadrat

Sieht gut aus:

Meldungen sind weg!

1000 Dank !!!
FHEM auf Mini-ITX-Server mit Intel Quad-Core J1900:
+ HM: HM-LAN, HM-USB, HM-MOD-UART mit div. HM-Komponenten
+ RFXtrx: Funkwetterstation Bresser mit ext. Thermometer, Regenmesser und Windmesser
+ TUL (KNX-Anbindung), KM271 (per ser2net), SONOS (div. Gimmicks), OneWire, Hue

Blackcat



2020.02.18 16:06:33 5 : SMARTMON sm: execute.568 Execute: sudo smartctl --scan
2020.02.18 16:06:33 5 : SMARTMON sm: execute.573 Returncode: 1
2020.02.18 16:06:33 5 : SMARTMON sm: Get.130 Get: 'sm' 'list' 'devices'



Irgendwie scheint meine Festplatte zu spinnen und ich wollte für den besseren Überblick smartmon nutzen. Leider funktioniert es aber nicht bei mir. Der Befehl will auch bei direkter Eingabe leider ein Passwort

Fhem ist in der Gruppe der Sudo Nutzer und anbei mein sudoers Auszug. Hat jemand eine Idee? Vielen Dank 😊
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)

Wernieman

1. Könntest Du anstatt Screenshot uns immer den Inhalt der Datei geben? 8So kann ich nicht copy&paste)
2. Am besten nicht die sudoers bearbeoten, sondern ein neuen Eitrag in dem Dir /etc/sudoers.d/ machen
3. Warum soll fhem ALLES können sollen? Sicherheit geht anders ... also nimm fhem ALL=(ALL.... RAUS
4. fhem ALL=NOPASSWD: /usr/sbin/smartctrl
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

Blackcat

Geänderte sudovi:
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"


# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d


sudoers.d fhem Datei:
fhem ALL=NOPASSWD: /usr/sbin/smartctl


und siehe da :) es geht. Vielen Dank
Viele Grüße Sandra - FHEM Style Entwicklerin iOS6+12
-----
ZBox nano, Homematic, Homebridge, Hue + Mi Light, ZWave, Dyson, etc.
https://www.foodcat.de
https://www.youtube.com/c/FoodCat (hier gibt es auch immer mehr Hausautomatisierungsvideos)