Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


Closed Thread
  Search this Thread
Old 03-02-2018, 04:38 AM   #1
Registered: Mar 2018
Posts: 32

Rep: Reputation: Disabled
hdd status report shell script

I have Netgear stora NAS with two hard drives.

I have ssh access to it. Probably Debian Linux, I am not so sure.
cat /proc/version
Linux version ( (gcc version 4.2.1)
In /var/log/dmesg I see that:
md: Autodetecting RAID arrays.
md: autorun ...
md: created md0
With this command I read hard drives smart information:

/usr/sbin/smartctl --all  -d marvell /dev/sda
/usr/sbin/smartctl --all  -d marvell /dev/sdb
Can you suggest me some linux shell script, which will be added in /etc/crontab to check hard drives state and sends email every week for example?

May be something like this.

subject: NAS state (OK or Warning)
hard drives smart result in plane text or may some part of it

Also I have mdadm in /sbin/, so may be some mdadm script?

/sbin/mdadm -D /dev/md0
        Version : 00.90.03
  Creation Time : Thu Feb 15 22:29:29 2018
     Raid Level : raid1
     Array Size : 1953124928 (1862.65 GiB 2000.00 GB)
  Used Dev Size : 1953124928 (1862.65 GiB 2000.00 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Fri Feb 16 09:48:43 2018
          State : active
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 3e4ce74f:c96e7f85:fd89366b:35810b16
         Events : 0.7

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb10
How to make script with these status reports, get state OK, Warning, Error and cron it ?

Using this can collect the all needed information

/sbin/mdadm -D /dev/md0 >> /data/`date +\%Y-\%m-\%d`-hdd.txt | /usr/sbin/smartctl --all -d marvell /dev/sda >> /data/`date +\%Y-\%m-\%d`-hdd.txt | /usr/sbin/smartctl --all -d marvell /dev/sdb  >> /data/`date +\%Y-\%m-\%d`-hdd.txt | /usr/bin/sendmail -s "mail@mail.mail" < /data/`date +\%Y-\%m-\%d`-hdd.txt
I cannot put the subject, which result is:

/sbin/mdadm -D /dev/md0 |grep State
          State : clean
    Number   Major   Minor   RaidDevice State
or using this lines:
awk 'begin {State;} {print $1,$3;}' GENERATED.txt  | grep State
Thanks in advance !
Old 03-04-2018, 11:12 AM   #2
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,902

Rep: Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
hdd status report shell script netaccs Linux - Newbie 22 03-29-2018 07:07 AM
Shell script to generate report for each user ? beingswarupmall Programming 2 02-07-2017 08:04 AM
script to check host status and report email in certaion losses franklin.sucre Linux - Newbie 3 01-06-2013 05:29 PM
shell script to create internet suage report jeesun Linux - Security 2 11-14-2011 08:59 AM
need a shell script for creating report HariharanV Linux - Software 1 08-31-2010 08:19 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration