LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Closed Thread
  Search this Thread
Old 03-02-2018, 03:38 AM   #1
netaccs
LQ Newbie
 
Registered: Mar 2018
Posts: 24

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.
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 !
 
Old 03-04-2018, 10:12 AM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 12,745

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
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 06:07 AM
Shell script to generate report for each user ? beingswarupmall Programming 2 02-07-2017 07:04 AM
script to check host status and report email in certaion losses franklin.sucre Linux - Newbie 3 01-06-2013 04:29 PM
shell script to create internet suage report jeesun Linux - Security 2 11-14-2011 07:59 AM
need a shell script for creating report HariharanV Linux - Software 1 08-31-2010 07:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:02 AM.

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