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

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Spearfoot is there anyway you can easily fix the get_hdd_temps.sh to support more than 10cpus my output looks like:
Code:
=== CPU (24) ===
CPU 0:  40C
CPU 1:  43C
CPU 2:  40C
CPU 3:  39C
CPU 4:  39C
CPU 5:  40C
CPU 6:  35C
CPU 7:  33C
CPU 8:  34C
CPU 9:  34C
CPU 10:   3C
CPU 11:   3C
CPU 12:   3C
CPU 13:   4C
CPU 14:   3C
CPU 15:   3C
CPU 16:   3C
CPU 17:   3C
CPU 18:   4C
CPU 19:   3C
CPU 20:   3C
CPU 21:   3C
CPU 22:   3C
CPU 23:   3C

=== DRIVES ===
  da0:  28C Western Digital Red WD-WMC4N0325860
  da1:  27C Western Digital Red WD-WMC4N0477619
  da2:  29C Western Digital Red WD-WCC4N4HUC0P9
  da3:  28C Western Digital Red WD-WCC4N4HUCJ2L
  da4:  27C Western Digital Red WD-WCC4N0YU03CV
  da5:  29C Western Digital Red WD-WMC4N0442863
  da6:  27C ST3000VN007-2E4166   W6A26NWE
  da7:  26C ST3000VN007-2E4166   W6A269EA



Thanks!
I've posted an update that should handle your huge array of CPUs! :smile:

It's available on Github, which you can access from the script resource here: "Github repository for FreeNAS scripts, including disk burnin".
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Wow that was fast I will test this now. Thanks!


-- Unfortunately the output is still the same. :( I will try to see if I can figure this out also.
Hmmm... can you post the output, in code tags so it will be easier to read?
 

tfast500

Explorer
Joined
Feb 9, 2015
Messages
77
Hmmm... can you post the output, in code tags so it will be easier to read?
Code:

root@CCNAS:/mnt/tank/scripts # ./get_hdd_temp.sh
=== CPU (24) ===
CPU  0:   39C
CPU  1:   39C
CPU  2:   37C
CPU  3:   37C
CPU  4:   38C
CPU  5:   36C
CPU  6:   30C
CPU  7:   30C
CPU  8:   31C
CPU  9:   33C
CPU 10:	3C
CPU 11:	3C
CPU 12:	3C
CPU 13:	3C
CPU 14:	3C
CPU 15:	3C
CPU 16:	3C
CPU 17:	3C
CPU 18:	3C
CPU 19:	3C
CPU 20:	3C
CPU 21:	3C
CPU 22:	3C
CPU 23:	3C

=== DRIVES ===
   da0:   28C [3.00TB] WD-WMC4N0325860	  Western Digital Red
   da1:   27C [3.00TB] WD-WMC4N0477619	  Western Digital Red
   da2:   29C [3.00TB] WD-WCC4N4HUC0P9	  Western Digital Red
   da3:   28C [3.00TB] WD-WCC4N4HUCJ2L	  Western Digital Red
   da4:   27C [3.00TB] WD-WCC4N0YU03CV	  Western Digital Red
   da5:   29C [3.00TB] WD-WMC4N0442863	  Western Digital Red
   da6:   27C [3.00TB] W6A26NWE			 ST3000VN007-2E4166
   da7:   26C [3.00TB] W6A269EA			 ST3000VN007-2E4166

 

Spearfoot

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

root@CCNAS:/mnt/tank/scripts # ./get_hdd_temp.sh
=== CPU (24) ===
CPU  0:   39C
CPU  1:   39C
CPU  2:   37C
CPU  3:   37C
CPU  4:   38C
CPU  5:   36C
CPU  6:   30C
CPU  7:   30C
CPU  8:   31C
CPU  9:   33C
CPU 10:	3C
CPU 11:	3C
CPU 12:	3C
CPU 13:	3C
CPU 14:	3C
CPU 15:	3C
CPU 16:	3C
CPU 17:	3C
CPU 18:	3C
CPU 19:	3C
CPU 20:	3C
CPU 21:	3C
CPU 22:	3C
CPU 23:	3C

=== DRIVES ===
   da0:   28C [3.00TB] WD-WMC4N0325860	  Western Digital Red
   da1:   27C [3.00TB] WD-WMC4N0477619	  Western Digital Red
   da2:   29C [3.00TB] WD-WCC4N4HUC0P9	  Western Digital Red
   da3:   28C [3.00TB] WD-WCC4N4HUCJ2L	  Western Digital Red
   da4:   27C [3.00TB] WD-WCC4N0YU03CV	  Western Digital Red
   da5:   29C [3.00TB] WD-WMC4N0442863	  Western Digital Red
   da6:   27C [3.00TB] W6A26NWE			 ST3000VN007-2E4166
   da7:   26C [3.00TB] W6A269EA			 ST3000VN007-2E4166

Ah ha! I believe the cut command in this code ( sysctl -a | grep "cpu.${code}.temp" | cut -c24-25 | tr -d) is the culprit. I'll see if I can figure out a fix.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Ah ha! I believe the cut command in this code ( sysctl -a | grep "cpu.${code}.temp" | cut -c24-25 | tr -d) is the culprit. I'll see if I can figure out a fix.
@tfast500 : Okay, I've posted an update that uses a different method to parse the temperature. Let me know how it works for you.
 

tfast500

Explorer
Joined
Feb 9, 2015
Messages
77
I was working on this myself and was able to add this if to get it working.

Code:
#############################
# CPU temperatures:
#############################

cores=$(sysctl -a | grep "hw.ncpu" | awk '{print $2}')
printf "=== CPU (%s) ===\n" "${cores}"
cores=$((cores - 1))
for core in $(seq 0 $cores); do

  if [ "$core" -gt 9 ] ; then
	temp="$(sysctl -a | grep "cpu.${core}.temp" | cut -c24-26 | tr -d "\n")"
  else
	temp="$(sysctl -a | grep "cpu.${core}.temp" | cut -c23-25 | tr -d "\n")"
  fi

  if [ "$temp" -lt 0 ]; then
	temp="--n/a--"
  else
	temp="${temp}C"
  fi
  printf "CPU %2.2s: %5s\n" "$core" "$temp"
done
echo ""



--just saw your post I will test that also (this new parser did not work) you can use mine if you want :) thanks so much!

