Created
March 27, 2020 19:09
-
-
Save robberendt/d7c43c92cd9c95ea855fdfef4cb1b466 to your computer and use it in GitHub Desktop.
Just in case you were curious as to what 5250 sessions are getting data sent back and forth and those where the user is asleep...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Used to see if a session is inactive | |
-- Run one capture | |
create or replace table rob.slot_one as ( | |
select | |
current time as initial_time, | |
j.authorization_name, | |
j.remote_address, | |
j.job_type, | |
j.remote_port, | |
j.local_port, | |
n.bytes_sent_remotely, | |
n.bytes_received_locally | |
from qsys2.netstat_job_info j | |
left outer join qsys2.netstat_info n | |
on j.remote_address = n.remote_address and j.remote_port = n.remote_port | |
where j.job_type = 'INTERACTIVE' | |
order by j.authorization_name, j.remote_address | |
) with data | |
on replace delete rows; | |
-- Run second capture after awhile... | |
create or replace table rob.slot_two as ( | |
select | |
current time as initial_time, | |
j.authorization_name, | |
j.remote_address, | |
j.job_type, | |
j.remote_port, | |
j.local_port, | |
n.bytes_sent_remotely, | |
n.bytes_received_locally | |
from qsys2.netstat_job_info j | |
left outer join qsys2.netstat_info n | |
on j.remote_address = n.remote_address and j.remote_port = n.remote_port | |
where j.job_type = 'INTERACTIVE' | |
order by j.authorization_name, j.remote_address | |
) with data | |
on replace delete rows; | |
-- Calculate how many bytes where sent and received between those two times | |
select | |
a.initial_time as initial_time, | |
b.initial_time as ending_time, | |
a.authorization_name, | |
a.remote_address, | |
a.remote_port, | |
b.bytes_sent_remotely - a.bytes_sent_remotely as difference_bytes_sent_remotely, | |
b.bytes_received_locally - a.bytes_received_locally as difference_bytes_received_locally, | |
u.text_description, | |
a.bytes_sent_remotely as starting_bytes_sent_remotely, | |
b.bytes_sent_remotely as ending_bytes_sent_remotely, | |
a.bytes_received_locally as starting_bytes_received_locally, | |
b.bytes_received_locally as ending_bytes_received_locally, | |
a.job_type, | |
a.local_port | |
from ( rob.slot_one a | |
left outer join rob.slot_two b | |
on a.authorization_name = b.authorization_name | |
and a.remote_address = b.remote_address | |
and a.remote_port = b.remote_port ) | |
left outer join user_info u | |
on a.authorization_name = u.authorization_name | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment