Solved

Retrieve iSeries Host Name

Posted on 2010-11-30
9
1,338 Views
Last Modified: 2012-05-10
I have a CL that I am using to monitor system messages and I want to be able to alert our helpdesk with the server name of the issue. Originally I was pulling the System Name value from RTVNETA, but can't do this because we have production and HA failover servers with the same 'system name'.  I want to use the TCP Host Name (configured in the CHGTCPDMN command.

Does anyone know of a way to pull that information within a CL?

I appreciate any help.
0
Comment
Question by:Matthew Roessner
9 Comments
 
LVL 34

Assisted Solution

by:Gary Patterson
Gary Patterson earned 250 total points
ID: 34242816
Use the gethostname() API to get the TCP hostname:

http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Fghostn.htm

- Gary Patterson

0
 
LVL 1

Author Comment

by:Matthew Roessner
ID: 34247009
Do you have any examples of how to use this successfully in a CL program? I had previously found this API, but have been unable to get it working. I am sure it is a result of my lack of knowledge regarding APIs...

Thank you again for the help
0
 
LVL 6

Assisted Solution

by:Jon Snyderman
Jon Snyderman earned 250 total points
ID: 34248112
With CL, you can simply use QSYS/RTVNETA SYSNAME('&VARIABLE').

Jon
0
 
LVL 1

Accepted Solution

by:
Matthew Roessner earned 0 total points
ID: 34248267
I actually found and used a different API. My code is below for anyone who wants to check it out:

PGM

/*DECLARE VARIABLES */                                      
         DCL  &name           *CHAR     (10)                
         DCL  &RcvVar         *CHAR     750                
             DCL        VAR(&APIERR) TYPE(*CHAR) LEN(8) +  
                          VALUE(X'0000000000000000')        
             DCL        VAR(&FORMAT) TYPE(*CHAR) LEN(8) +  
                          VALUE('TCPA0300')                
         dcl  &RcvVarLen      *CHAR     4                  
     chgvar %Bin(&RcvVarLen) 750                            
     callprc 'QtocRtvTCPA' ( +                              
                            &RcvVar    +                    
                            &RcvVarLen +                    
                            &Format    +                      
                            &ApiErr)                          
                                                               
                                                               
    chgvar &name %SST(&rcvvar 177 10)                          
                                                               
                                                               
                                                               
              SNDMSG     MSG('Server Name: ' *BCAT &name) +    
                           TOUSR(USERNAME)                      
                                                               
                                                               
                                                               
                                                               
  RETURN                                                        
  ENDPGM
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:Jon Snyderman
ID: 34248275
Glad it worked, but Wow!  Wouldnt the one liner that I listed be a lot cleaner with lower CPU cycles?

Jon
0
 
LVL 1

Author Comment

by:Matthew Roessner
ID: 34248294
The RVTNETA doesn't return the same value as the API I used. We set our 'system name' in the network attributes to be the same as our serial number. We set our TCP name up as the same as our DNS name.  I wanted to retrieve the TCP system name, not the network attribute system name. They are 2 separate things...
0
 
LVL 6

Expert Comment

by:Jon Snyderman
ID: 34248298
My bad.  Sorry guys.  (back peddling now)  I thought you were looking for the sysname.  Not the TCP host name.

Jon
0
 
LVL 27

Expert Comment

by:tliotta
ID: 34251673
To use gethostname(), code something like this:
pgm
   dcl   &hostname    *char  257
   dcl   &size        *int           value( 256 )

   callprc     'gethostname'  ( &hostname (&size *byval) )
   callprc     'strlen'       ( &hostname ) rtnval( &size )

   sndpgmmsg   msg( 'Host name is' *bcat %sst(&hostname 1 &size) )
   dmpclpgm

   return
endpgm

Open in new window

Compile that example as a *MODULE. Use CRTPGM to bind it as a *pgm while referencing BNDDIR( QC2LE ). The gethostname() API is always available to everything, but strlen() needs to look in the ILE C functions through QC2LE. I can never remember which service program supplies strlen() and related functions, but QC2LE always finds them.

Tom
0
 
LVL 1

Author Closing Comment

by:Matthew Roessner
ID: 34281056
Found a different API to use that worked. Thanks guys
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A procedure for exporting installed hotfix details of remote computers using powershell
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now