Einfacher SMART-Test per script

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
meine Scripts liegen im ordner "mnt/Volume1/scripts" der ausführende benutzer ist "root"
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Ok, setz Mal den vollen Pfad vor beide Dateien, das wird es sein.

cp /mnt/Volume1/scripts/...

Bei mir liegen sie im root

Vermutlich reicht das aber nicht weil du ja weiter die falsche smart.txt befüllst.
Glaube man muss erst dem Script am Anfang sagen dass er in den Ordner gehen soll.

Setz Mal ganz oben an deinen Script das:
cd /mnt/Volume1/scripts/
 
Last edited:

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
ich habe auch schon drübernachgedacht ob aus der smart.txt nicht eine smart.txt.txt geworden ist.
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Also wenn deine sh Datei am Anfang so aufgebaut ist müsste es gehen:

#! /bin/sh
cd /mnt/Volume1/scripts
cp mailsmart.txt smart.txt
echo "S.M.A.R.T Ergebnisse:" >> smart.txt
echo "" >> smart.txt
 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
So danke genau das war es.
Meinst du ich könnte die SMART Tests alle parallel laufen lassen - denn ich kann mir nicht vorstellen das man dann noch viel nebenbei machen kann.

Wie sieht es mit deinem Temp script aus - da kommt alles nur mit html-tags an - die Mails sieht so aus

Code:

<html>
<p>Systemtemperaturen:</p>
<ul style="list-style-type: square;">
<li><p>41&deg;C (cpu0)
<li><p>44&deg;C (cpu1)
<li><p>39&deg;C (ada2)
<li><p>42&deg;C (ada3)
</ul>
<p>Geschickt am 22.02.2019 um 18:54 Uhr von deinem treuen NAS.
</html>
<html>
<p>Systemtemperaturen:</p>
<ul style="list-style-type: square;">
<li><p>45&deg;C (cpu0)
<li><p>45&deg;C (cpu1)
<li><p>39&deg;C (ada2)
<li><p>42&deg;C (ada3)
</ul>
<p>Geschickt am 22.02.2019 um 19:00 Uhr von deinem treuen NAS.
</html>
<html>
<p>Systemtemperaturen:</p>
<ul style="list-style-type: square;">
<li><p>45&deg;C (cpu0)
<li><p>46&deg;C (cpu1)
<li><p>39&deg;C (ada2)
<li><p>42&deg;C (ada3)
</ul>
<p>Geschickt am 22.02.2019 um 20:00 Uhr von deinem treuen NAS.
</html>
<html>
<p>Systemtemperaturen:</p>
<ul style="list-style-type: square;">
<li><p>44&deg;C (cpu0)
<li><p>43&deg;C (cpu1)
<li><p>39&deg;C (ada2)
<li><p>41&deg;C (ada3)
</ul>
<p>Geschickt am 22.02.2019 um 20:19 Uhr von deinem treuen NAS.
</html>

 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
Ist doch alles OK. Alles wird doch korrekt angezeigt nachdem ich auch den Pfad angepasst habe ;).
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Also den Festplatten sollte das egal sein zusammen zu testen. Eventuell höhere CPU last, das müsstest du mal beobachten. Aber beim short Test sollte das klar gehen. Da ich long Tests mache und bei meiner CPU... mache ich das lieber einzeln.

Beim Tempscript habe ich das mit html formatiert.

Da musst du eventuell in der Mailvorlage auch definieren, dass die Email html sein soll.

Code:
Subject: NAS Temperaturen
Content-Type: text/html; charset=\"utf-8\"
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Super, dann erstmal viel Spaß jetzt beim zurechtbasteln deines Scriptes.

Man kann sich mit ... | awk ... echt alles mögliche da raus basteln.

Ich hatte eigentlich mal vor die Laufzeit und die Testzeit voneinander zu subtrahieren und in der Mail zu schreiben z.B.
"12h seit dem letzten Test: Completed without error"

Aber bisher habe ich es nicht hinbekommen.
 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
Danke erstmal
ich habe noch 2 weitere CPUs eingefügt und die menge an HDDs ergänzt.

ich würde gerne einen absatz zwischen den CPUs und den HDDS hinzufügen .

