Script for getting SMART and scrub reports doesn't work

Status
Not open for further replies.

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
Hey guys,

I followed this incredible guide to set up SMART and Scrub processes and I wanted to add an email report to them.

To send email reports, the guide tells me to do that:

Schedule automatic email status reports/backups. [Updated 8/17/17] This will run a simple script to generate an email report of the scrub and SMART test results. The script I’m using is combined, condensed, and generally improved version of several scripts posted on the FreeNAS forums (my version of the script is posted and discussed towards the end of this thread). The biggest improvement I've made to this script is converting the ZPool and SMART summary data tables from ASCII to HTML. I've also added some other features, like the ability to save each version of the config backup, automatic detection of drives and pools, and color coding in the table that highlights potential issues. I based my script off the SATA version of the script in the above thread, people have reported it works for SAS drives, too. After wrestling with MIME formatting for seemingly endless hours, I've also managed to combine the report email and the config backup email into a single message. Instructions below include a github that will have the most recent version of the script and a basic changelog.

  • Get the script from here [.sh file] and put it somewhere on your server; I recommend somewhere in your primary login’s home folder. Use chmod to ensure root has permission to execute the report.sh file.

  • Modify the parameters section at the top, most importantly the email address you created above (examples are in the script; remove the <>'s in your script):


    email="<the gmail address you set up earlier>"

    ...

    includeSSD="<true/false>"

    ...

    configBackup="<true/false>"

  • In the FreeNAS web UI, go to Tasks > Cron Jobs and click “Add Cron Job”. Set the user to “root”, put the full path to the script in the command box, and schedule the report so it runs right after your SMART tests and scrubs occur. My cron settings look like this.

I tried to do everything as given in the guide, but when I hit "run now" to test it, it does not send me any email. Things I am not sure I did correctly are:
  • Email address (do I have to put the freenas email address, not the one to which the process is supposed to send the report, right? - Anyway I tried both of them and it doesn't work)
  • The part of the guide when he says "Use chmod to ensure root has permission to execute the report.sh file." --> I don't understand what do I have to do
Is there anything I can do to understand what is blocking the process to send the email report?
Thanks!
 

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
Hey guys,

I followed this incredible guide to set up SMART and Scrub processes and I wanted to add an email report to them.

To send email reports, the guide tells me to do that:



I tried to do everything as given in the guide, but when I hit "run now" to test it, it does not send me any email. Things I am not sure I did correctly are:
  • Email address (do I have to put the freenas email address, not the one to which the process is supposed to send the report, right? - Anyway I tried both of them and it doesn't work)
  • The part of the guide when he says "Use chmod to ensure root has permission to execute the report.sh file." --> I don't understand what do I have to do
Is there anything I can do to understand what is blocking the process to send the email report?
Thanks!

Update:
I received this email some minutes ago
a2241312ead1e4abcafb9e904cc1efe0.png


In bold you can see the subject, the other is the email text







Inviato dal mio iPhone utilizzando Tapatalk
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Well, the file v1/media/Scripts/report.sh doesn't exist. It can't--pathnames to *nix files always start with a /. If v1 is your pool name, and everything else is correct, the correct path would be /mnt/v1/media/Scripts/report.sh.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Take a look at the instructions in the original post on how to get it working. It looks like you missed a step.
 

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
Well, the file v1/media/Scripts/report.sh doesn't exist. It can't--pathnames to *nix files always start with a /. If v1 is your pool name, and everything else is correct, the correct path would be /mnt/v1/media/Scripts/report.sh.

Hi!
Thanks for helping

Now it seems that the system reaches the file but does not have the privileges to execute the script. This is what I receive
8be73b5f9afc7ad05e8e1da2a6fed019.png


It's strange because the folder in which the script is positioned has "root" as user


Inviato dal mio iPhone utilizzando Tapatalk
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
It's strange because the folder in which the script is positioned has "root" as user
That is why I referred you back to the original instructions that covered chmod. You just jumped to the latest improved version of the scripts without understanding how to make them work and that is covered at the beginning of the original thread, which you linked to but you apparently didn't read.
 

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
Probably. That goes back to the instructions you quoted in your OP:

You're right. That is exactly the issue, but the thing is that I don't know how to code (I have to cut and paste even simple commands) so I don't know what to write in the Shell to Give the right permissions to the file. "Use chmod" for me is too general to understand what to do


Inviato dal mio iPhone utilizzando Tapatalk
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Well, you could always Google chmod, which would tell you what you need to know (and probably in less time than posting here asking). Or you could follow the link from jro.io to the forum thread where the scripts come from, which has detailed instructions--that link is in the paragraph immediately above the instruction you quoted.
 

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
Well, you could always Google chmod, which would tell you what you need to know (and probably in less time than posting here asking). Or you could follow the link from jro.io to the forum thread where the scripts come from, which has detailed instructions--that link is in the paragraph immediately above the instruction you quoted.

Hi,

I went to the paragraph this afternoon and I tried to follow the instructions..but still I'm missing something because I still get errors from the cron job output.
18d41f0922b09417b7e0dd700c8fdfc3.png



Inviato dal mio iPhone utilizzando Tapatalk
 

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
You're back to an incorrect pathname for your script.

Yes I understand that but I don't know how to understand what should be the correct path. I wrote "mkdir scripts" and then created the report.sh file in it, so the path should be /scripts/report.sh right?


Inviato dal mio iPhone utilizzando Tapatalk
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I wrote "mkdir scripts" and then created the report.sh file in it, so the path should be /scripts/report.sh right?
No, unless you were in / at the time you did mkdir scripts (which you weren't, and shouldn't have been). If you don't know what directory you're in, pwd will tell you.
 

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
No, unless you were in / at the time you did mkdir scripts (which you weren't, and shouldn't have been). If you don't know what directory you're in, pwd will tell you.

If I run
Code:
pwd
I get
Code:
/root



Inviato dal mio iPhone utilizzando Tapatalk
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
No, you don't; that's a different message. You really need to read the messages more carefully.

Ok, that's not the same message...the point is: what do I have to do to fix it?


Inviato dal mio iPhone utilizzando Tapatalk
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Someplace in the script is referring to /path/to/config/backup/ as a location for the config backups to be stored. That path doesn't exist. You need to change it to the correct path where your config backups are being stored. Which the instructions on the page you linked to told you to do (it's part of "Modify the parameters section at the top").
 

mbrunelli87

Explorer
Joined
Sep 17, 2016
Messages
65
Someplace in the script is referring to /path/to/config/backup/ as a location for the config backups to be stored. That path doesn't exist. You need to change it to the correct path where your config backups are being stored. Which the instructions on the page you linked to told you to do (it's part of "Modify the parameters section at the top").

I put "false" on the backup part because I could not manage to find where the config backup files are...anyway I got this message when I ran the script

a31334f444bc7c2d3424b64c7b64bd6c.png





Inviato dal mio iPhone utilizzando Tapatalk
 
Status
Not open for further replies.
Top