Solved

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

Posted on 2013-12-06
5
513 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
ID: 39701396
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
ID: 39701419
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
ID: 39701531
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
ID: 39701655
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
ID: 39702276
Excellent!  Works like a charm.  Thank you so much.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

825 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