Ping a server/machine in a batch job

Here's another method that uses the 400 ping command and allows you to account for sometime hic-ups in system response

Here's another method that uses the 400 ping command and allows you to account for sometime hic-ups in system...

response.

PROGRAM STEPS.....

Program reads file Yourlib/YourFile. Yourlib/Yourfile contains the host names of the servers/machines to be monitored. Any additions or removals of hardware need to be reflected in Yourlib/Yourfile. Using Yourfile and the system host table program will ping all servers listed. If the server responds to one or more ping out of five, system will issue a pass status. If the server fails all five requests, a message/page/escape can be sent. This eliminates needless pages on servers that may not respond due to heavy workloads at peak periods.

      
PGM                                                    
                                                       
DCLF       FILE(Yourlib/Yourfile)                              
                                                       
DCL        VAR(&SYSTEM) TYPE(*CHAR) LEN(16)            
DCL        VAR(&MSG) TYPE(*CHAR) LEN(100)              
DCL        VAR(&MSG2) TYPE(*CHAR) LEN(100)             
DCL        VAR(&DECMSG) TYPE(*DEC) LEN(1)              
DCL        VAR(&WAIT) TYPE(*DEC) LEN(2) VALUE(10)      
                                                       
PROGRAM:                                                               
                                                                       
             RCVF                                                      

             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END_JOB))      

             VFYTCPCNN  RMTSYS(&SYSTEM) MSGMODE(*VERBOSE *ESCAPE) +    
                          WAITTIME(&WAIT)                              

             MONMSG     MSGID(TCP3210) EXEC(GOTO CMDLBL(PINGFAIL))     
                                                                       
             GOTO       CMDLBL(PROGRAM)                                

PINGFAIL:                                                                     
                                                                              
             RCVMSG     MSGTYPE(*LAST) MSG(&MSG)                              
                                                                              
             CHGVAR     VAR(&MSG2) VALUE(%SST(&MSG 37 1))                     
                                                                              
             CHGVAR     VAR(&DECMSG) VALUE(&MSG2)                             
                                                                              
             IF         COND(&DECMSG *GE 1) THEN(GOTO CMDLBL(PROGRAM))        
                                                                              
SNDMSG MSG(&SYSTEM *BCAT 'failed a ping request') TOUSR(OPERATOR)    
            
  MONMSG     CPF0000              /* JUST IN CASE, AVOID LOOP */   
                                                                              
            GOTO       CMDLBL(PROGRAM)                                       

END_JOB:  
 
 ENDPGM   

 
Example of a simple physical file

Yourlib/Yourfile

SERVER1
SERVER2
SERVER3
SERVER4
SERVER5
SERVER6
SERVER7
SERVER8

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: Tips, tutorials and more.

Ask your systems management questions--or help out your peers by answering them--in our live discussion forums.

Read this Search400.com Featured Topic: Managing your iSeries.

Ask the Experts yourself: Our systems management gurus are waiting to answer your technical questions.


This was last published in December 2002

Dig Deeper on Performance

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close