🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.privacy.anon-server
Article #312350

Re: Ping redjohn

#312350
From: inwtx
Date: Thu, 17 Dec 2020 20:08
48 lines
2428 bytes
> 
<snip>
> 
> For my servers I have been using an online notification service called
> UptimeRobot <https://uptimerobot.com> which sends an email when it
> notices the server is unreachable. But using your script in addition to
> uptimerobot.com is an even better solution since if the entire box goes
> offline your script won't be able to notify. But UptimeRobot will.
> 
  Yes, I have each of my servers check each of my other servers by
running this script on all of them:


#!/bin/bash
#
# ServerMonitor.sh
#
# This script monitors any number of external servers to try to determine if
# they are up and reachable.  I execute it every 5 minutes.  Place the foreign
# server(s) domain name or IP number in the ServerArray below.  To temporarily
# disable checking a server, place a # at the beginning of its line in the array.
#
# Cron: Cron: */5 * * * * /root/ServerMonitor.sh &> /dev/null
#

filePath=${0%/*}  # current file path

emailaddr="your@email.address"

ServerArray=(
"mixport.xyz"     # mixport.xyz
"mixharbor.xyz"   # mixharbor.xyz
#"inwtx.xyz"       # inwtx.xyz
)

for index in ${!ServerArray[*]}; do
    cat /dev/null > $filePath/ServerMonitor.txt            # empty work file
    varserv=${ServerArray[index]}                          # get a server DN from ServerArray
    $(ping -c3 -w3 $varserv > $filePath/ServerMonitor.txt) # ping another server 3 times and timeout after 3 seconds

    if [[ $(grep -c "0 received" $filePath/ServerMonitor.txt) -gt 0 ]]; then
       mutt -s "Warning: Server $varserv may be down!" $emailaddr <<< "Warning: Server $varserv may be down!"   # send error
    fi
done

rm $filePath/ServerMonitor.txt                             # delete work file

exit 0
Technical Details
Message-ID: <rrgdr6$t68$1@news.mixmin.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
References: <LKLCH.39543$EA2.698@fx01.iad>

Show Full Headers
Complete Article Headers
Message-ID: <rrgdr6$t68$1@news.mixmin.net>
Subject: Re: Ping redjohn
Date: Thu, 17 Dec 2020 14:08:07 -0600
From: "inwtx" <noreply@inwtx.net>
References: <LKLCH.39543$EA2.698@fx01.iad>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail
Newsgroups: alt.privacy.anon-server
Organization: Mixmin
Injection-Date: Thu, 17 Dec 2020 20:08:07 -0000 (UTC)
Injection-Info: news.mixmin.net; posting-host="14dacb797dbe11327430ab8a9921de15e1063b5f"; logging-data="29896"; mail-complaints-to="abuse@mixmin.net"