Don't know whether you might be able to pull this to pieces.....it was a
node status script we used in the NT4 days to see what was up and what
wasn't. Sorry I can't sanitize it for you at the moment.....it may help. It
pipes server names in from a text file
:: Check supported servers for node availability
@echo off
setlocal
setlocal enableextensions
set log=
set offline=
set srv=
set user=
set log=\\mgtbdc\nt4gp$\availability\nodestatus.log
echo Node status availability report launched by %userdomain%\%username%
%date% %time%>%log%
echo.>>%log%
echo.
echo Checking node status of all DSMC-supported servers...please wait...
echo.
for /f "eol=# tokens=1 delims=," %%a in (\\mgtbdc\nt4gp$\servers.txt
<file://mgtbdc/nt4gp$/servers.txt>) do set srv=%%a& call :CHK
set log=
set offline=
set srv=
set secondary=
set tertiary=
set user=
endlocal
goto :eof
:CHK
set offline=
set secondary=
set tertiary=
echo Checking node status of %srv%...
PING %srv% -n 1 -w 1000 2>NUL | FIND "TTL=" >NUL
if %errorlevel% GTR 0 (set offline=1) else set offline=0
if %offline% EQU 1 (call :SECONDARY) else echo %srv% is online (reply at
%time%)>>%log%
goto :eof
:SECONDARY
echo %srv% failed primary node status check...initiating secondary...
sleep 3
PING %srv% -n 2 -w 1000 2>NUL | FIND "TTL=" >NUL
if %errorlevel% GTR 0 (set secondary=1) else set secondary=0
if %secondary% EQU 0 (echo %srv% failed primary but passed secondary node
status check - online>>%log%) else call :TERTIARY
if %secondary% EQU 0 echo %srv% passed secondary status check.
goto :eof
:TERTIARY
echo %srv% failed secondary node status check...initiating tertiary...
for /f "tokens=2 delims=," %%a in ('type \\mgtbdc\nt4gp$\servers.txt^|find
<file://mgtbdc/nt4gp$/servers.txt%5E%7Cfind> /I "%srv%"') do set defgate=%%a
ping %defgate% -n 1 -w 1000 2>NUL | FIND "TTL=" >NUL
if %errorlevel% GTR 0 (set tertiary=1) else set tertiary=0
if %tertiary% EQU 1 (echo %srv% and default gateway %defgate% are both
offline>>%log%) else echo %srv% is offline - please check immediately>>%log%
if %tertiary% EQU 1 for /f %%a in ('global "EDS_ALERTS" WTSMGT') do set
user=%%a& call :TERTIARYSEND
if %tertiary% EQU 0 for /f %%a in ('global "EDS_ALERTS" WTSMGT') do set
user=%%a& call :SECONDARYSEND
goto :eof
:TERTIARYSEND
msg %user% /SERVER:MGTSRV1 SUBNET STATUS WARNING - %srv% and default
gateway %defgate% both failed ICMP polling at %date% %time%. Please check
possible network outage.
msg %user% /SERVER:MGTSRV2 SUBNET STATUS WARNING - %srv% and default
gateway %defgate% both failed ICMP polling at %date% %time%. Please check
possible network outage.
goto :eof
:SECONDARYSEND
msg %user% /SERVER:MGTSRV2 NODE STATUS WARNING - server %srv% failed
primary and secondary ICMP polling at %date% %time%. Please check node
status immediately.
msg %user% /SERVER:MGTSRV1 NODE STATUS WARNING - server %srv% failed
primary and secondary ICMP polling at %date% %time%. Please check node
status immediately.
goto :eof
On 6 November 2014 16:13, David McSpadden <[email protected]> wrote:
> I want to run a windows batch the just does a ping.
>
> If the ping returns good data do nothing but if the ping fails set an
> error code I can look for and address it outside the batch.
>
> Anyone have or can point me to a . b a t script that does this already??
>
> Thanks
>
>
>
> This e-mail and any files transmitted with it are property of Indiana
> Members Credit Union, are confidential, and are intended solely for the use
> of the individual or entity to whom this e-mail is addressed. If you are
> not one of the named recipient(s) or otherwise have reason to believe that
> you have received this message in error, please notify the sender and
> delete this message immediately from your computer. Any other use,
> retention, dissemination, forwarding, printing, or copying of this email is
> strictly prohibited.
>
> Please consider the environment before printing this email.
>
--
*James Rankin*
---------------------
RCL - Senior Technical Consultant (ACA, CCA, MCTS) | The Virtualization
Practice Analyst - Desktop Virtualization
http://appsensebigot.blogspot.co.uk