Doch mit einem einfachen <p> CPU-Temperaturen </p> klappt das net.
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
ich habe noch 2 weitere CPUs eingefügt und die menge an HDDs ergänzt.
:cool::cool::cool: läuft bei dir ^^

Das liegt daran, weil die Temperaturen aufgelistet werden. Die temp.txt sieht später z.B. so aus.

Code:
Subject: NAS Temperaturen
Content-Type: text/html; charset=\"utf-8\"
<html>
<p>Systemtemperaturen:</p>
<ul style="list-style-type: square;">
<li><p>46&deg;C (cpu0)
<li><p>46&deg;C (cpu1)
<p> # Das ignoriert er leider...
<li><p>30&deg;C (ada0)
<li><p>31&deg;C (ada1)
<li><p>32&deg;C (ada2)
<li><p>30&deg;C (ada3)
</ul>
<p>Geschickt am 22.02.2019 um 21:09 Uhr von deinem treuen NAS.
</html>


Du müsstet zwei Auflistungen draus machen, dann kannst du sie mit einem Absatz trennen.
Benutz mal folgende Code als "Trenner":

Code:
echo "</ul>" >> temp.txt
echo "<p>Festplattentemperaturen:</p>" >> temp.txt
echo "<ul style=\"list-style-type: square;\">" >> temp.txt


Geht sicher auch einfach mit einem Freiraum, aber in html bastel ich mich auch nur so durch ;)
 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
ja klappt und eine leerzeile klappt ja auch mit <br> </br>

Nur meine SSDs machen wohl keine Temperatur ;(
 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
Wenn jetzt alles läuft ist es nur noch ein abschätzen wann alle SMART-Test fertig gestellt sind um dann das Mail-script zu starten.
 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
Scheint alles perfekt zu funktionieren - jetzt noch eine frage wie kann ich noch weitere Werte zu der SMART Auswertung hinzufügen.
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Optimal.

Da musst du dir am besten Mal ansehen wie genau awk funktioniert und direkt in der Konsole mit smartctl -a /dev/ada0 | awk <Befehl> rumspielen. Bis du die Ausgabe hast die du willst und dann in den Script kopieren.
Habe nur für die Scripte oben Mal n halbe Nacht gebastelt.

ZB https://www.tutorialspoint.com/awk/awk_basic_syntax.htm
 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
Falls du Interesse hast ich hab da auch ein "Backup-Script"
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Da vertraue ich auf mein Raid5 gegen HDD Sterben und die lebenswichtigen Files liegen nochmal auf einer kalten externen HDD am anderen Standort. Bei meinem Webserver mache ich das aber zB immer einfach mit tar und sichere alles.

Aber Posten kannst du es gerne. Kann man ja immer was dazu lernen.
 

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
Hi @honeybee
villeicht kannst du mir ebend nochmal beim scripten helfen ich möchte mir die Ausage von

Code:
zpool list
als Mail versenden lassen . Die mail kommt auch an nur ist alles in einer zeile.
Wie bekomme ich das mit der Darstellung hin ?
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Hi @honeybee
villeicht kannst du mir ebend nochmal beim scripten helfen ich möchte mir die Ausage von

Code:
zpool list
als Mail versenden lassen . Die mail kommt auch an nur ist alles in einer zeile.
Wie bekomme ich das mit der Darstellung hin ?

Hab's getestet und sehe was du meinst. Schön ist anders. Ist glaube hier musst du dir auch einen Script bauen und die die schippsel aus der Ausgabe raus holen sie du brauchst.
Ist ja quasi analog zur Basteiel bei smartctl wie wir sie oben haben.

Beispiele:

#Zeigt die Zeile wo Volume_1 enthalten ist.
root@FREENAS:~ # zpool list | awk '/Volume_1/'

Volume_1 100T 50T 50T - 50% 50% 1.00x ONLINE /mnt

#Zeigt den ersten Block aus der Zeile wo Volume_1 enthalten ist.
root@FREENAS:~ # zpool list | awk '/Volume_1/{print $1}'

Volume_1

#Zeigt den zweiten Block aus der Zeile wo Volume_1 enthalten ist.
root@FREENAS:~ # zpool list | awk '/Volume_1/{print $2}'

100T

#Zeigt den dritten Block aus der Zeile wo Volume_1 enthalten ist.
root@FREENAS:~ # zpool list | awk '/Volume_1/{print $3}'

50T


Ganz analog zu unserem smartctl Script.
 
Last edited:

555NASE

Patron
Joined
Mar 3, 2017
Messages
202
Schau mal was ich gebastelt habe ;) jetzt muss ich nur noch einen doppelpunkt dazwischen bekommen ;)

