• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Ping Servers Script

Hi experts

We have some guys refitting our server room, this week, im concearned they could knock a cable out so im looking for a script to monitor the servers.

Im thinking a constant ping which emails me if a server stops responding. Any help would be greatly appreciated, IP's below.

  • 2
1 Solution
Steve KnightIT ConsultancyCommented:
The one thing I would say is.... where is your mail server, in the server room?  What about if they knock out one of the switches, or power to it, then also no email :-)

You can certainly do this but you might be better off just having something running on a workstation.  This is a simple script I use for instance for quick checking... just add your ip's in as lines here, with a description of each.  If you add in an external IP or two then it will tell you if they have knocked out your external comms too..


@Echo off
setlocal enabledelayedexpansion
set pinglog=pinglog.txt
set fail=0

echo %date%,%time%,Log Started
echo %date%,%time%,Log Started >>%pinglog%

REM ping some hosts

Call :pingit "PIPEX DNS"
call :pingit, "ROUTER"
call :pingit, "SERVER1"

REM The dot on the next line is Control G "BEL" which beeps... add is using EDIT from CMD prompt.
if "%fail%"=="1" echo 

REM Wait 2 mins

call :delay10 3
goto next

exit /b

  echo WAITING...
  ping -w 10000 -n %~1 >NUL 2>&1
exit /b

echo PING %~2 [%1]
ping %1 -n 1 -w 200 >NUL || (
  echo     %date%,%time%,FAIL,%1,%~2 >> %pinglog%
  echo     %date%,%time%,FAIL,%1,%~2
  set fail=1
exit /b

Open in new window

Think I have a few other examples on http://scripts.dragon-it.co.uk/ , if not I will do once I upload some!

coreccAuthor Commented:
this does the job, thanks for your help.
Steve KnightIT ConsultancyCommented:
No problem, been caught out by customers' well meaning server-check scripts that email... which of course don't work when you most want them to - dns, router, internet connection, mail server down etc..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now