Latest interface: 0.3.1
Latest system: 010
nka
User

45 posts

Posted on 16 November 2011 @ 23:08edited 23:09 43s
Well, I had a little script that was checking my 3ware card server and notify me if the raid is other than "OK". I modify it to fit ZFS.

Create a zfscheck.sh with that in it. You need to modify the "user@email.com" to your email.

#######

#######

#!/usr/local/bin/bash
zfsstat=`zpool status -x | awk '{print $4}'`

if [ $zfsstat != 'healthy' ]; then
/bin/date > /tmp/zfs.stat
echo >> /tmp/zfs.stat
/bin/hostname >> /tmp/zfs.stat
echo >> /tmp/zfs.stat
/sbin/zpool status -x >> /tmp/zfs.stat
cat /tmp/zfs.stat | /bin/mail -s "Disk failure in server : `hostname`" user@email.com
fi

#######
[code]
#######

I also have a version for a tank in particular (change "tank1" with your pool name (there's two places)... and also the email).

#######
[code]
#######

#!/usr/local/bin/bash
zfsstat=`zpool status -x tank1 | awk '{print $4}'`

if [ $zfsstat != 'healthy' ]; then
/bin/date > /tmp/zfs.stat
echo >> /tmp/zfs.stat
/bin/hostname >> /tmp/zfs.stat
echo >> /tmp/zfs.stat
/sbin/zpool status -x tank1 >> /tmp/zfs.stat
cat /tmp/zfs.stat | /bin/mail -s "Disk failure in server : `hostname`" user@email.com
fi

#######

#######

then, chmod +x zfscheck.sh, then make a cronjob that run as much as you need.

#######

crontab -e
*/30 * * * * /path/to/file/zfscheck.sh

#######

This one will run every 30 mins.
Maurizio
User

42 posts

Posted on 17 November 2011 @ 16:03
Thank you for sharing this script. Already used in my server.
The_Dave
User

221 posts

Posted on 17 November 2011 @ 18:37
Nice! Should integrate it into the interface!
Maurizio
User

42 posts

Posted on 21 November 2011 @ 14:41
This morning I found a pool error. My server is running FreeBSD 8.2-RELEASE, but the zfscheck.sh script returns ./zfscheck.sh: line 4: [: too many arguments. I have uploaded the error message output of the 'zpool status -x' command to pastebin.com so you can debug the script by yourself: http://pastebin.com/DSnFfhd1 .

Looking at /etc/periodic/daily/404.status-zfs I have replaced the first 2 lines of the script with:

zpool status -x | grep 'all pools are healthy'
if [ $? -ne 0 ]; then

and seems all work. You can download the modified version here: http://pastebin.com/qMy3SB35 .
Thanks again nka, for sharing yours ideas.
wevavyhi
User

2 posts

Posted on 21 July 2018 @ 07:54
School development is vital for the upbringing of the kids. The souls have been trained in schools and bestessays review has been divided for the reforms and all such issues for the uplift of the students in schools.
Last Page

Valid XHTML 1.1