Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use SQL's NETSTAT and ACTIVE_JOB_INFO services to identify and explore active 5250 sessions.
--
-- description: Find active Telnet or Interactive 5250 sessions
--
-- resource: ibm.biz/WellDefinedIBMiPorts
--
select remote_address, remote_port, authorization_name as user_name, job_name
from qsys2.netstat_job_info n
where local_port in (23,992) and job_type = 'INTERACTIVE';
--
-- description: Find Interactive jobs
--
select * from table(qsys2.active_job_info(
subsystem_list_filter => 'QINTER',
detailed_info => 'ALL')) b where job_type = 'INT';
--
-- description: Join them together (secret sauce)
--
with active5250(remote_address, remote_port, user_name, job_name) as (
select remote_address, remote_port, authorization_name as user_name, job_name
from qsys2.netstat_job_info n
where local_port in (23,992) and job_type = 'INTERACTIVE'
)
select remote_address, remote_port, user_name, a.job_name,
sql_statement_status, sql_statement_text, b.* from active5250 a inner join
table(qsys2.active_job_info(subsystem_list_filter => 'QINTER',
detailed_info => 'ALL')) b
on a.job_name = b.job_name where job_type = 'INT';
@chrjorgensen

This comment has been minimized.

Copy link

commented Jun 29, 2019

Nice tool - maybe you should include port 992 for 5250 over SSL... hopefully there would be more connections on this port than on port 23...! :-)

@forstie

This comment has been minimized.

Copy link
Owner Author

commented Jun 30, 2019

Great point... updated.
Thanks Christian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.