My new output looks like:
Code:

root@CCNAS:/mnt/tank/scripts # ./get_hdd_temp.sh
=== CPU (24) ===
CPU  0:   39C
CPU  1:   38C
CPU  2:   37C
CPU  3:   37C
CPU  4:   36C
CPU  5:   36C
CPU  6:   28C
CPU  7:   30C
CPU  8:   30C
CPU  9:   30C
CPU 10:   31C
CPU 11:   32C
CPU 12:   36C
CPU 13:   36C
CPU 14:   33C
CPU 15:   33C
CPU 16:   34C
CPU 17:   34C
CPU 18:   35C
CPU 19:   37C
CPU 20:   35C
CPU 21:   34C
CPU 22:   37C
CPU 23:   35C

=== DRIVES ===
   da0:   28C [3.00TB] WD-WMC4N0325860	  Western Digital Red
   da1:   27C [3.00TB] WD-WMC4N0477619	  Western Digital Red
   da2:   29C [3.00TB] WD-WCC4N4HUC0P9	  Western Digital Red
   da3:   28C [3.00TB] WD-WCC4N4HUCJ2L	  Western Digital Red
   da4:   27C [3.00TB] WD-WCC4N0YU03CV	  Western Digital Red
   da5:   29C [3.00TB] WD-WMC4N0442863	  Western Digital Red
   da6:   27C [3.00TB] W6A26NWE			 ST3000VN007-2E4166
   da7:   26C [3.00TB] W6A269EA			 ST3000VN007-2E4166
root@CCNAS:/mnt/tank/scripts #

 
Last edited:

melp

Explorer
Joined
Apr 4, 2014
Messages
55
EcMQ0np.png


I redid the script a bit so it uses HTML tables instead of <pre> tags (which allow text wrap on small screens). I also combined the zpool status and smart status reports into a single email. I've got conditional highlighting on cells for alert (two shades of red).

I can't figure out how to get the backup tar file attached to the same email that the report goes out in and I want to add a couple columns in the SMART table, but other than that, it's pretty solid.

Edit: Here's the updated file on github, will now auto-detect SMART devices and pools: https://github.com/edgarsuit/FreeNAS-Report
 
Last edited:

Xyrgh

Explorer
Joined
Apr 11, 2016
Messages
69
I redid the script a bit so it uses HTML tables instead of <pre> tags (which allow text wrap on small screens). I also combined the zpool status and smart status reports into a single email. I've got conditional highlighting on cells for alert (two shades of red). There's some more stuff I want to do with it, but here's the current version on pastebin: https://pastebin.com/Bqvek62k

