cancel
Showing results for 
Search instead for 
Did you mean: 

Script to execute smartctl.

LittleZee
Occasional Visitor

Script to execute smartctl.

Hello Folks,

 

I am new in Linux and working as a Junior Admin.  One of the task I have is to runt SMART utility every night and mail the list of systems with and drives with errors only Admin team.

 

I will be running the following command on all 200 Systems for all hard drives and the output will go to a file.

If there is any other solution please help me out.

 

# smartctl -q errorsonly -H -A /dev/XXX >> StatusLog

 

The output in the file is also having all the name of systems and drive with no errors.

How can I extract the  SYSTEM NAME and DRIVE NAME with errors only and output to a different file ,, eg (Error_File) ???????????

 

FOR EXAMPLE ..... I ran the command on 3 system only but only NODE-1 is showing errors on both drives.

 

 

--------------------------- NODE-1 ---------------------------
Disk /dev/sda in NODE-1
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
190 Airflow_Temperature_Cel 0x0022   042   039   045    Old_age   Always   FAILING_NOW 58 (255 255 59 56)

Disk /dev/sdb in NODE-!
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
190 Airflow_Temperature_Cel 0x0022   040   036   045    Old_age   Always   FAILING_NOW 60 (255 255 61 58)

----------------------------NODE-2 ---------------------------
Disk /dev/sda in NODE-2
--------------------------- NODE-3 ---------------------------
Disk /dev/hde in NODE-3
Disk /dev/sda in NODE-3
Disk /dev/sdb in NODE-3
Disk /dev/sdc in NODE-3

1 REPLY
Goran Koruga
Honored Contributor

Re: Script to execute smartctl.

Hello.

 

Wouldn't it be easier to use 'smartd' instead and let it report to you?

 

Regards,

Goran