[RLAdams at Kelsey-Seybold.com: Re: NCSA for AIX]

Adams, Russell L. RLAdams at Kelsey-Seybold.com
Thu Aug 25 16:22:35 CEST 2005


----- Forwarded message from "Adams, Russell L." <RLAdams at Kelsey-Seybold.com> -----

Date: Thu, 25 Aug 2005 09:16:30 -0500
From: "Adams, Russell L." <RLAdams at Kelsey-Seybold.com>
To: Ricardo Silva <ricardo.silva at rigorcg.pt>
Cc: nagios-users at sourceforge.net
Subject: Re: NCSA for AIX

>From AIX I use the perl script send_nsca.pl to push service data up to
my Nagios box running the NSCA daemon.

I run a few shell scripts from a cron job at 5 minute intervals to
check specific items on the local system and send the results to
Nagios. I can't install the whole plugin suite or additional binaries
in my environment, but a few simple shell scripts do the trick for
what I need.

Here are my scripts for checking disks and processes. Note that you
must update the destination hostname. I have nagios.mydomain.com in as
an example.

In my cron job I test for multiple processes, and so I cache a copy of
the ps list to disk via "ps auxw > /tmp/proclist" before running
check_proc.sh.

A sample from the cron job:

ps auxw > /tmp/proclist
check_proc.sh /usr/sbin/inetd -ge 1
check_proc.sh /usr/sbin/cron -ge 1
check_proc.sh /usr/sbin/syslogd -ge 1
check_proc.sh sendmail -ge 1

check_disk.sh /$ 90 95
check_disk.sh /usr 90 95
check_disk.sh /var 90 95
check_disk.sh /tmp 90 95

I have passive services setup on Nagios to match the input from NSCA,
such as:

Disk /usr
Process /usr/sbin/syslogd

Hope that helps!

Russell


check_disk.sh ---------------------------------------------------------------

#!/bin/sh

# $Id: check_disk.sh,v 1.9 2004/11/23 16:10:12 rladams Exp $    

# check_disk.sh
# Used to check a given disk for space, and send the data to netsaint.
#
# Syntax:
#
#   check_disk.sh <disk-regexp> <warning %> <critical %>

######################################################################
# Functions first

function send_nsca {

    MYDISK=`/bin/echo "$1" | tr -d '$'`
    /bin/echo "`/usr/bin/hostname`\tDisk $MYDISK\t$RESULT\t$USED%
    used." | \
        /usr/local/bin/send_nsca.pl -H nagios.mydomain.com
    [ -n "$DEBUG" ] && /bin/echo "`/usr/bin/hostname`\tDisk
    $MYDISK\t$RESULT\t$USED% used."

    exit
}


######################################################################
# Main script

# Default to 3, which is state unknown.
RESULT=3
USED="Unknown"

# Get disk line
RAW=`/usr/bin/df -m 2> /dev/null | /usr/bin/egrep "$1" | head -n1`

# If disk $1 was not found, return unknown immediately.
[ -z "$RAW" ] && send_nsca 

# Get percent used
USED=`echo "$RAW" | /usr/bin/awk '{print $4}' | tr -d '%'`

# If current is less than warning, change result code.
[ $USED -lt "$2" ] && RESULT=0

# If current is at warning threshold, change result code.
[ $USED -ge "$2" ] && RESULT=1

# If current is at critical threshold, change result code.
[ $USED -ge "$3" ] && RESULT=2

send_nsca "$1"
----------------------------------------------------------------------

check_proc.sh ----------------------------------------------------------------

#!/bin/sh

# $Id: check_proc.sh,v 1.4 2004/11/23 22:52:07 rladams Exp $    

# check_proc.sh
# Used to check for a process
#
# Syntax:
#
#   check_proc.sh <process-regexp> <operand> <number>
#
# Example:
#
#   check_proc.sh cron -ge 1

######################################################################
# Functions first

function send_nsca {

    /bin/echo "`/usr/bin/hostname`\tProcess $1\t$RESULT\t$NUM
    running." | \
        /usr/local/bin/send_nsca.pl -H nagios.mydomain.com

    [ -n "$DEBUG" ] && \
        /bin/echo "`/usr/bin/hostname`\tProcess $1\t$RESULT\t$NUM
        running."

    exit
}


######################################################################
# Main script

# Default to 3, which is state unknown.
RESULT=3

# Wants ps auxw in /tmp/proclist, cached by wrapper script
NUM=`cat /tmp/proclist | grep "$1" | grep -v grep | wc -l | tr -d ' '`

[ $NUM $2 "$3" ] || RESULT=2
[ $NUM $2 "$3" ] && RESULT=0

send_nsca "$1"
----------------------------------------------------------------------

----- End forwarded message -----


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Nagios-users mailing list
Nagios-users at 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





More information about the Users mailing list