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
Try to change the rights with chmod +x your_script.sh and then retry.

Please note that to execute a script you need to provide the path before it (even if you're in the directory where the script is, use ./your_script.sh) you can't just use your_script.sh.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Not sure if i am doing something obviously wrong, but I am getting "command not found" and permission denied when i try to run this script, even as root.
Might be a permissions problem: scripts need to have 'execute' permissions enabled for at least the owner and often the group as well. I set my scripts to 0770 (owner & group have Read, Write & Execute permissions).
 

lazybones

Dabbler
Joined
Jan 16, 2016
Messages
45
Might be a permissions problem: scripts need to have 'execute' permissions enabled for at least the owner and often the group as well. I set my scripts to 0770 (owner & group have Read, Write & Execute permissions).
I tried setting permissions to 0770, same result. All my other scripts works fine.

Sent from my Nexus 6P using Tapatalk
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
I tried setting permissions to 0770, same result. All my other scripts works fine.

Sent from my Nexus 6P using Tapatalk
Did you edit the script and specify your email address?
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Yes, I did.
Did you by any chance use a Windows text editor of any kind when editing the file? Sometimes these will replace newlines with Carriage-Return/Line-Feed sequences, thus wreaking havoc on UNIX scripts.
 

LaserAllan

Dabbler
Joined
Mar 25, 2017
Messages
34
Did you by any chance use a Windows text editor of any kind when editing the file? Sometimes these will replace newlines with Carriage-Return/Line-Feed sequences, thus wreaking havoc on UNIX scripts.


Actually, I used Atom, I'll have to report a bug then if that is the case that it is ruining it :)

I will try copying directly from github instead.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Actually, I used Atom, I'll have to report a bug then if that is the case that it is ruining it :)

I will try copying directly from github instead.
I have no idea if that's the cause of your problem; I'm just making guesses based on past experience. I wouldn't report a bug unless you can reliably reproduce the actual cause of your problem.
 

LaserAllan

Dabbler
Joined
Mar 25, 2017
Messages
34
I have no idea if that's the cause of your problem; I'm just making guesses based on past experience. I wouldn't report a bug unless you can reliably reproduce the actual cause of your problem.


Ok i tried copying it from github. Same result for some reason.
Funny thing is that all the other scripts I run works just fine.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Ok i tried copying it from github. Same result for some reason.
Funny thing is that all the other scripts I run works just fine.
I downloaded the repo as a zipfile; extracted the script; edited it to specify an email address; and ran it just now with no problems.

Would you please post the exact output you see when you run the script?

Also please include the output of ls -l in whatever directory you've stored the script.

Wouldn't hurt to give your FreeNAS version and basic system specs, too.
 

LaserAllan

Dabbler
Joined
Mar 25, 2017
Messages
34
Update, okay so I fixed it by pipeing the output directly into the textfile. Something obviously happens when it is pasted in Windows.

Anyway, would it be possible to add SSDs to the report?
I do know that they have a tendency of displaying weird SMART values.

Also a quesiton, where can i set how often the boot devices are scrubbed?
 

melp

Explorer
Joined
Apr 4, 2014
Messages
55
I've got a bunch of stuff I've been meaning to add to my version of the report script, but I haven't found time yet. Hopefully I'll get around to making some updates (per requests in this thread) in the next week or so. I've looked into adding SSD compatibility beforee, but the information they report varies a lot from one manufacturer to another and most of the information isn't all that useful for continual monitoring. I'll take another look at it, though.

As for setting a boot device scrub schedule, you can do that in in the FreeNAS web UI (v9.10) > System > Boot and change the number in the "Automatic scrub interval (in days) field at the top left of the table.

Edit-- as for it not running correctly unless you get a "clean" exact copy of the text, I'm not sure what would cause this. The only special character in the script is the degrees symbol.
 

melp

Explorer
Joined
Apr 4, 2014
Messages
55
Updated the script: https://github.com/edgarsuit/FreeNAS-Report

Changes:
  • Config backup now attached to report email
  • Added option to turn off config backup
  • Added option to save backup configs in a specified directory
  • Power-on hours in SMART summary table now listed as YY-MM-DD-HH
  • Changed filename of config backup to exclude timestamp (just uses datestamp now)
  • Config backup and checksum files now zipped (was just .tar before; now .tar.gz)
  • Fixed degrees symbol in SMART table (rendered weird for a lot of people); replaced with a *
  • Added switch to enable or disable SSDs in SMART table (SSD reporting still needs work)
  • Added most recent Extended & Short SMART tests in drive details section (only listed one before, whichever was more recent)
  • Reformatted user-definable parameters section
  • Added more general comments to code
TODO:
  • Improve SSD reporting, going to have to add them in a new table
  • Run through shellcheck for general improvements
  • Add support for conveyance SMART tests
 

Jaques

Dabbler
Joined
Jul 14, 2017
Messages
30
Hi there

Thanks for the awesome scripts. Any chance changing the CPU/HDD temperature one to email as well?

thanks
 
Joined
Jan 4, 2014
Messages
1,644
@melp Whohoo! Thank you!
 

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
@melp
I'm getting this
2017-07-28 12_07_31-192.168.1.11 - PuTTY.png

Code:
###### Auto-generated Parameters
host=$(hostname -s)
logfile="/tmp/smart_report.tmp"
subject="Status Report and Configuration Backup for ${host}"
boundary="gc0p4Jq0M2Yt08jU534c0p"
if ([ "$includeSSD" == "true" ]); then
   drives=$(for drive in $(sysctl -n kern.disks); do \
	 if ([ "$(smartctl -i /dev/${drive} | grep "SMART support is: Enabled")" ]); then printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')
else
   drives=$(for drive in $(sysctl -n kern.disks); do \
	 if ([ "$(smartctl -i /dev/${drive} | grep "SMART support is: Enabled")" ] && ! [ "$(smartctl -i /dev/${drive} | grep "Solid State Device")" ]); then
	   printf ${drive}" "; fi done | awk '{for (i=NF; i!=0 ; i--) print $i }')
fi
pools=$(zpool list -H -o name)

 

melp

Explorer
Joined
Apr 4, 2014
Messages
55
Weird... in the code you pasted, which is line 69? Also, do you have $includeSSD set to true or false?

edit: I broke out the lines a little bit more to make it easier to debug, try copying in the following code and see what line the error is on now:
Code:
###### Auto-generated Parameters
host=$(hostname -s)
logfile="/tmp/smart_report.tmp"
subject="Status Report and Configuration Backup for ${host}"
boundary="gc0p4Jq0M2Yt08jU534c0p"
if ([ "$includeSSD" == "true" ]); then
	drives=$(for drive in $(sysctl -n kern.disks); do \
		if ([ "$(smartctl -i /dev/${drive} | grep "SMART support is: Enabled")" ]); then 
			printf ${drive}" "; 
		fi 
	done | awk '{for (i=NF; i!=0 ; i--) print $i }')
else
	drives=$(for drive in $(sysctl -n kern.disks); do \
		if ([ "$(smartctl -i /dev/${drive} | grep "SMART support is: Enabled")" ] && ! [ "$(smartctl -i /dev/${drive} | grep "Solid State Device")" ]); then
			printf ${drive}" "; 
		fi 
	done | awk '{for (i=NF; i!=0 ; i--) print $i }')
fi
pools=$(zpool list -H -o name)
 
Last edited:

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
Weird... in the code you pasted, which is line 69? Also, do you have $includeSSD set to true or false?

edit: I broke out the lines a little bit more to make it easier to debug, try copying in the following code and see what line the error is on now:
SSD is false. All I changed in the code was my email address and subject line text. Everything else is untouched. I'll have to get back to you later on the rest...
 

diedrichg

Wizard
Joined
Dec 4, 2012
Messages
1,319
Weird... in the code you pasted, which is line 69? Also, do you have $includeSSD set to true or false?

edit: I broke out the lines a little bit more to make it easier to debug, try copying in the following code and see what line the error is on now:
Code:
###### Auto-generated Parameters
host=$(hostname -s)
logfile="/tmp/smart_report.tmp"
subject="Status Report and Configuration Backup for ${host}"
boundary="gc0p4Jq0M2Yt08jU534c0p"
if ([ "$includeSSD" == "true" ]); then
	drives=$(for drive in $(sysctl -n kern.disks); do \
		if ([ "$(smartctl -i /dev/${drive} | grep "SMART support is: Enabled")" ]); then
			printf ${drive}" ";
		fi
	done | awk '{for (i=NF; i!=0 ; i--) print $i }')
else
	drives=$(for drive in $(sysctl -n kern.disks); do \
		if ([ "$(smartctl -i /dev/${drive} | grep "SMART support is: Enabled")" ] && ! [ "$(smartctl -i /dev/${drive} | grep "Solid State Device")" ]); then
			printf ${drive}" ";
		fi
	done | awk '{for (i=NF; i!=0 ; i--) print $i }')
fi
pools=$(zpool list -H -o name)
2017-08-03 12_41_44-192.168.1.11 - PuTTY.png


67: fi
64: drives=$(for drive in $(sysctl -n kern.disks); do \
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Top