I can't figure out how to get the backup tar file attached to the same email that the report goes out in and I want to add a couple columns in the SMART table, but other than that, it's pretty solid.

Mate, that is fantastic. It's a small complain some people in this thread have said is that reading the ascii tables on mobile devices sucks. I'm going to give your script a shot, excellent work.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
I can't figure out how to get the backup tar file attached to the same email that the report goes out in and I want to add a couple columns in the SMART table, but other than that, it's pretty solid.

AFAIK you can't. I tested a lot of different things and the only method that works is the one I use but it doesn't work on all mail apps and you can't have anything but the attached file content in the mail body.
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419

Stux

MVP
Joined
Jun 2, 2016
Messages
4,419
AFAIK you can't. I tested a lot of different things and the only method that works is the one I use but it doesn't work on all mail apps and you can't have anything but the attached file content in the mail body.


Check the email attachment script I wrote. It uses modern mime attachment methods and should work.
 

Bidule0hm

Server Electronics Sorcerer
Joined
Aug 5, 2013
Messages
3,710
Ok, thanks ;)
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Moved this out of the archived sections. I have to find the time to neatly move all this to the Resources section, it'd be nice to have it there.
 
Joined
Dec 2, 2015
Messages
730
EcMQ0np.png


I redid the script a bit so it uses HTML tables instead of <pre> tags (which allow text wrap on small screens). I also combined the zpool status and smart status reports into a single email. I've got conditional highlighting on cells for alert (two shades of red). There's some more stuff I want to do with it, but here's the current version on pastebin: https://pastebin.com/Bqvek62k

I can't figure out how to get the backup tar file attached to the same email that the report goes out in and I want to add a couple columns in the SMART table, but other than that, it's pretty solid.
I wish I could get this to work, but it fails for me. I'm not enough of a bash and awk guru to figure out what is happening. My output looks like:

Code:
/root/bin/smart_report2.sh: line 151: #f4f4f4: command not found
/root/bin/smart_report2.sh: line 151: #ffffff: command not found
/root/bin/smart_report2.sh: line 151: #f4f4f4: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
awk: no variable name

/root/bin/smart_report2.sh: line 193: -v: command not found
/root/bin


Any hints appreciated.

Thanks
 

Xyrgh

Explorer
Joined
Apr 11, 2016
Messages
69
I wish I could get this to work, but it fails for me. I'm not enough of a bash and awk guru to figure out what is happening. My output looks like:

Code:
Any hints appreciated.

Thanks
Code:

Sounds like a cut and paste issue. This is from pastebin? Copy the raw data, paste into something like Notepad++ and then paste in, using whatever your editor of choice is (ie. nano).
 
Joined
Dec 2, 2015
Messages
730
Code:

Sounds like a cut and paste issue. This is from pastebin? Copy the raw data, paste into something like Notepad++ and then paste in, using whatever your editor of choice is (ie. nano).
This is exactly what I did. I just tried it again - same problem.
 
Joined
Dec 2, 2015
Messages
730
Weird... not sure what would cause that. Are the color codes in the first couple lines still in quotes?

I've attached an updated version, see if it works for you.
I got it working by copying report.zip to the server, unzipping it and then editing it with nano.

For some crazy reason, copying it out of my ever reliable text editor and pasting it into nano via the terminal wasn't giving the expected result. I updated the terminal program recently, and I wonder if perhaps something is awry with the new version. Or maybe some arcane preference got changed.

Thanks.
 

Xyrgh

Explorer
Joined
Apr 11, 2016
Messages
69
I redid the script a bit so it uses HTML tables instead of <pre> tags (which allow text wrap on small screens). I also combined the zpool status and smart status reports into a single email. I've got conditional highlighting on cells for alert (two shades of red). EDIT: Updated version attached in zip file.

I can't figure out how to get the backup tar file attached to the same email that the report goes out in and I want to add a couple columns in the SMART table, but other than that, it's pretty solid.

Hey, I've been using your script and it looks great on my iPhone, much easier to read the info and saves me from opening my normal mail client to view.

Just a question, is there any possibility you can add functionality like @Spearfoot 's script where it automatically detects the drives, pools and hostname? I find that a big quality of life improvement, as it saves me having to adjust my scripts every time I add pools or drives.
 
Top