Friday, April 19, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 3229  / 3 Years ago, wed, may 19, 2021, 7:57:06

We would like to monitor few servers,like if the server goes down i
should get a pop-up instantly without fail. I know it is possible,
but i have no idea on how to setup it. It will be so kind if someone helps
me to setup it. Thanks in advance..


More From » monitoring

 Answers
7

You can use ping. Although ping failure doesn't necessarily mean that your system is down, it can also happen if the network is down but I believe for most intents and purposes these are same thing. You can use following script



#!/bin/bash
HOSTS="cyberciti.biz theos.in router"

COUNT=4

for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 0 ]; then
# 100% failed
echo "Host : $myHost is down (ping failed) at $(date)"
fi
done


This is from here. You can also setup a cron job for this or any similar script to ping all your servers after a regular interval.


[#44670] Friday, May 21, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
velelf

Total Points: 395
Total Questions: 115
Total Answers: 107

Location: Sudan
Member since Mon, Jun 1, 2020
4 Years ago
velelf questions
Sat, Nov 6, 21, 05:08, 3 Years ago
Fri, Sep 24, 21, 01:23, 3 Years ago
Sun, Oct 9, 22, 07:37, 2 Years ago
Mon, Oct 10, 22, 08:55, 2 Years ago
;