Try this : It is a python script
============================================================
#!/usr/bin/python

# check_swraid - plugin for nagios to check the status of linux swraid devices
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Copyright 2004 Duke University
# Written by Sean Dilda <[EMAIL PROTECTED]>

# Version: 0.3
# patched with the rouilj's patch (03.02.2006) by Virer (28.07.2006)

import os
import sys
import string

mdstat = '/proc/mdstat'

mdFile = open(mdstat).readlines()

# two cases: two starting lines or just one starting line.
# Remove the first and lasts lines as we don't need them
mdFile = mdFile[1:-1]
if (len(mdFile) % 3) != 0:
        mdFile = mdFile[1:]


if (len(mdFile) % 3) != 0:
        # must have two starting lines
        print 'Error with mdstat file'
        sys.exit(3)

if len(mdFile) == 0:
        print 'Error no md devices configured'
        sys.exit(3)

mdData = []
while len(mdFile) > 0:
    mdData.append((mdFile[0],mdFile[1]))
    mdFile = mdFile[3:]

overallStatus = 0
errorMsg = ''
devices = ''
for tup in mdData:
    device, colon, status, type, drives = string.split(tup[0], None, 4)
    drives = string.split(drives)
    values = string.split(tup[1])[-2]
    values = values[1:-1]
    normal, current = string.split(values, '/')
    normal = int(normal)
    current = int(current)

    devices = devices + " " + device

    # Status of 0 == Ok, 1 == Warning, 2 == Critical
    status = 0
    failed = 0
    degraded = 0
    msg = ''

    failed = []
    for drive in drives:
        if drive[-3:] == '(F)':
            failed.append(drive[:string.index(drive, '[')])
            status = 1
    failed = ' (' + string.join(failed, ', ') + ').'


    if status == 'inactive':
        status = 2
        msg = device + ' is inactive.'
    if type == 'raid5':
        if current < (normal -1):
            msg = device + ' failed' + failed
            status = 2
        elif current < normal:
            msg = device + ' degraded' + failed
            status = 1
    else:
        if current < normal:
            msg = device + ' failed' + failed
            status = 2

    if len(msg) > 0:
        if len(errorMsg) > 0:
            errorMsg = errorMsg + '; '
        errorMsg = errorMsg + msg
        overallStatus = max(overallStatus, status)

if overallStatus == 0:
    print 'All md devices (' + devices + ' ) Ok.'
    sys.exit(0)
else:
    print errorMsg
    sys.exit(overallStatus)
#EOF
============================================================




Rene Fertig escreveu:
Hello Hari.

  
Have you checked NagiosExchange.org? I didn't see anything but then I
didn't look too closely. Otherwise you could just write one. VBS is an
easy language and universal enough for this. I'd write this in fact, if
I had any servers poor enough to have windows software raid...
    

Of cause I've checked NagiosExchange, but there are only plugins for hardware 
raids.

I've found a _vbscript_ which uses DISKPART 
(http://www.anchor.com.au/hosting/dedicated/monitoring_windows_software_raid). 
Unfortunately DISKPART didn't work on Windows 2000 (only Win 2000 Pro, Win 
2000 server, Win 2003 ...)

But I've got a list of event IDs so I can monitor the event log and do passive 
checks - more than nothing...

Greetings,

	Rene

  
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to