Bohack

Check In and Tune Out!
 
 
« LAN Party Bean Soup
Windows Version of the Linux / UNIX ‘which’ Command »

Simple Server Ping and Reboot Monitor



I think we have all rebooted a server and then asked ourselves “Did it actually reboot?”. So we hunt through the logs for the event and then move on or reboot it again. During patch day for the servers this can be a real nag, knowing when something is back online so you can finish patching it; is key to getting the job done. So I wrote this little batch script a while ago to help keep track.

Once it’s started via the command of ‘pingmon servername’. It will echo the time it started monitoring, then the alive time of a successful ping back. Once the host goes dead, it will echo the time it went dead or lost ping. Then it will echo the time it has gone alive again and quit. Simple batch script with one purpose, to make the administrator’s life simple.

Just copy and paste the script below into notepad and save it as “pingmon.cmd”

@echo off

rem Bohack - pingmon.cmd - 2002i

set ipname=%1

if {%ipname%}=={} (GOTO :errhand)

set /a calive=0
set /a cdead=0
set /a cexit=0

echo.
echo.
echo Monitoring %ipname%
echo.
echo ** Started %date% - %time%
echo.

:loop

FOR /F “skip=3 tokens=1,2*” %%a IN (’ping -n 1 %ipname%’) DO CALL :checkdo %%a
if %cexit% EQU 1 (goto :mend)

goto :loop

:checkdo

set reply=%1
if {%reply%}=={} (goto :end)
set replytruc=%reply:~0,5%
if /I {%replytruc%}=={Reply} (goto :alive)
if /I {%replytruc%}=={Reque} (goto :dead)
goto :end

:alive

if %calive% EQU 0 (echo ** Alive %date% - %time%)
set /a calive=1
if %cdead% GTR 0 (echo ** Alive %date% - %time%) & (set /a cexit=1)

goto :end

:dead

if %cdead% LSS 1 (echo ** Dead  %date% - %time%)
set /a cdead=1

goto :end

:errhand

echo.
echo.
echo Usage PingMon {computer or IP}

:mend

echo.
echo.

:end

Tags: Script, Windows

This entry was posted on Sunday, November 16th, 2008 at 8:36 pm and is filed under Windows.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.

Comments are closed.

  • Channels

    • Beer (2)
    • Blog (1)
    • Exchange (2)
    • Ham Radio (1)
    • Homebrew (3)
    • Linux / Unix (4)
    • Misc (1)
    • Mods (4)
    • Networking (1)
    • Programming (4)
    • Recipes (2)
    • Scripts (7)
    • Security (1)
    • Software (2)
    • Spam (1)
    • Telco (7)
    • Virtual PC (1)
    • VMware (3)
    • VOIP (3)
    • Windows (16)
    • Windows 2008 (4)
    • Windows 7 (5)
  • Archives

    • September 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • November 2011
    • September 2011
    • July 2011
    • April 2011
    • February 2011
    • January 2011
    • October 2010
    • August 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • June 2009
    • May 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
  • Links

    • Blogarama Blogarama – The Blog Directory
    • BlogHub Blog Directory
    • Blogrankings Technology Blogs – Blog Rankings
    • Blogville.us blogville.us
    • Buzzerhut free directory | buzzerhut.com
    • Ontoplist Online Marketing
    • Primechoiceautoparts Discount Auto Parts
    • PTC My Employer
 

  Copyright - Bohack 2025 ©