Go Back   Singapore Web Hosting Talk > LEARNING CENTER > Others

Others Other guides/howtos.

Reply
 
Thread Tools
Old 04-09-2003, 23:20   #1
royong
SGWHT Administrators
 
royong's Avatar
 
Join Date: 01-07-2002
Location: Singapore
Posts: 1,469
royong is a splendid one to beholdroyong is a splendid one to beholdroyong is a splendid one to beholdroyong is a splendid one to beholdroyong is a splendid one to beholdroyong is a splendid one to beholdroyong is a splendid one to beholdroyong is a splendid one to behold
HOWTO : Script to Monitor functionality of Software RAID1

# cd /
# cd etc
# mkdir raidcheck
# cd raidcheck
# vi raidgetstatus.sh

##########################################
#!/bin/sh
# filename: raidgetstatus.sh
# get active raid status
# version 1.03 4-18-00
/bin/cat /proc/mdstat | /bin/grep active
##########################################
Save and Exit
:wq
##########################################

# vi raidcheck.sh

##########################################
#! /bin/sh
# filename: raidcheck.sh
# Version: 1.02 8-7-99 Michael A. Robinton
#
# raidcheck.sh This file must be executed periodically by cron
# It will check the raid status and e-mail a message if
# a status error is detected.
#
# USAGE: raidcheck.sh e-mail@addr {where to send error msg}
#
############ check raid status info ##############
MAILTO=$1
SENDMAILCMD="/usr/lib/sendmail -t -oi -O DeliveryMode=background"
RAIDHOST=`/bin/hostname`
DATE=`/bin/date`

# you must have issued
# raidgetstatus.sh >raidgood
# in the local directory before this routine will work

# capture raid status
RAIDSTATUS=`/etc/raidcheck/./raidgetstatus.sh`

# get raid reference
RAIDREF=`cat /etc/raidcheck/raidgood`

# test for a clean shutdown with array matching reference
if [ "${RAIDSTATUS}" != "${RAIDREF}" ]; then
${SENDMAILCMD} <<EOF123xxx
To:${MAILTO}
Reply-To:root@${RAIDHOST}
Errors-To:root@${RAIDHOST}
Sender:root@${RAIDHOST}
Subject:ALERT ALERT ALERT - RAID Device Failure on ${RAIDHOST}

An error has been detected in the RAID Device status of ${RAIDHOST}
Tested on ${DATE}

A good RAID device status should be:
${RAIDREF}

The currrent device status is:
${RAIDSTATUS}
EOF123xxx
#| ${SENDMAILCMD}
fi

if [ "${RAIDSTATUS}" = "${RAIDREF}" ]; then
${SENDMAILCMD} <<EOF123xxx
To:${MAILTO}
Reply-To:root@${RAIDHOST}
Errors-To:root@${RAIDHOST}
Sender:root@${RAIDHOST}
Subject:RAID Device Functioning normally on ${RAIDHOST}

RAID Device on ${RAIDHOST} is functioning normally
Tested on ${DATE}

A good RAID device status should be:
${RAIDREF}

The current device status is:
${RAIDSTATUS}
EOF123xxx
#| ${SENDMAILCMD}

fi
##########################################
Save and Exit
:wq
##########################################

# chmod +x raidcheck.sh
# chmod +x raidgetstatus.sh

# ./raidgetstatus.sh >raidgood

# cd /
# cd etc
# cd cron.daily
# vi checkraidstatus

##########################################
#!/bin/bash
/etc/raidcheck/./raidcheck.sh root@localhost
##########################################
Save and Exit
:wq
##########################################

# chmod +x checkraidstatus

Do a RAID status check by running :-
# ./checkraidstatus

Check root email for the output status

==========
I do not take sole credit for all the information that I post. I have spent countless hours and effort to research, amendment, change and implement these solutions and I'm sharing them solely for the benefit of others. Credit to the original writer will be provided whenever possible.
__________________
Roy Ong
Site Admin - Singapore Web Hosting Talk - My PM facility has been disabled. Please contact me via email instead.
My Web | My Tweets | My LinkedIn
royong is offline   Reply With Quote

Reply

Thread Tools

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 On
HTML code is Off

Forum Jump




All times are GMT +8. The time now is 23:43.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright (C) 2002-2015 Brought to you by Singapore Web Hosting Talk (SGWHT). All Rights Reserved.