Scripts to report SMART, ZPool and UPS status, HDD/CPU T°, HDD identification and backup the config

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
input.voltage.nominal is useless because it's a static value. I'd chose input.voltage, and battery.voltage too ;)
 

marcusorwen

Dabbler
Joined
Aug 22, 2013
Messages
14
I did not get the self-adaptive script to work for the drives variable got this message:
Code:
./smartreport.sh: 1: Syntax error: end of file unexpected
./smartreport.sh: 7: Syntax error: Error in command substitution


So i did a google search about it and found out that the `<command here>` cannot be nested and was causing issues for me. so i changed it to the $(<command here>) that can be nested.
old version:
Code:
drives=`for drive in `sysctl -n kern.disks`; do if [ "`smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}'`" ]; then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }'`

new version
Code:
drives=$(for drive in $(sysctl -n kern.disks); do if [ "$(smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}')" ]; then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }');


might help some people having the same issue that i had.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Thanks. I know the backquotes aren't the POSIX way to do that but I'm used to this syntax... I plan to clean and correct all the scripts one day or another but right now I'm busy.
 
Last edited:

Crispin

Explorer
Joined
Jun 8, 2011
Messages
85
Many thanks for the scripts. Added to my arsenal or system health reports and handy scripts. Top man (or woman)
 

HardChargin

Dabbler
Joined
Jul 19, 2015
Messages
49
@Bidule0hm (and other contributors) Thank you for the time and effort you put into these scripts. They are great and have been invaluable in keeping an eye on things. One thing I did was do a little tweaking to write my CPU/HDD temps to a csv log file in addition to getting emails. That way its easier to see trends, I can keep a history (w/out a full mailbox), and be able to view/manipulate the data in a spreadsheet editor. Not sure if I will use it long term, but I wanted to have it in order to monitor a new build, at least until I am comfortable it is stable/solid.
 
Last edited:

satyr

Dabbler
Joined
Jun 20, 2015
Messages
37
Thanks for the scripts! Appreciate all the time you put into it.

Any tips for setting these up as cron tasks? I've got the scripts running via CLI, but would like to run them daily. I'm having issues with the proper command in the task creator. After following your guide and naming my script "poolstatus.sh" within a "scripts" directory, I thought that "/scripts/sh poolstatus.sh" would work, but it does not. I'm sure I'm missing something stupid but I'm a total script noob.
 
Last edited:

satyr

Dabbler
Joined
Jun 20, 2015
Messages
37
Change this to
Code:
sh /scripts/poolstatus.sh

The "sh" part is the command to run a script, and the parameter is the full path of the script to run.

I discovered that just a moment ago. Thanks!
I also noticed that I wasn't directing it into the full directory, but I resolved that after going through the file structure in WinSCP.
Working find now. Thanks for the help.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
NB: the sh command isn't needed as there's already the shebang in the scripts ;)
 
Last edited:

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I made a new script I wanted to make for a long time: it checks the config file integrity and sends a copy of it if everything is ok or an error message otherwise: http://pastebin.com/syF2JeAU :)

But before I put it in the first post can someone with another client than gmail checks that it works ok? (the way the file is attached is more or less a hack but as we can't add apps to the system it's not like if I have the choice...) NB: the mail can take some time to be received so wait a bit before checking the inbox.
 
Last edited:

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
I'm getting this:
Code:
./dbcheck.sh: ./config_backup.sha256: Permission denied
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Are you executing it as root?
 

Robert Trevellyan

Pony Wrangler
Joined
May 16, 2014
Messages
3,778
Are you executing it as root?
Yes.
Code:
[root@poweredge] ~/scripts# ls -al
total 5
drwxr-xr-x  2 root  wheel     3 Sep  3 21:12 ./
drwxr-xr-x  4 root  wheel    19 Sep  3 21:12 ../
-rwxr-xr-x  1 root  wheel  1376 Sep  3 21:10 dbcheck.sh*
[root@poweredge] ~/scripts#
 
Joined
Jan 9, 2015
Messages
430
I'm getting this:
Code:
./dbcheck.sh: ./config_backup.sha256: Permission denied
Yes.
Code:
[root@poweredge] ~/scripts# ls -al
total 5
drwxr-xr-x  2 root  wheel     3 Sep  3 21:12 ./
drwxr-xr-x  4 root  wheel    19 Sep  3 21:12 ../
-rwxr-xr-x  1 root  wheel  1376 Sep  3 21:10 dbcheck.sh*
[root@poweredge] ~/scripts#

What is the * at the end of the filename? It didn't show up in the previous post. Just curious.
 
Joined
Jan 9, 2015
Messages
430
I've never seen that before. Doesn't do it on my system. Interesting.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Yep, it means it's an executable.

Ok, so it's the rm who generate the permission denied but it is fine for the md5 file, WTF?! I'm too tired to think about that right now (4 am here)... can you post the output of ls -l /var/tmp/ please?

Thanks for the testing. Have you checked that the tar can be downloaded from the mail and contains the 2 checksum files and the db file?
 
Top