Skip to content

Instantly share code, notes, and snippets.

@dancarlosgabriel
Forked from forstie/ddm server.sql
Created June 15, 2022 01:38
Show Gist options
  • Save dancarlosgabriel/a39cfc1ccb5a3087ddc1cc7a2f200af6 to your computer and use it in GitHub Desktop.
Save dancarlosgabriel/a39cfc1ccb5a3087ddc1cc7a2f200af6 to your computer and use it in GitHub Desktop.
The request... use SQL to determine if the DDM/DRDA server was active, and if not, start it.
--
-- Subject: The request... use SQL to determine if the DDM/DRDA server was active, and if not, start it.
-- Author: Scott Forstie
-- Date : June, 2022
-- Features Used : This Gist uses QSYS2.ACTIVE_JOB_INFO, BOOLEAN, QSYS2.QCMDEXC scalar function, CTE, case expression
--
--
-- Is the DDM/DRDA listener active? (If at IBM i 7.4 or earlier)
--
select count(*) as DDM_DRDA_Listener_Active
from table (
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN')
);
stop;
--
-- Is the DDM/DRDA listener active? (If at IBM i 7.5 or later)
--
select boolean(count(*)) as DDM_DRDA_Listener_Active
from table (
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN')
);
stop;
--
-- Restart the *DDM TCPSVR as needed (If at IBM i 7.4 or later)
--
with ddmsvr (started) as (
select count(*) as DDM_DRDA_Listener_Active
from table (
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN')
)
)
select
case started
when 0 then qsys2.qcmdexc('QSYS/STRTCPSVR SERVER(*DDM)')
else 1
end
from ddmsvr;
stop;
--
-- Restart the *DDM TCPSVR as needed (If at IBM i 7.5 or later)
--
with ddmsvr (started) as (
select boolean(count(*)) as DDM_DRDA_Listener_Active
from table (
qsys2.active_job_info(SUBSYSTEM_LIST_FILTER => 'QSYSWRK', JOB_NAME_FILTER => 'QRWTLSTN')
)
)
select
case started
when false then qsys2.qcmdexc('QSYS/STRTCPSVR SERVER(*DDM)')
else 1
end
from ddmsvr;
stop;
--
-- Is the DDM/DRDA server active?
--
select subsystem, count(*) as QRWTSRVR_Jobs
from table (
qsys2.active_job_info(JOB_NAME_FILTER => 'QRWTSRVR')
)
group by subsystem;
stop;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment