Additionally, you can create another script that uses the FOR command to check ALL your servers so you don’t have to check one by one. Have the script do the job for you.
The key to this script is the command SAPINFO.exe, which comes on the SAPFrontEnd CD (SAPGUI). It’s part of the SDK. If you don’t have the file, e-mail me and I’ll send it to you.
The syntax of SAPINFO is:
sapinfo ashost=host sysnr=nn
When used in a batch file (.bat or .cmd) you can check the errorlevel returned by the program. If it is 1 then the system is not up and running.
My script below first checks if the system is on the network by ‘pinging’ it and expecting a reply.
If you want to check all your systems, then create another script (example: checkallrfcs.bat) and use this command:
FOR /F %%i in (SAPsystems.txt) do call checkrfc %%i 00
The command above reads the file SAPsystems.txt, which should have a list of all the servers (one server name per line) and then it invokes the script ‘checkrfc’ passing the server name as a parameter. The 00 indicates the instance number.
I believe you will find it extremely useful and it will save you tons of time.
Now, you can just run the script, sit back and watch it report the status of the systems.
rem Script: CheckRFC.BAT
rem It uses SAPINFO from the RFC-SDK (SAPGUI) to check an RFC destination.
rem It needs two parameters: 1. Hostname 2. Instance Number
rem A ping is sent to the host. If successful an RFC check is carried out.
rem By: Giovanni Davila
if “%2″==”" goto NoParameter
echo Pinging %1 …
ping %1 -n 2 | find /i “reply” >nul && goto CheckRFC
echo System does not exist on the network! & goto Bye
sapinfo ashost=%1 sysnr=%2 & if errorlevel 1 goto System_Down
echo System is up. RFC checks OK!
echo System is down!
echo You did not specify at least one parameter!
echo Syntax: checkrfc “hostname” “instance number”
echo Example: checkrfc mydev 00