Network Overview Alert

Jon Lyons jlyons30 at yahoo.com
Fri Mar 21 02:05:52 CET 2003


Mine isn't as pretty, .. :) but gives an e-mail like;
Nag stat H:       0/     387 S:       1/     445 ***Hosts:   
***Service: 300sr-users-Ping 300srtunrtra-Ping socksohi2.bankone.net-TCP-SOCKS5 
#!/usr/local/bin/bash 
LOGFILE=/usr/local/var/nagios/status.log
HOST=`/usr/bin/grep HOST $LOGFILE | /usr/bin/grep CRITICAL | /usr/bin/awk -F\; '{printf $2 " "}'`
SERVICE=`/usr/bin/grep SERVICE $LOGFILE | /usr/bin/grep CRITICAL | /usr/bin/awk -F\; '{printf $2"-"$3 " "}'` 
UP=`/usr/bin/grep HOST $LOGFILE | /usr/bin/grep UP | wc -l`
DOWN=`/usr/bin/grep HOST $LOGFILE | /usr/bin/grep CRITICAL | wc -l ` 
SUP=`/usr/bin/grep SERVICE $LOGFILE | /usr/bin/grep OK | wc -l`
SDOWN=`/usr/bin/grep SERVICE $LOGFILE | /usr/bin/grep CRITICAL | wc -l ` 
echo "Nag stat H:$DOWN/$UP S:$SDOWN/$SUP ***Hosts: $HOST  ***Service: $SERVICE" $1 | mailx -s nagstats jlyons30 at yahoo.com 



Frank Sweetser <fes at users.sourceforge.net> wrote: On Thu, Mar 20, 2003 at 02:39:44PM -0800, wasson at brawleyonline.com wrote:
> I'd like to set up nagios to send a morning 'overall network status' in a
> single email/SMS message. I'd like the alert to briefly list broken hosts
> and services or send an "Everything is up" message. I can set up a time
> period and run a custom command during that time, but I am getting stuck
> when I think about what command I actually want this to run.
> I didn't find anything in the FAQ or mailing list archives about this, but
> if it's been covered, please direct me to it.
> Tony Wasson

Here's a couple of scripts that I just started using here for just such
a purpose. Call nagcechk from cron, editing it to fit your paths.

-- 
Frank Sweetser fs at wpi.edu
WPI Network Engineer
#!/bin/bash

MSG=`mktemp /tmp/nagcheck-$$-XXXXXX`
if [ ! -f $MSG -o ! -w $MSG ] ; then
exit;
fi

/usr/lib/nagios/plugins/check_nagios /var/log/nagios/status.log 5 '/usr/sbin/nagios' | sed -e 's/:.*//' > $MSG 2>&1
/usr/local/bin/nagios-summary >> $MSG 2>&1

cat $MSG | mail -s 'Nagios Heartbeat' fs at wpi.edu
cat $MSG | /usr/local/bin/qpage -f nagios -p fs

rm -f $MSG
#!/usr/bin/perl -w

use strict;

my $logfile = $ARGV[0] || "/var/log/nagios/status.log";

open(STAT, "<$logfile") or die "Can't open logfile $logfile: $!\n";

my $line;
my %hst;
my %svc;

while(){
next if /^#/;
$_ =~ s/^\S*\s*//;
my @inf = split(/;/);
if ($inf[0] eq 'HOST'){
$hst{$inf[2]}++;
}elsif ($inf[0] eq 'SERVICE'){
$svc{$inf[3]}++;
}
}

print "Hosts: ";
foreach my $key (keys %hst){
print $key, ": ", $hst{$key}, " ";
}
print "\n";

print "Svcs: ";
foreach my $key (keys %svc){
print $key, ": ", $svc{$key}, " ";
}
print "\n";




---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20030320/455d543a/attachment.html>


More information about the Users mailing list