Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disk failure detection perl script

Tags:

linux

perl

syslog

I need to write a script to check the disk every minute and report if it is failing by any reason. The error could be the absolute disk failure and a bad sector and so on .

First, I wonder if there is any script out there that does the same as it should be a standard procedure (because I really do not want to reinvent the wheel).

Second, I wonder if I want to look for errors in /var/log/messages, is there any list of standard error strings for disks that I can use?

I look for that on the net a lot, there are lots of info and at the same time no info about that.

Any help will be much appreciated.

Thanks,

like image 801
Amir Avatar asked Jan 17 '12 01:01

Amir


2 Answers

You could simply parse the output of dmesg which usually reports fairly detailed information about drive errors, well that's how I've collected stats on failing drives before.

You might get better more well documented information by using Parse::Syslog or lower level kernel reporting directly though.

like image 86
Jeff Burdges Avatar answered Sep 30 '22 16:09

Jeff Burdges


Logwatch does the /var/log/messages part of the ordeal (as well as any other logfiles that you choose to add). You can either choose to use that, or to use its code to roll your own sollution (it's all written in perl).

If your harddrives support SMART, i suggest you use smartctl output for diagnostics as it includes a lot of nice info that can be monitored over time to detect failure.

like image 22
Jarmund Avatar answered Sep 30 '22 16:09

Jarmund