[Nagiosplug-devel] Ping multiple IP addresses

Joe Rhett jrhett at meer.net
Fri Dec 31 11:46:03 CET 2004


This really isn't a plugin, it's a state of being.  It is probably handled
better by using a group of hosts and checking their state. (so as to not do
the same tests twice, if you are testing those hosts for other reasons)

As in, this plugin should just check other service states and make a
result based on their state, IMHO.  That would make it very general and
useful.
 
... and probably easier to implement with Nagios v2's groups...

On Wed, Dec 15, 2004 at 01:42:21PM -0700, Gabriel Somlo wrote:
> Hey,
> 
> I needed to figure out when our connectivity to the Net is down (e.g.,
> to determine whether it's worth sending an alert to something like 
> <cellphone-number>@provider.net
> 
> If our outside connectivity is down, these pages won't make it through
> and I need to use a modem-dialer to deliver the pages.
> 
> So, I came up with a plugin that pages multiple hosts or IP addresses
> and has warning and critical thresholds on how many of them must be
> 'up' before I call our outside connectivity 'down'.
> 
> Do you guys think this might be a worthwhile addition to the
> nagios-plugins package ? Should I rewrite it in C, or is it good
> enough as a shell script ?
> 
> Please let me know what you think. Cc me on followups, or tell me to
> quit whining and subscribe to the list :)
> 
> Thanks,
> Gabriel
> 
> -----------begin multiping script-------------------------------------
> 
> #!/bin/bash
> 
> #
> # multiping -- ping a list of hosts for Nagios
> # Gabriel L. Somlo, 2004-12-15
> #
> 
> print_usage () {
>   echo
>   echo "Usage:  $0 HOST[:HOST[:HOST...]] <#warn> <#crit>"
>   echo
>   echo "   First arg. is a colon-separated list of HOSTs to ping"
>   echo "   Second arg. is the warning threshold"
>   echo "   Third arg. is the critical threshold"
>   echo "      Note: #warn > #crit !"
>   echo
> }
> 
> # check presence of required arguments
> if [ -z "${1}" -o -z "${2}" -o -z "${3}" ]; then
>   print_usage
>   exit 1
> fi
> 
> # check validity of #warn and #crit thresholds
> if ((${2}<=${3})); then
>   print_usage
>   exit 2
> fi
> 
> # count total hosts and 'up' hosts
> let TOTAL=0 UP=0
> for H in $(echo "${1}" | tr ':' ' '); do
>   ping -qc1 ${H} > /dev/null 2>&1
>   if [ "${?}" == "0" ]; then
>     let UP++
>   fi
>   let TOTAL++
> done
> 
> # print results
> if ((UP>${2})); then
>   echo "MULTIPING OK - up ${UP}/${TOTAL}"
> elif ((UP>${3})); then
>   echo "MULTIPING WARNING - up ${UP}/${TOTAL}"
> else
>   echo "MULTIPING CRITICAL - up ${UP}/${TOTAL}"
> fi
> 
> -----------end multiping script----------------------------------------
> -- 
> -----------------------------------------------------------------------
> Gabriel L. Somlo               Academic Computing & Networking Services
> Colorado State University      Tel: (970)297-3707   Cell: (970)567-1017
> 601 Howes St., Room 619C       Fax: (970)491-1958 
> Fort Collins, CO 80523-2028 e-mail: somlo at acns dot colostate dot edu
> -----------------------------------------------------------------------
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now. 
> http://productguide.itmanagersjournal.com/
> _______________________________________________________
> Nagios Plugin Development Mailing List Nagiosplug-devel at lists.sourceforge.net
> Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
> ::: Please include plugins version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null

-- 
Joe Rhett
Senior Geek
Meer.net




More information about the Devel mailing list