Tip

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.

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 first published in December 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.