Solved

How to detect when a server stops being pinged by another device?

Posted on 2013-12-06
5
511 Views
Last Modified: 2013-12-06
My workplace has a Windows network with about 60 PCs running Windows 7.  I'm in the process of configuring a Linux-based monitoring server that will be running Nagios and Cacti.  I also have access to a cloud-based VPS running Ubuntu.

I'd like to use the VPS to monitor the monitoring server and issue an alert if the monitoring server goes down.  As it stands now, the monitoring server will not be visible outside the LAN, and I don't want to make any changes to the firewall.  My thought is to have the monitoring server continuously ping the VPS.  If the pinging stops, the VPS will send me an alert via email.

I've done some Googling, but I can't find any information about a way to issue an alert when a server stops receiving pings from another machine.

I'm a Linux newbie, and any help would be appreciated.  Thanks!
0
Comment
Question by:chernavsky
  • 2
  • 2
5 Comments
 
LVL 19

Assisted Solution

by:xterm
xterm earned 325 total points
Comment Utility
On the VPS just run:

tcpdump -w myfile.output icmp and host <ip address of monitoring server>

Then you can just script something else to watch myfile.output and tell you if it stops growing.
0
 
LVL 57

Assisted Solution

by:giltjr
giltjr earned 25 total points
Comment Utility
You will want to make sure you stop the process and delete myfile.output every now and then or it will continue to grow forever.
0
 

Author Comment

by:chernavsky
Comment Utility
xterm, I installed tcpdump, and it's detecting the pings.  Thanks for that.  What do you suggest for a script?  Something in BASH that checks the size of the myfile.output file once per minute, and then sends an email alert if the size didn't change from the previous cycle?  Or is there a simpler way?  Thanks again.
0
 
LVL 19

Accepted Solution

by:
xterm earned 325 total points
Comment Utility
Here's a little shell script that will do what you need:

#!/bin/sh

FILE_TO_WATCH="myfile.output"
if [ ! -f $FILE_TO_WATCH ]; then
        echo "Capture file not found, please edit value FILE_TO_WATCH in this script"
        exit 1
fi

EMAILRCPT="you@youraddress.com"
OLDSIZE=0

while :;
do
        MYFILESIZE=`du -b $FILE_TO_WATCH | awk '{print $1}'`
        if [ $OLDSIZE -eq $MYFILESIZE ]; then
                mail -s "Ping capture file did not grow" $EMAILRCPT < /dev/null 
        else
                OLDSIZE=$MYFILESIZE
        fi
        sleep 30
done

Open in new window


Keep in mind though, you might want to have it exit after it mails you (add a line with "exit 0" below that line) otherwise you will get an email every 30 seconds until the pings resume again.

And of course, every once in a while you probably want to remove the output file and re-run the script because it will keep growing over time.
0
 

Author Closing Comment

by:chernavsky
Comment Utility
Excellent!  Works like a charm.  Thank you so much.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Phishing is at the top of most security top 10 efforts you should be pursuing in 2016 and beyond. If you don't have phishing incorporated into your Security Awareness Program yet, now is the time. Phishers, and the scams they use, are only going to …
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now