Code:
#! /bin/sh
cd /mnt/Volume1/scripts
cp mailvol.txt volume.txt

echo "</ul>" >> volume.txt
echo "<ul style=\"list-style-type: square;\">" >> volume.txt

zpool list | awk '/NAME/{print "<li>" $1}' >> volume.txt
zpool list | awk '/Volume1/ {print $1}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $2}' >> volume.txt
zpool list | awk '/Volume1/ {print $2}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $3}'>> volume.txt
zpool list | awk '/Volume1/ {print $3}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $4}' >> volume.txt
zpool list | awk '/Volume1/ {print $4}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $5}' >> volume.txt
zpool list | awk '/Volume1/ {print $5}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $6}' >> volume.txt
zpool list | awk '/Volume1/ {print $6}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $7}' >> volume.txt
zpool list | awk '/Volume1/ {print $7}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $8}' >> volume.txt
zpool list | awk '/Volume1/ {print $8}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $9}' >> volume.txt
zpool list | awk '/Volume1/ {print $9}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $10}' >> volume.txt
zpool list | awk '/Volume1/ {print $10}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $11}' >> volume.txt
zpool list | awk '/Volume1/ {print $11}' >> volume.txt

################################################################

echo "</ul>" >> volume.txt
echo "<ul style=\"list-style-type: square;\">" >> volume.txt


zpool list | awk '/NAME/{print "<li>" $1}' >> volume.txt
zpool list | awk '/Volume2/ {print $1}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $2}' >> volume.txt
zpool list | awk '/Volume2/ {print $2}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $3}'>> volume.txt
zpool list | awk '/Volume2/ {print $3}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $4}' >> volume.txt
zpool list | awk '/Volume2/ {print $4}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $5}' >> volume.txt
zpool list | awk '/Volume2/ {print $5}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $6}' >> volume.txt
zpool list | awk '/Volume2/ {print $6}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $7}' >> volume.txt
zpool list | awk '/Volume2/ {print $7}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $8}' >> volume.txt
zpool list | awk '/Volume2/ {print $8}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $9}' >> volume.txt
zpool list | awk '/Volume2/ {print $9}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $10}' >> volume.txt
zpool list | awk '/Volume2/ {print $10}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $11}' >> volume.txt
zpool list | awk '/Volume2/ {print $11}' >> volume.txt

################################################################

echo "</ul>" >> volume.txt
echo "<ul style=\"list-style-type: square;\">" >> volume.txt


zpool list | awk '/NAME/{print "<li>" $1}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $1}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $2}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $2}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $3}'>> volume.txt
zpool list | awk '/Volume3ssd/ {print $3}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $4}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $4}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $5}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $5}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $6}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $6}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $7}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $7}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $8}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $8}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $9}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $9}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $10}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $10}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $11}' >> volume.txt
zpool list | awk '/Volume3ssd/ {print $11}' >> volume.txt

################################################################

echo "</ul>" >> volume.txt
echo "<ul style=\"list-style-type: square;\">" >> volume.txt

zpool list | awk '/NAME/{print "<li>" $1}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $1}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $2}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $2}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $3}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $3}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $4}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $4}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $5}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $5}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $6}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $6}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $7}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $7}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $8}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $8}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $9}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $9}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $10}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $10}' >> volume.txt

zpool list | awk '/NAME/{print "<li>" $11}' >> volume.txt
zpool list | awk '/Volume4ssd/ {print $11}' >> volume.txt


date +"<p>Geschickt am %d.%m.%Y um %H:%M Uhr von deinem treuen NAS." >> volume.txt
echo "</html>" >> temp.txt
sendmail  < volume.txt

 
Last edited:

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Sehr gut. Nun besser deine Emailadresse noch raus bevor die Spamflut kommt.
 
Top