[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to be alerted if mount status changes

Posted on 2011-04-26
8
Medium Priority
?
485 Views
Last Modified: 2012-05-11
I have a few linux server that i am tyring to setup some alerts for. There is one main Linux server that is connected to a fibre channel SAN that is mounted on the box. these drives are then shared via NFS to the other servers.

Recently we had a few problems where there were some file system errors and the drives changed to read only.

My question is how I can monitor and create an alert if this were to happen again? I am using Opmanager to monitor my network devices and servers, and have configured it to monitor some processes on the Linux serversm, but I cant seem to get it to monitor the status of the mounts.

How can this be accomplished? Do I need to setup a log server or can this be scripted?
0
Comment
Question by:ryan80
  • 4
  • 4
8 Comments
 
LVL 38

Accepted Solution

by:
wesly_chen earned 2000 total points
ID: 35469048

1. Create a script
-- /usr/local/bin/check_mount.sh ---
#!/bin/sh

HOSTNAME=`hostname`
NFS_MOUNT=/nfs-mount

touch ${NFS_MOUNT}/test-mount
if [ $? -eq 0 ]
then
   echo "the nfs is rw"
   /bin/rm -f
else
  echo $NFS_MOUNT | mail -s "nfs mount fail on $HOSTNAME"  <ops email address>
fi

2.
chmod +x /usr/local/bin/check_mount.sh

3. setup cron job each NFS client to check every hour
$ crontab -e
1 * * * * * /usr/local/bin/check_mount.sh > /dev/null 2>&1
0
 
LVL 12

Author Closing Comment

by:ryan80
ID: 35469063
thank you
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35469226
Woo, I missing something...
-------  /usr/local/bin/check_mount.sh
..
touch ${NFS_MOUNT}/test-mount
if [ $? -eq 0 ]
then
   echo "the nfs is rw"
   /bin/rm -f ${NFS_MOUNT}/test-mount   #### change this line
else
...
0
 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

 
LVL 12

Author Comment

by:ryan80
ID: 35469719
i keep on getting this error when running this script:

check_mount.sh: line 7: [: missing `]'
check_mount.sh: line 7: ?: command not found


This is what I have for the script

#//bin/sh

HOSTNAME='rbmpl01'
FIBRE_MOUNT=/Production

touch ${FIBRE_MOUNT}/test-mount
if [ &? -eq 0 ]
then
        echo "the Production mount is rw"
else
        echo $FIBRE_MOUNT | mailx -s "mount fail on $HOSTNAME" ryan.palamara@zaisgroup.com
fi
0
 
LVL 12

Author Comment

by:ryan80
ID: 35469738
by the way it is fedora 9 if that matters.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35469747
> if [ &? -eq 0 ]
You have typo there
it should be
if [ $? -eq 0 ]
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 35469795
Work for all the Linux

Your first line is wrong
>#//bin/sh
should be
#!/bin/sh
0
 
LVL 12

Author Comment

by:ryan80
ID: 35470213
thank you again
0

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A new hacking trick has emerged leveraging your own helpdesk or support ticketing tools as an easy way to distribute malware.
The Internet has made sending and receiving information online a breeze. But there is also the threat of unauthorized viewing, data tampering, and phoney messages. Surprisingly, a lot of business owners do not fully understand how to use security t…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses
Course of the Month18 days, 1 hour left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question