Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Retrieve iSeries Host Name

Posted on 2010-11-30
9
Medium Priority
?
1,524 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 1000 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 1000 total points
ID: 34248112
With CL, you can simply use QSYS/RTVNETA SYSNAME('&VARIABLE').

Jon
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Did you know there are services out there that can turn an Instagram feed into an RSS feed? I found some interesting exclusive Instagram content which I wanted to follow without signing up for yet another social media account. RSS to the rescue!
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

972 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