- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: How to determine to which IP address a process...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2010 08:19 PM
тАО03-24-2010 08:19 PM
These systems are running TCP/IP services, so the messy way is to do the following basic steps:
1. Use f$getjpi(0,"tt_accpornam") to get the actual port string and from that the port number.
2. Use TCPIP SHOW DEVICE/PORT=
3. Using TCPIP SHOW DEVICE BGnnnn /FULL and parse that output.
Or I could add /FULL to step 2, the TCPIP SHOW DEVICE/PORT=
Is there a simpler way? Maybe a method I have overlooked and maybe a means of not having to send output to a file and parse the file contents?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-24-2010 11:42 PM
тАО03-24-2010 11:42 PM
Re: How to determine to which IP address a process connected
It depends which kind of login (telnet, ssh, ftp), what tt_accpornam contains.
With telnet it is already the IP address (not the port number), with TCPIP SSH my (rather old) version contains nothing, maybe recent TCPIP version containn the same info as for telnet.
In case of no info in tt_accpornam,, there would be a way to do a device scan:
for BG devices, get the owner process ID.
If owner process is my own, then this BG device is one of my connections. Then TCPIP show device will reveal the IP address (although I don't know how to do it "programmatically" other than scanning the output of TCPIP show device).
And caveat: for SSH login, this also doesn't work for non-privileged users, because the device is owned by the SSH server.
For privileged users, there is of course the SDA> SHOW PROCESS/CHANNEL,
which will list the BG device if the process has one allocated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 11:40 AM
тАО03-25-2010 11:40 AM
Re: How to determine to which IP address a process connected
$! Source_IP.COM
$! Get the IP address to which this process connected
$! Jim Geier 25-Mar-2010
$ space = " "
$ if f$mode().nes."INTERACTIVE") then exit
$ nodename = f$getsyi("nodename")
$ fao_ip = "Process !AS on device !AS connected to IP !AS"
$ fao_non_tna = "Process !AS on device !AS not connected via TCP/IP"
$ process_id = f$getjpi(0,"pid")
$ process_device = f$getjpi(process_id,"tt_phydevnam") - "_" - ":"
$ process_username = f$edit(f$getjpi(process_id,"username"),"trim,compress")
$ if f$extract(0,3,process_device) .nes. "TNA"
$ then
$ write sys$output f$fao(fao_non_tna,process_username,process_device)
$ exit
$ endif
$ process_actual_port = f$getjpi(process_id,"tt_accpornam")
$ port_number = f$element(3,space,f$edit(process_actual_port,"trim,compress"))
$
$ create/fdl=sys$input: sys$scratch:bg_port.tmp
record
format stream
$ define/user_mode sys$output sys$scratch:bg_port.tmp
$ tcpip show device/port='port_number'/full
$ open/read bg$file sys$scratch:bg_port.tmp
$ read bg$file bg_record ! Device_socket: line
$ read bg$file bg_record ! heading (LOCAL REMOTE)
$ read bg$file bg_record ! Port: line
$ read bg$file bg_record ! host/data line
$ close/nolog/disposition=delete bg$file
$ bg_record = f$edit(bg_record,"trim,compress")
$ connected_ip_address = f$element(1,space,bg_record)
$ message = f$fao(fao_ip,process_username,process_device,connected_ip_address)
$ write sys$output message
$ exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 12:57 PM
тАО03-25-2010 12:57 PM
Re: How to determine to which IP address a process connected
bg_process shows the bg devices of a process and their statistics
http://dcl.openvms.org/stories.php?story=08/12/02/3240441
find_bg just shows the bg devices owned by a process
http://dcl.openvms.org/stories.php?story=08/06/09/6088086
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 01:39 PM
тАО03-25-2010 01:39 PM
Re: How to determine to which IP address a process connected
> $ process_device = f$getjpi(process_id,"tt_phydevnam") [...]
What's wrong with:
f$getjpi( "", "tt_phydevnam")
?
HELP LEXICALS F$GETJPI Arguments
[...]
If you specify a null string (""), the current PID number is
used.
[...]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2010 06:14 PM
тАО03-25-2010 06:14 PM
Re: How to determine to which IP address a process connected
$ getips == "pipe netstat -an " -
+ "| sea sys$pipe ''f$el(3," ",f$getj("","TT_ACCPORNAM"))' " -
+ "| ( read sys$pipe t ; " -
+ "t=f$ed(t,""COMPRESS"") ; " -
+ "l=f$el(3,"" "",t) ; r=f$el(4,"" "",t) ; " -
+ "p=f$el(4,""."",l) ; l=l-("".""+p) ; " -
+ "p=f$el(4,""."",r) ; r=r-("".""+p) ; " -
+ "def/j/nol MY_LOCAL_IP &l ; def/j/nol MY_REMOTE_IP &r )"
$ getips
$ show logical my_*_ip
All the commands in getips have been stripped to their absolute minimum so that this will work on an OpenVMS VAX system. The fully expanded commands are:
$ getips == "pipe netstat -an " -
+ "| search sys$pipe ''f$element(3, " ", f$getjpi("", "TT_ACCPORNAM"))' " -
+ "| ( read sys$pipe txt ; " -
+ "txt = f$edit(txt, ""COMPRESS"") ; " -
+ "lcl = f$element(3, "" "", txt) ; rem = f$element(4, "" "", txt) ; " -
+ "port = f$element(4, ""."", lcl) ; lcl = lcl - (""."" + port) ; " -
+ "port = f$element(4, ""."", rem) ; rem = rem - (""."" + port) ; " -
+ "define/job/nolog MY_LOCAL_IP &lcl ; " -
+ "define/job/nolog MY_REMOTE_IP &rem )"
The above definition will work on OpenVMS I64 and Alpha (with extended DCL) systems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2010 12:06 AM
тАО03-26-2010 12:06 AM
Re: How to determine to which IP address a process connected
for telnet login I get:
write sys$output f$getj("","TT_ACCPORNAM")
Host: x.y.z.n Port: 58968
tcpip show version
HP TCP/IP Services for OpenVMS Alpha Version V5.4 - ECO 7
on a Digital Personal WorkStation running OpenVMS V7.3-1
So one gets the remote IP address simply by
f$element(1," ",f$getjpi("","TT_ACCPORNAM"))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2010 12:11 AM
тАО03-26-2010 12:11 AM
Re: How to determine to which IP address a process connected
the question was how to obtain the LOCAL IP address to which a session is connected (if you have multiple local IP interfaces).
Volker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2010 12:18 AM
тАО03-26-2010 12:18 AM
Re: How to determine to which IP address a process connected
After reading I misunderstood the question as the source address of the login, not the destion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2010 09:30 PM
тАО03-26-2010 09:30 PM
Re: How to determine to which IP address a process connected
TT_ACCPORNAM does include the port to use in the TCPIP SHOW DEVICE/PORT=nnnn/FULL. But this only occurs IF the telnet session originates on a non-VMS system, for example TT_ACCPORNAM is "Host: 10.1.16.70 Port: 3627" for a current session I have active from my home PC. If the telnet session originates on a VMS system, the format of TT_ACCPORNAM changes to: "Host: 10.1.20.62 Locn: _TNA24:/JGEIER" and that port number is not available.
I can find my source address in "netstat -an" and get the address to which I telnetted, but if there are multiple processes coming from the same source adderss, how do I tell which one is me? it seems that having the port is pretty useful.