I have Netgear stora NAS with two hard drives.
I have ssh access to it. Probably Debian Linux, I am not so sure.
Code:
cat /proc/version
Linux version 2.6.22.18-Netgear (mostafah@es5x86.axentra.com) (gcc version 4.2.1)
In /var/log/dmesg I see that:
Code:
md: Autodetecting RAID arrays.
md: autorun ...
md: created md0
With this command I read hard drives smart information:
Code:
/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?
Code:
/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 ?
Using this can collect the all needed information
Code:
/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:
Code:
/sbin/mdadm -D /dev/md0 |grep State
State : clean
Number Major Minor RaidDevice State
or using this lines:
Code:
awk 'begin {State;} {print $1,$3;}' GENERATED.txt | grep State
Thanks in advance !