Distributed Monitoring
Dmitriy Kirhlarov
dimma at higis.ru
Mon Jan 22 11:08:40 CET 2007
On Mon, Jan 22, 2007 at 11:28:43AM +0200, Moayad Mohammad wrote:
> I have one nagios server working in my company, and I
> need to add another nagios server to monitor another servers in other
> subnets,
>
> I don't know if there's any solution to have 2 nagios servers(1 central
> nagios) and 1 monitor screen... it's mean the second server will send
> all check results to the central nagios.
It's work in our installation.
But, I don't find no one web config tool support this. :(
It's not complicated.
Look schema:
Central Host (location1 + location2)
^ ^
| |
| |
location1 location2
You making service_template_locations and host_template_locations. On
central host and on locations it's different templates
(active_check_enable 0 and 1 correspondingly)
All checks for locations based on this templates.
Next, you must setup nsca on central host and send_nsca on
location{1,2},
configure on location{1,2}:
obsess_over_services=
ocsp_command=
obsess_over_hosts=
ochp_command=
and disable direct notification on locations -- only central host
sending notifications.
Also, good idea make checks on location{1,2} for nagios on central
host (over nrpe) and make eventhandler in this check for enabling
notification directly on location[1,2}, when nagios on central host
dead.
eventhadler example:
--------------------
#!/bin/sh
# $Id: service_notification,v 1.1 2006/01/18 14:40:02 dkirhlarov Exp $
# this handler switching notifications.
# for details contact dimma at oilspace.com
DATE="`which date 2>/dev/null`" || DATE="/bin/date"
CAT="`which cat 2>/dev/null`" || CAT="/bin/cat"
BASENAME="`which basename 2>/dev/null`" || BASENAME="/bin/basename"
ECHO="`which echo 2>/dev/null`" || ECHO="/bin/echo"
AWK="`which awk 2>/dev/null`" || AWK="/bin/awk"
PRINTF="`which printf 2>/dev/null`" || PRINTF="/usr/bin/printf"
PROGNAME=`${BASENAME} $0`
NAGIOSCMD="/usr/local/nagios/var/rw/nagios.cmd"
NOW=`${DATE} +%s`
print_help() {
${CAT} <<EOF
Event Handler for switch on|off notifications
Usage: $PROGNAME -s $SERVICESTATE$ -st $SERVICESTATETYPE$ [-c /path/to/nagios/cmd/file]
Keys:
-s -- STATE of service
-st -- TYPE of service STATE
(for details read nagios documentation)
-c -- command nagios socket. By default /usr/local/nagios/var/rw/nagios.cmd
Usage: $PROGNAME --help
EOF
}
enable_event() {
${PRINTF} "[%lu] ENABLE_NOTIFICATIONS\n" ${NOW} > ${NAGIOSCMD}
}
disable_event() {
${PRINTF} "[%lu] DISABLE_NOTIFICATIONS\n" ${NOW} > ${NAGIOSCMD}
}
# Make sure the correct number of command line
# arguments have been supplied
if [ $# -lt 4 ]; then
print_help
exit -1
fi
$ECHO $* >> /usr/local/nagios/var/event.out
# Grab the command line arguments
while [ -n "$1" ]; do
case "$1" in
--help|-h)
print_help
exit -1
;;
-s)
# state of service
STATE=$2
shift
;;
-st)
# state type of service
STATETYPE=$2
shift
;;
-c)
# command file
NAGIOSCMD=$2
shift
;;
*)
${ECHO} "Wrong param '$1'"
print_help
exit -1
;;
esac
shift
done
# Run check
case "$STATETYPE" in
HARD)
case "$STATE" in
CRITICAL)
# Time to enabling local notification feature
enable_event
;;
WARNING|UNKNOWN)
# Just smoke
;;
OK)
# Disable local notification feature
disable_event
;;
*)
# What the shit we are get?
${ECHO} "What?.. Can't understand '$STATE'"
exit -1
;;
esac
;;
esac
exit 0
--------------------
WBR.
Dmitriy
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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