1.

Solve : Batch command for Pings?

Answer»

Morning all,

Im hoping someone here may be able to help me out here.
I'm  DBA and IT support Tech and have a few servers I investigate from time to time and sadly I'm NEW to my enviroment and the referance data for System names and IP addresses is rather lacking.

SO what i want to do is have a look at a few systems and return are they up, and what are the IP addresses.

So to that end i developped a really simple DOS Batch for the one but cant get the 2nd part now, just cant seem to figure it out.

Heres the Batch file coding.

Code: [Select]:====8<-----[ Pinger V2.bat ]-----
ECHO OFF
TITLE Network Check
setlocal enabledelayedexpansion

REM -----------------------------------
REM -- Files
REM -----------------------------------

SET MachineList=ping.txt
SET ResultsFile=results.txt

REM -----------------------------------
REM -- Checks
REM -----------------------------------

CLS
ECHO.
IF NOT EXIST "%MachineList%" (
  ECHO Cannot locate Machine List: %MachineList%
    PAUSE>NUL
      GOTO :EOF
      )
 
REM -----------------------------------
REM -- Running Notice
REM -----------------------------------

      ECHO PROCESSING all machine names in %MachineList% . . .
      ECHO.
 
REM -----------------------------------
REM -- Machine Responds
REM -----------------------------------

      FOR /f "tokens=*" %%M in (%MachineList%) do CALL :CHECK "%%M"
          GOTO :EOF

      :CHECK
      SET Machine=%~1
      SET Machine=%Machine: =%

      PING -w 1000 %Machine%>NUL
        IF %ERRORLEVEL% NEQ 0 ECHO %Machine% did not respond at %Time%>>%ResultsFile%
        IF NOT %ERRORLEVEL% NEQ 0 ECHO %Machine% responded at %Time%>>%ResultsFile%

      EXIT /B

 
 
:EOF
:====8<-----[ Pinger V2.Bat]-----

Can someone possibly help me in adding a IP value to my "IF %ERRORLEVEL% NEQ 0 ECHO %Machine% did not respond at %Time%>>%ResultsFile%" string

Thanks a TON in advance.I also monitor my servers etc and use a cheap and great piece of software called Alert PING Pro. You add your systems to monitor to it and you can create your own programs to execute if you LIKE or be notified by e-mail etc if there are problems. I wrote a C++ program that worked between a modified VOIP phone, the software, and a handset release relay connected through serial port that would TRIGGER handset release to activate phone, so that it would call my cell phone repeatedly and play out a *.wav file instructing the error condition. This way I got called as the problem was detected and on my drive to the workplace I had a hint as to where the problem was etc. It also has many other features such as color coding ping response times etc, so if you want to watch areas of your network for bottlenecking etc.

http://www.softpedia.com/get/Network-Tools/Network-Monitoring/AlertPingPro.shtml



Discussion

No Comment Found