Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

hdd status report shell script


  • Please log in to reply
1 reply to this topic

#1 netaccs

netaccs

  • Members
  • 67 posts
  • OFFLINE
  •  
  • Local time:09:26 PM

Posted 16 February 2018 - 03:44 AM

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 2.6.22.18-Netgear (mostafah@es5x86.axentra.com) (gcc version 4.2.1)

In /var/log/dmes 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)

body:

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
/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 ?

 

Thanks in advance !


Edited by netaccs, 16 February 2018 - 03:44 AM.


BC AdBot (Login to Remove)

 


#2 netaccs

netaccs
  • Topic Starter

  • Members
  • 67 posts
  • OFFLINE
  •  
  • Local time:09:26 PM

Posted 23 February 2018 - 02:38 AM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users