netstat_info is the way to go. Here is a simple example of something we were doing to monitor for connections on port 992.
insert into kevin/ssllog select
SUBSTR(JOB_NAME,LOCATE_IN_STRING(JOB_NAME,'/',-1)+1),
Remote_address, local_address, Authorization_name , now() FROM
qsys2.netstat_job_info WHERE local_port = 992 AND
authorization_name IS NOT NULL AND authorization_name <> 'QTCP' and
job_type = 'INTERACTIVE'
This was run from a cl like this.
PGM
RUNSQL: RUNSQLSTM SRCFILE(KEVIN/QSQLSRC) SRCMBR(SSLLOGSQL) +
COMMIT(*NONE) OPTION(*NOLIST)
MONMSG MSGID(CPF0000 SQL0000)
DLYJOB DLY(1800)
GOTO CMDLBL(RUNSQL)
ENDPGM
And for an example of the API, this is some I had laying around. Not sure what we were doing, but it looks for connections on port 8190 as is. Easy enough to modify to capture the info you need.
https://code.midrange.com/57c3dc1a60.html
On Tue, 2021-09-07 at 12:38 -0500, Jacob Banda wrote:
Hello there,
I would like to take snapshots defined at some interval (e.g., every 15
minutes) of the active TCP/IP connections on my system, dumping them to a
spool or stream file. Traditionally, I would go WRKTCPSTS *CNN (or NETSTAT
*CNN) and sort the list to my liking. This is great for one-offs, but I need
to monitor the connections throughout the day, preferably with me not at a
green screen hitting F5 every 15 minutes, followed by F6. The following
archived post bears some similarity:
https://archive.midrange.com/midrange-l/200208/msg01652.html.
I am aware of the "List Network Connections (QtocLstNetCnn) API" found here
(
https://www.ibm.com/docs/en/i/7.4?topic=ssw_ibm_i_74/apis/qtoclstnetcnn.htm
) and the QSYS2.NETSTAT_INFO view. The tools are there. What I lack is the
knowledge to use them. Any suggestions?
------------
Jacob
------------
[
https://www.medtronsoftware.com/img/MedtronMinilogo.bmp] Kevin Bucknum
Senior Programmer Analyst
MEDDATA / MEDTRON
120 Innwood Drive
Covington LA 70433
Local: 985-893-2550
Toll Free: 877-893-2550
https://www.medtronsoftware.com
CONFIDENTIALITY NOTICE
This document and any accompanying this email transmission contain confidential information, belonging to the sender that is legally privileged. This information is intended only for the use of the individual or entity named above. The authorized recipient of this information is prohibited from disclosing this information to any other party and is required to destroy the information after its stated need has been fulfilled. If you are not the intended recipient, or the employee of agent responsible to deliver it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or action taken in reliance on the contents of these documents is STRICTLY PROHIBITED. If you have received this email in error, please notify the sender immediately to arrange for return or destruction of these documents.
As an Amazon Associate we earn from qualifying purchases.