Solved

Retrieve iSeries Host Name

Posted on 2010-11-30
9
1,414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
as400 interactive sql phone number search 7 146
iSeries Bath SFTP CL Program Problem 6 523
iSeries Memory Utilization 2 104
Varsity Logistics Speedwigh and AS/400 issues 18 75
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
One event, two days, a great line-up of speakers, and 48% female presence. Still have no idea what I’m talking about?
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 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