Solved

Retrieve iSeries Host Name

Posted on 2010-11-30
9
1,388 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 35

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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Programmer 26 551
AS400 DAYOFWEEK(GENERAL DATE) 12 410
Read spool files from iseries in C# 4 284
Access to SYSIBM tables 7 109
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
This article shows theĀ method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scannerā€¦

830 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