System API で NETSTAT 情報と関連ジョブの SQL の取得 (V5R4)

System API で NETSTAT 情報の取得 (V5R4)」と「ソケットごとの実行 SQL (可変長) とその状況の収集 (V5R4)」を組み合わせて、

IP アドレス(の範囲)とポートを指定すると、関連しているジョブが実行中の SQL を取ってくる、

というツールを作ってみました。

特に新しいことはないので、特別に説明することはありません。(というか、ちょっと今はまだ書く余裕がないので…)
ソースやコマンドをとりあえず公開します。「どうしてこうなっているのか?」といったようなことに対する説明は、必ずこのサイト内にあるので、探して参照してみてくださいね。

取得情報格納用のテーブル

とりあえず、取得した情報は「System API で NETSTAT 情報の取得 (V5R4)」と同様にデータベースに格納することにしました。

NETSTAT で取れるような情報を格納するテーブルと

CREATE TABLE NETSQLINF.NETSTAT                 
      (COUNT CHAR ( 5) NOT NULL WITH DEFAULT,  
       REMOTE_ADDR CHAR ( 15) NOT NULL WITH DEFAULT,      
       REMOTE_PORT CHAR ( 5) NOT NULL WITH DEFAULT,       
       LOCAL_ADDR CHAR ( 15) NOT NULL WITH DEFAULT,       
       LOCAL_PORT CHAR ( 5)  NOT NULL WITH DEFAULT,       
       TCP_STATE CHAR ( 11) NOT NULL WITH DEFAULT,        
       IDLE_TIME DEC ( 10, 0),                            
       BYTES_IN DEC ( 10, 0),                             
       BYTES_OUT DEC ( 10, 0),                            
       OPEN_TYPE CHAR ( 11) NOT NULL WITH DEFAULT,        
       CONNECTION_TYPE CHAR ( 10) NOT NULL WITH DEFAULT,  
       USER_PROFILE CHAR ( 10) NOT NULL WITH DEFAULT,     
       INQUIRED_DATE TIMESTAMP NOT NULL WITH DEFAULT);

NETSTAT のより詳細な情報と関連ジョブの SQL 情報を格納するテーブルと

CREATE TABLE NETSQLINF.SQLLOG                             
      (COUNT CHAR (5 ) NOT NULL WITH DEFAULT,             
       REMOTE_ADDR CHAR (15 ) NOT NULL WITH DEFAULT, 
       REMOTE_PORT CHAR (5 ) NOT NULL WITH DEFAULT,  
       LOCAL_ADDR CHAR (15 ) NOT NULL WITH DEFAULT,  
       LOCAL_PORT CHAR (5 ) NOT NULL WITH DEFAULT,       
       JOB_NAME CHAR (10 ) NOT NULL WITH DEFAULT,         
       JOB_USER CHAR (10 ) NOT NULL WITH DEFAULT,         
       JOB_NUMBER CHAR (6 ) NOT NULL WITH DEFAULT,        
       CURSOR_STATUS CHAR (5 ) NOT NULL WITH DEFAULT,     
       SQL_TEXT VARCHAR (1024 ) NOT NULL WITH DEFAULT,    
       ACT_JOB_STATUS CHAR(4 ) NOT NULL WITH DEFAULT,     
       DB_LOCK_WAITS INTEGER NOT NULL WITH DEFAULT,       
       INT_MCH_WAITS INTEGER NOT NULL WITH DEFAULT,       
       NDB_LOCK_WAITS INTEGER NOT NULL WITH DEFAULT,      
       DB_LOCK_WAITS_TIME INTEGER NOT NULL WITH DEFAULT,  
       INT_MCH_WAITS_TIME INTEGER NOT NULL WITH DEFAULT,  
       NDB_LOCK_WAITS_TIME INTEGER NOT NULL WITH DEFAULT, 
       THREAD_COUNT INTEGER NOT NULL WITH DEFAULT,         
       CPU_TIME SMALLINT NOT NULL WITH DEFAULT,            
       AUX_IO INTEGER NOT NULL WITH DEFAULT,               
       PAGE_FAULTS INTEGER NOT NULL WITH DEFAULT,          
       ELAPSED_TIME INTEGER NOT NULL WITH DEFAULT,         
       ASYNC_IO INTEGER NOT NULL WITH DEFAULT,             
       SYNC_IO INTEGER NOT NULL WITH DEFAULT,              
       ELAPSED_TIME_PERC INTEGER NOT NULL WITH DEFAULT,    
       ELAPSED_CPU_TIME INTEGER NOT NULL WITH DEFAULT,     
       ELAPSED_LOCK_WAITS INTEGER NOT NULL WITH DEFAULT,   
       ELAPSED_PAGE_FAULTS INTEGER NOT NULL WITH DEFAULT,  
       INQUIRED_DATE TIMESTAMP NOT NULL WITH DEFAULT);    

の二つのテーブルを事前に作成しておく必要があります。

それぞれ、最初に COUNT というカラムがありますが、これはツールで情報を取るときに「何回取得したら終了」というように終了条件の指定を行っているのですが、その「何回」めかを示します。
この COUNT カラムとその他の IP アドレス情報等がキーになる、というイメージですね。

テーブルを格納するスキーマ(ライブラリー)は NETSQLINF という名前にしています。ツールと同じライブラリーにしたくなかっただけで、特別な意味/意図はありません。

NETSTAT 詳細情報と関連ジョブの SQL の取得

今回作ったメインのプログラムです。

     H bnddir('QC2LE')                                                                              
      *                                                                                             
      *  CREATE TABLE NETSQLINF/SQLLOG                                                              
      *        (COUNT CHAR (5 ) NOT NULL WITH DEFAULT,                                              
      *         REMOTE_ADDR CHAR (15 ) NOT NULL WITH DEFAULT,                                       
      *         REMOTE_PORT CHAR (5 ) NOT NULL WITH DEFAULT,                                        
      *         LOCAL_ADDR CHAR (15 ) NOT NULL WITH DEFAULT,                                        
      *         LOCAL_PORT CHAR (5 ) NOT NULL WITH DEFAULT,                                         
      *         JOB_NAME CHAR (10 ) NOT NULL WITH DEFAULT,                                          
      *         JOB_USER CHAR (10 ) NOT NULL WITH DEFAULT,                                          
      *         JOB_NUMBER CHAR (6 ) NOT NULL WITH DEFAULT,                                         
      *         CURSOR_STATUS CHAR (5 ) NOT NULL WITH DEFAULT,                                      
      *         SQL_TEXT VARCHAR (1024 ) NOT NULL WITH DEFAULT,                                     
      *         ACT_JOB_STATUS CHAR(4 ) NOT NULL WITH DEFAULT,                                      
      *         DB_LOCK_WAITS INTEGER NOT NULL WITH DEFAULT,                                        
      *         INT_MCH_WAITS INTEGER NOT NULL WITH DEFAULT,                                        
      *         NDB_LOCK_WAITS INTEGER NOT NULL WITH DEFAULT,                                       
      *         DB_LOCK_WAITS_TIME INTEGER NOT NULL WITH DEFAULT,                                   
      *         INT_MCH_WAITS_TIME INTEGER NOT NULL WITH DEFAULT,                                   
      *         NDB_LOCK_WAITS_TIME INTEGER NOT NULL WITH DEFAULT,                                  
      *         THREAD_COUNT INTEGER NOT NULL WITH DEFAULT,                                         
      *         CPU_TIME SMALLINT NOT NULL WITH DEFAULT,                                            
      *         AUX_IO INTEGER NOT NULL WITH DEFAULT,                                               
      *         PAGE_FAULTS INTEGER NOT NULL WITH DEFAULT,                                          
      *         ELAPSED_TIME INTEGER NOT NULL WITH DEFAULT,                                         
      *         ASYNC_IO INTEGER NOT NULL WITH DEFAULT,                                             
      *         SYNC_IO INTEGER NOT NULL WITH DEFAULT,                                              
      *         ELAPSED_TIME_PERC INTEGER NOT NULL WITH DEFAULT,                                    
      *         ELAPSED_CPU_TIME INTEGER NOT NULL WITH DEFAULT,                                     
      *         ELAPSED_LOCK_WAITS INTEGER NOT NULL WITH DEFAULT,                                   
      *         ELAPSED_PAGE_FAULTS INTEGER NOT NULL WITH DEFAULT,                                  
      *         INQUIRED_DATE TIMESTAMP NOT NULL WITH DEFAULT);                                     
      *                                                                                             
      *                                                                                             
      *  CRTSQLRPGI OBJ(NETSQLTOOL/RTVNETSQL) SRCFILE(NETSQLTOOL/QRPGLESRC)                         
      *             COMMIT(*NONE) OBJTYPE(*MODULE) DBGVIEW(*SOURCE)                                 
      *                                                                                             
      *  CRTPGM PGM(NETSQLTOOL/RTVNETSQL)                                                           
      *         MODULE(NETSQLTOOL/RTVNETSQL NETSQLTOOL/RTVSQLINF NETSQLTOOL/CRTUSRSPCP)             
      *                                                                                             
      *                                                                                             
     D RtvNetSQL       PR                                                                           
     D  pProtocol                     4a                                                            
     D  lAddr                        15a                                                            
     D  lPort                         5a                                                            
     D  rAddr                        15a                                                            
     D  rPort                         5a                                                            
     D  count                         5a                                                            
      *                                                                                             
     D RtvNetSQL       PI                                                                           
     D  pProtocol                     4a                                                            
     D  lAddr                        15a                                                            
     D  lPort                         5a                                                            
     D  rAddr                        15a                                                            
     D  rPort                         5a                                                            
     D  count                         5a                                                            
      *                                                                                             
     D RtvNetCnnDta    Pr                  ExtProc( 'QtocRtvNetCnnDta' )                            
     D  spRcvVar                  65535a   Options( *VarSize )                                      
     D  spRcvVarLen                  10i 0 Const                                                    
     D  spFmtName                     8a   Const                                                    
     D  spSocReq                       *   value                                                    
     D  spError                   32767a   Options( *VarSize: *Omit )                               
     **                                                                                             
      *                                                                                             
     D inet_addr       Pr            10u 0 ExtProc( 'inet_addr' )                                   
     D  srcAddr                        *   value options(*string)                                   
      *                                                                                             
     D RtvJobSQL       PR                                                                           
     D  JobName                      10a   CONST                                                    
     D  UserName                     10a   CONST                                                    
     D  JobNumber                     6a   CONST                                                    
     D  SQLStmt                   65535a   VARYING Options(*VarSize)                                
     D  SQLStatus                     5a                                                            
      *                                                                                             
     D CrtUsrspcP      PR              *                                                            
     D  Name                         20a                                                            
      *                                                                                             
     D RtvJobSts       PR                  EXTPGM('QUSRJOBI')                                       
     D  RcvVar                    65535a   Options(*VarSize)                                        
     D  RcvVarLen                    10i 0 Const                                                    
     D  FmtName                       8a   Const                                                    
     D  QualJobName                  26a   Const                                                    
     D  InternalJobID                16a   Const                                                    
     D  ErrorCode                          like(ERRC0100)                                           
     D  ResetPfrStat                  1a   Const                                                    
      *                                                                                             
     D JOBI1000        DS                  Qualified Based(usPtr10)                                 
     D  NbrBytesRtn                  10i 0                                      Bytes Returned      
     D  NbrBytesAvl                  10i 0                                      Bytes Available     
     D  JobName                      10a                                        Job name            
     D  UsrName                      10a                                        Job user            
     D  JobNbr                        6a                                        Job number          
     D  InternalJobID                16a                                        Internal Job id     
     D  JobSts                       10a                                        Job status          
     D  JobType                       1a                                        Job type            
     D  JobSubType                    1a                                        Job subtype         
     D  rsvd                          2a                                                            
     D  ElapsTim                     20u 0                                      Elapsed time        
     D  durDiskIO                    20u 0                                      Disk I/O during     
     D  durDiskIOAsc                 20u 0                                      Disk I/O async      
     D  durDiskIOSyc                 20u 0                                      Disk I/O sync       
     D  IntRspTim                    10i 0                                      Interactive rsp     
     D  IntTrans                     10i 0                                      Interancive txs     
     D  CPU                          10i 0                                      CPU %               
     D  DbCPU                        10i 0                                      DB CPU %            
     D  CPUT                         20u 0                                      CPU Time            
     D  DbCPUT                       20u 0                                      DB CPU Time         
     D  LCKWT                        20u 0                                      Lock wait time      
     D  PageFltCounts                20u 0                                      Page fault          
      *                                                                                             
     D JOBI0200        DS                  Qualified Based(usPtr2)                                  
     D  NbrBytesRtn                  10i 0                                      Bytes Returned      
     D  NbrBytesAvl                  10i 0                                      Bytes Available     
     D  JobName                      10a                                        Job name            
     D  UsrName                      10a                                        Job user            
     D  JobNbr                        6a                                        Job number          
     D  InternalJobID                16a                                        Internal Job id     
     D  JobSts                       10a                                        Job status          
     D  JobType                       1a                                        Job type            
     D  JobSubType                    1a                                        Job subtype         
     D  SBSD                         10a                                        SBSD name           
     D  RUNPTY                       10i 0                                      Run priority        
     D  POOLID                       10i 0                                      System pool id      
     D  CPUTime                      10i 0                                                          
     D  numAUXIO                     10i 0                                                          
     D  numIntTrans                  10i 0                                      Interactive txs     
     D  TotRsp                       10i 0                                      Rsp time total      
     D  FuncTyp                       1a                                        Function type       
     D  FuncNam                      10a                                        Function name       
     D  ActJobSts                     4a                                        Active job status   
     D  numDBLW                      10i 0                                      DB lock waits       
     D  numIntLW                     10i 0                                      Internal lock w     
     D  numNDBLW                     10i 0                                      NDB lock waits      
     D  timDBLW                      10i 0                                      DB lock waits time  
     D  timIntLW                     10i 0                                      Internal lock w time
     D  timNDBLW                     10i 0                                      NDB lock waits time 
     D  rsvd                          1a                                                            
     D  curPOOLID                    10i 0                                      Current pool id     
     D  THDCount                     10i 0                                      Thread count        
     D  totCPUT                      20u 0                                      CPU time total      
     D  numAUXIOReq                  20u 0                                      AUX IO reqs         
     D  totDBCPUT                    20u 0                                      DB CPU time total   
     D  PageFlts                     20u 0                                      Page faults         
     D  ActJStsEnd                    4a                                        Act job status end  
     D  MemPoolNam                   10a                                        Memory poll name    
     D  MsgRpy                        1a                                        Message reply       
      *                                                                                             
     **-- Api error data structure:                                                                 
     D ERRC0100        Ds                  Qualified                                                
     D  BytPro                       10i 0 Inz( %Size( ERRC0100 ))                                  
     D  BytAvl                       10i 0 Inz                                                      
     D  MsgId                         7a                                                            
     D                                1a                                                            
     D  MsgDta                      128a                                                            
      *                                                                                             
     **-- Global variables:                                                                         
     D ApiRcvSiz       s             10u 0                                                          
     **                                                                                             
     DSocReqInfo       DS                  Qualified                                                
     D Protocol                      10U 0                                      Protocol            
     D LocalIP                       10U 0                                      Local IP Address    
     D LocalPort                     10U 0                                      Local Port Number   
     D RemoteIP                      10U 0                                      Remote IP Address   
     D RemotePort                    10U 0                                      Remote Port Number  
      *                                                                                             
     DNCND0100         DS                  Qualified BASED(p2CnnInfo)                               
     D BytRtnd                       10U 0                                      Bytes Returned      
     D BytAvl                        10U 0                                      Bytes Available     
     D TCPConnCur                    10U 0                                      TCP Connections Cur 
     D TCPActiveOpn                  10U 0                                      TCP Active Opens    
     D TCPPasiveOpn                  10U 0                                      TCP Passive Opens   
     D TCPAtOpnFail                  10U 0                                      TCP Attempted Opn F 
     D TCPEstRset                    10U 0                                      TCP Established And 
     D TCPSegSent                    10U 0                                      TCP Segments Sent   
     D TCPRtrsmtSeg                  10U 0                                      TCP Retransmited Sg 
     D TCPRsetSeg                    10U 0                                      TCP Reset Segments  
     D TCPSegRcvd                    10U 0                                      TCP Segments Rcvd   
     D TCPSegRcvdErr                 10U 0                                      TCP Segments Rcvd Er
     D UDPDtagrmSent                 10U 0                                      UDP Datagrams Sent  
     D UDPDtagrmRcvd                 10U 0                                      UDP Datagrams Rcvd  
     D UDPDtagrmNDNF                 10U 0                                      UDP Datagrms ND NF  
     D UDPDtagrmNDDE                 10U 0                                      UDP Datagrms ND Err 
     D OffSet2Add                    10U 0                                      Offset To Add Info  
     D Len4AddInf                    10U 0                                      Length Of Add Info  
      *                                                                                             
     DNCND0200         DS                  Qualified BASED(p2Cnd2Info)                              
     D Protocol                      10U 0                                      Protocol            
     D LocalIP                       10U 0                                      Local IP Address    
     D LocalPort                     10U 0                                      Local Port Number   
     D RemoteIP                      10U 0                                      Remote IP Address   
     D RemotePort                    10U 0                                      Remote Port Number  
     D RoundTripTime                 10U 0                                      Round Trip Time     
     D RoundTripVar                  10U 0                                      Round Trip Variance 
     D OutByteBuf                    10U 0                                      Outgoing Bytes Buff 
     D UsrSndNxt                     10U 0                                      User Send Next      
     D SndNxt                        10U 0                                      Send Next           
     D SndUnAck                      10U 0                                      Send Unacknowledged 
     D OutPushNbr                    10U 0                                      Outgoing Push No    
     D OutUrgNbr                     10U 0                                      Outgoing Urgency No 
     D OutWindNbr                    10U 0                                      Outgoing Window No  
     D InByteBuf                     10U 0                                      Incoming Bytes Buff 
     D RcvNxt                        10U 0                                      Receive Next        
     D UsrRcvNxt                     10U 0                                      User Receive Next   
     D InPushNbr                     10U 0                                      Incoming Push No    
     D InUrgNbr                      10U 0                                      Incoming Urgency No 
     D InWindNbr                     10U 0                                      Incoming Window No  
     D TotRetrnsmt                   10U 0                                      Total Retransmit    
     D CurRetrnsmt                   10U 0                                      Currect Retransmit  
     D MaxWindSize                   10U 0                                      Maximum Window Size 
     D CurWindSize                   10U 0                                      Current Window Size 
     D LastUpdate                    10U 0                                      Last Update         
     D LastUpdateAckd                10U 0                                      Last Update Acked   
     D CongWind                      10U 0                                      Congestion Window   
     D SlowStrThresld                10U 0                                      Slow Start Threshold
     D MaxSegSize                    10U 0                                      Max Segment Size    
     D InitSendSeqNbr                10U 0                                      Init Send Seq No    
     D InitRcvSeqNbr                 10U 0                                      Init Receive Seq No 
     D ConnTrnpLayr                  10U 0                                      Conn Transport Layer
     D TCPState                      10U 0                                      TCP State           
     D CnnOpnType                    10U 0                                      Conn Open Type      
     D IdleTimeMsec                  10U 0                                      Idle Time Millisec  
     D IPOptions                     40a                                        IP Options          
     D ByteIn                        10U 0                                      Bytes In            
     D BytesOut                      10U 0                                      Bytes Out           
     D SocState                      10U 0                                      Socket State        
     D OfsLstSocOpt                  10U 0                                      Offset List Of Sock 
     D SocOptNbr                     10U 0                                      Num Soc Opts W Cnn  
     D EntLenSocOpt                  10U 0                                      Ent Len Soc Opts    
     D Ofs2LstJobs                   10U 0                                      Ofs List Jobs A W C 
     D HowManyJobsCnn                10U 0                                      Num Jobs A W Conn   
     D EntLenLstJobs                 10U 0                                      Ent Len Jobs A W Cnn
     D AssocUSRPRF                   10a                                        Associated USRPRF   
     D rsvd                           2a                                        reserved            
      *                                                                                             
     DJobInfo          DS                  Qualified  BASED(p2JobInfo)                              
     D FmtEntry                      10u 0                                      Format Entry        
     D Taskname                      16a                                        Format Entry        
     D JobName                       10a                                        Job Name            
     D JobUser                       10a                                        Job User            
     D JobNumber                      6a                                        Job Number          
     D IntJobID                      16a                                        Job Internal ID     
     D JobType                        1a                                        Job Type            
     D rsvd                           7a                                        reserved            
     D CurUSRPRF                     10a                                        Associated USRPRF   
      *                                                                                             
     D  i              S             10u 0                                                          
     D  pSQLStatus     S              5a                                                            
     D  pSQLStmt       S          65535a   VARYING                                                  
     D  SQLTEXT        S           1024a                                                            
      *                                                                                             
     D QualJobName     DS            26    Qualified                                                
     D  Job                          10a                                                            
     D  User                         10a                                                            
     D  JobNO                         6a                                                            
      *                                                                                             
     D pName           S             20a                                                            
     D usPtr           S               *                                                            
      *                                                                                             
     D RcvSize         S             10  0 INZ(16776704)                                            
      *                                                                                             
      /Free                                                                                         
                                                                                                    
             *inLR = *on;                                                                           
                                                                                                    
             ApiRcvSiz = 65535;                                                                     
             p2CnnInfo = %alloc( ApiRcvSiz );                                                       
             NCND0100.BytAvl = *Zero;                                                               
                                                                                                    
             Select ;                                                                               
                when pProtocol = '*TCP' ;                                                           
                     SocReqInfo.Protocol = 1 ;                                                      
                when pProtocol = '*UDP' ;                                                           
                     SocReqInfo.Protocol = 2 ;                                                      
                other ;                                                                             
                     return ;                                                                       
             endSL ;                                                                                
                                                                                                    
             if lAddr = *blank ;                                                                    
                return ;                                                                            
             else ;                                                                                 
                SocReqInfo.LocalIP = inet_addr(%trimR(lAddr)) ;                                     
             endif ;                                                                                
                                                                                                    
             if lPort = *blanks ;                                                                   
                return ;                                                                            
             else ;                                                                                 
                SocReqInfo.LocalPort = %int(lPort) ;                                                
             endif ;                                                                                
                                                                                                    
             if rAddr = *blank ;                                                                    
                return ;                                                                            
             else ;                                                                                 
                SocReqInfo.RemoteIP = inet_addr(%trimR(rAddr)) ;                                    
             endif ;                                                                                
                                                                                                    
             if rPort = *blanks ;                                                                   
                return ;                                                                            
             else ;                                                                                 
                SocReqInfo.RemotePort = %int(rPort) ;                                               
             endif ;                                                                                
                                                                                                    
             doU  NCND0100.BytAvl <= ApiRcvSiz     Or                                               
                  ERRC0100.BytAvl  > *Zero;                                                         
                                                                                                    
                if  NCND0100.BytAvl > ApiRcvSiz;                                                    
                   ApiRcvSiz = NCND0100.BytAvl;                                                     
                   p2CnnInfo = %reAlloc( p2CnnInfo: ApiRcvSiz );                                    
                endIf;                                                                              
                                                                                                    
                RtvNetCnnDta( NCND0100                                                              
                            : ApiRcvSiz                                                             
                            : 'NCND0200'                                                            
                            : %addr(SocReqInfo)                                                     
                            : ERRC0100                                                              
                            );                                                                      
                                                                                                    
              endDo;                                                                                
                                                                                                    
              if  ERRC0100.BytAvl = *Zero;                                                          
                                                                                                    
                 p2Cnd2Info = p2CnnInfo + NCND0100.OffSet2Add ;                                     
                                                                                                    
                 if NCND0200.HowManyJobsCnn = *Zero;                                                
                    return ;                                                                        
                 endIf ;                                                                            
                                                                                                    
                 pName =    'JOBI0200  QTEMP     ' ;                                                
                 usPtr2 = CrtUsrspcP  (pName ) ;                                                    
                 pName =    'JOBI1000  QTEMP     ' ;                                                
                 usPtr10 = CrtUsrspcP  (pName ) ;                                                   
                                                                                                    
             //  p2JobInfo = p2Cnd2Info + NCND0200.Ofs2LstJobs ;                                    
             //  Not offset from NCND0200 but NCND0100 ... (see above)                              
                 p2JobInfo = p2CnnInfo + NCND0200.Ofs2LstJobs ;                                     
                                                                                                    
                 for i = 1 to NCND0200.HowManyJobsCnn ;                                             
                 // do something                                                                    
                    RtvJobSQL( JobInfo.JobName                                                      
                             : JobInfo.JobUser                                                      
                             : JobInfo.JobNumber                                                    
                             : pSQLStmt                                                             
                             : pSQLStatus                                                           
                             );                                                                     
                                                                                                    
                    QualJobName.Job = JobInfo.JobName ;                                             
                    QualJobName.User = JobInfo.JobUser ;                                            
                    QualJobName.JobNO = JobInfo.JobNumber ;                                         
                                                                                                    
                    RtvJobSts( JOBI0200                                                             
                             : RcvSize                                                              
                             : 'JOBI0200'                                                           
                             :  QualJobName                                                         
                             :  *blanks                                                             
                             : ERRC0100                                                             
                             : '0'                                                                  
                             ) ;                                                                    
                                                                                                    
                    RtvJobSts( JOBI1000                                                             
                             : RcvSize                                                              
                             : 'JOBI1000'                                                           
                             :  QualJobName                                                         
                             :  *blanks                                                             
                             : ERRC0100                                                             
                             : '0'                                                                  
                             ) ;                                                                    
                                                                                                    
                    SQLText = %subst(pSQLStmt:1) ;                                                  
                                                                                                    
                    exec SQL                                                                        
                       INSERT INTO NETSQLINF/SQLLOG                                                 
                       VALUES( :count,                                                              
                               :rAddr,                                                              
                               :rPort,                                                              
                               :lAddr ,                                                             
                               :lPort ,                                                             
                               :JobInfo.JobName,                                                    
                               :JobInfo.JobUser,                                                    
                               :JobInfo.JobNumber,                                                  
                               :pSQLStatus,                                                         
                               :SQLText,                                                            
                               //JOBI0200                                                           
                               :JOBI0200.ActJobSts,                                                 
                               :JOBI0200.numDBLW,                                                   
                               :JOBI0200.numIntLW,                                                  
                               :JOBI0200.numNDBLW,                                                  
                               :JOBI0200.timDBLW,                                                   
                               :JOBI0200.timIntLW,                                                  
                               :JOBI0200.timNDBLW,                                                  
                               :JOBI0200.THDCount,                                                  
                               :JOBI0200.totCPUT,                                                   
                               :JOBI0200.numAUXIOReq,                                               
                               :JOBI0200.PageFlts,                                                  
                               //JOBI1000                                                           
                               :JOBI1000.ElapsTim,                                                  
                               :JOBI1000.durDiskIOAsc,                                              
                               :JOBI1000.durDiskIOSyc,                                              
                               :JOBI1000.CPU,                                                       
                               :JOBI1000.CPUT,                                                      
                               :JOBI1000.LCKWT,                                                     
                               :JOBI1000.PageFltCounts,                                             
                               CURRENT_TIMESTAMP                                                    
                             ) ;                                                                    
                                                                                                    
                    p2JobInfo = p2JobInfo + NCND0200.EntLenLstJobs ;                                
                                                                                                    
                 endfor ;                                                                           
                                                                                                    
              else ;                                                                                
                                                                                                    
              // sndmsg ERRC0100.MSGID                                                              
                                                                                                    
              endIf;                                                                                
                                                                                                    
              dealloc p2CnnInfo ;                                                                   
                                                                                                    
              return;                                                                               
                                                                                                    
      /End-Free                                                                                     

NETSTAT 情報の取得

System API で NETSTAT 情報の取得 (V5R4)」のプログラムに↑のプログラムを呼び出すように変更したものです。
リモート IP アドレスを範囲指定できるように、ちょっとした変更も加えています。

     H bnddir('QC2LE')                                                                              
      *                                                                                             
      *  CREATE TABLE NETSQLINF/NETSTAT                                                             
      *        (COUNT CHAR ( 5) NOT NULL WITH DEFAULT,                                              
      *         REMOTE_ADDR CHAR ( 15) NOT NULL WITH DEFAULT,                                       
      *         REMOTE_PORT CHAR ( 5) NOT NULL WITH DEFAULT,                                        
      *         LOCAL_ADDR CHAR ( 15) NOT NULL WITH DEFAULT,                                        
      *         LOCAL_PORT CHAR ( 5)  NOT NULL WITH DEFAULT,                                        
      *         TCP_STATE CHAR ( 11) NOT NULL WITH DEFAULT,                                         
      *         IDLE_TIME DEC ( 10, 0),                                                             
      *         BYTES_IN DEC ( 10, 0),                                                              
      *         BYTES_OUT DEC ( 10, 0),                                                             
      *         OPEN_TYPE CHAR ( 11) NOT NULL WITH DEFAULT,                                         
      *         CONNECTION_TYPE CHAR ( 10) NOT NULL WITH DEFAULT,                                   
      *         USER_PROFILE CHAR ( 10) NOT NULL WITH DEFAULT,                                      
      *         INQUIRED_DATE TIMESTAMP NOT NULL WITH DEFAULT)                                      
      *                                                                                             
      *                                                                                             
      *  CRTSQLRPGI OBJ(NETSQL/GETNETINF) SRCFILE(NETSQL/QRPGLESRC)                                 
      *             COMMIT(*NONE) OBJTYPE(*MODULE) DBGVIEW(*SOURCE)                                 
      *                                                                                             
      *  CRTPGM PGM(NETSQL/GETNETINF)                                                               
      *         MODULE(NETSQL/GETNETINF NETSQL/RTVNETSQL NETSQL/CRTUSRSPCP NETSQL/RTVJOBSQL)        
      *                                                                                             
      *                                                                                             
     D GetNetInf       PR                                                                           
     D  lAddr                        15a                                                            
     D  lPort                         5a                                                            
     D  rAddrlow                     15a                                                            
     D  rAddrupp                     15a                                                            
     D  rPort                         5a                                                            
     D  count                         5a                                                            
      *                                                                                             
     D GetNetInf       PI                                                                           
     D  lAddr                        15a                                                            
     D  lPort                         5a                                                            
     D  rAddrlow                     15a                                                            
     D  rAddrupp                     15a                                                            
     D  rPort                         5a                                                            
     D  count                         5a                                                            
      *                                                                                             
     D CrtUsrspcP      PR              *                                                            
     D  Name                         20a                                                            
      *                                                                                             
     D LstNetCnn       Pr                  ExtProc( 'QtocLstNetCnn' )                               
     D  pUsrspcName                  20a   Const                                                    
     D  pFormatName                   8a   Const                                                    
     D  pCnnQual                     64a   Const                                                    
     D  pCnnQualSiz                  10i 0 Const                                                    
     D  pCnnQualFmt                   8a   Const                                                    
     D  ErrorCode                          like(APIErr)                                             
      *                                                                                             
     D RtvNetSQL       PR                                                                           
     D  pProtocol                     4a                                                            
     D  lAddr                        15a                                                            
     D  lPort                         5a                                                            
     D  rAddr                        15a                                                            
     D  rPort                         5a                                                            
     D  count                         5a                                                            
      *                                                                                             
     D inet_addr       Pr            10u 0 ExtProc( 'inet_addr' )                                   
     D  srcAddr                        *   value options(*string)                                   
      *                                                                                             
     D GenericHeader   DS                  Qualified Based(usPtr)                                   
     D  userarea                     64a                                                            
     D  size                         10i 0                                                          
     D  releaselevel                  4                                                             
     D  formatname                    8                                                             
     D  APIused                      10                                                             
     D  DateCreated                  13                                                             
     D  InforSts                      1                                                             
     D  sizeUsed                     10i 0                                                          
     D  offsetInput                  10i 0                                                          
     D  sizeInput                    10i 0                                                          
     D  offsetHeader                 10i 0                                                          
     D  sizeHeader                   10i 0                                                          
     D  offsetList                   10i 0                                                          
     D  sizeList                     10i 0                                                          
     D  numberList                   10i 0                                                          
     D  sizeEntry                    10i 0                                                          
     D  CCSID                        10i 0                                                          
     D  cntryID                       2                                                             
     D  langID                        3                                                             
     D  subsetInd                     1                                                             
     D  rsvd                         42                                                             
      *                                                                                             
     D jlPtr           S               *                                                            
     D NCNN0100        DS                  Qualified Based(jlPtr)                                   
     D  RmtAddr                      15a                                                            
     D  rsvd1                         1a                                                            
     D  RmtAddrBin                   10i 0                                                          
     D  LclAddr                      15a                                                            
     D  rsvd2                         1a                                                            
     D  LclAddrBin                   10i 0                                                          
     D  RmtPort                      10i 0                                                          
     D  LclPort                      10i 0                                                          
     D  TcpState                     10i 0                                                          
     D  IdleMs                       10i 0                                                          
     D  BytesIn                      20i 0                                                          
     D  BytesOut                     20i 0                                                          
     D  ConnOpenT                    10i 0                                                          
     D  NetConnT                     10a                                                            
     D  rsvd3                         2a                                                            
     D  UsrPrf                       10a                                                            
     D  rsvd4                         2a                                                            
      *                                                                                             
     D NCLQ0100        DS                  Qualified                                                
     D  NetConnT                     10a   inz('*ALL      ')                                        
     D  LstReqT                      10a   inz('*SUBSET   ')                                        
     D  rsvd                         12a   inz('            ')                                      
     D  LclAddrLow                   10u 0 inz(0)                                                   
     D  LclAddrUpp                   10u 0 inz(0)                                                   
     D  LclPortLow                   10i 0 inz(0)                                                   
     D  LclPortUpp                   10i 0 inz(0)                                                   
     D  RmtAddrLow                   10u 0 inz(0)                                                   
     D  RmtAddrUpp                   10u 0 inz(0)                                                   
     D  RmtPortLow                   10u 0 inz(0)                                                   
     D  RmtPortUpp                   10u 0 inz(0)                                                   
      *                                                                                             
     D pName           S             20a                                                            
     D usPtr           S               *                                                            
      *                                                                                             
     D APIErr          DS                  Qualified                                                
     D  ErrSize                      10i 0 inz(%size(APIErr))                                       
     D  ErrLen                       10i 0 inz(0)                                                   
     D  ErrID                         7a                                                            
     D  rsvd                          1a                                                            
     D  ErrData                   32767a                                                            
      *                                                                                             
     D i               S              5  0                                                          
     D wSECs           S             29p 2                                                          
     D wMINs           S             29p 5                                                          
     D wHOURs          S             29p 5                                                          
     D wDAYs           S             29p 5                                                          
     D status          S             11a                                                            
      *                                                                                             
     D RcvSize         S             10  0 INZ(16776704)                                            
      *                                                                                             
     D HandleErr       PR                                                                           
      *                                                                                             
     D RemoteAddr      s             15a                                                            
     D RemotePort      s              5a                                                            
     D LocalAddr       s             15a                                                            
     D LocalPort       s              5a                                                            
     D IdleMS          s             10p 0                                                          
     D BytesIn         s             10p 0                                                          
     D BytesOut        s             10p 0                                                          
     D OpenType        s             11a                                                            
      *                                                                                             
      /Free                                                                                         
                                                                                                    
              if lAddr = *blank ;                                                                   
                 NCLQ0100.LclAddrLow = 0 ;                                                          
              else ;                                                                                
                 NCLQ0100.LclAddrLow = inet_addr(%trimR(lAddr)) ;                                   
                 NCLQ0100.LclAddrUpp = 0 ; // *only                                                 
              endif ;                                                                               
                                                                                                    
              if lPort = *blanks ;                                                                  
                 NCLQ0100.LclPortLow = 0 ; // all local ports                                       
              else ;                                                                                
                 NCLQ0100.LclPortLow = %INT(lPort) ;                                                
              endif ;                                                                               
                                                                                                    
              // when lower value is 0, all addresses go                                            
              // when upper value is 0, only lower address go                                       
              if rAddrlow = *blank ;                                                                
                 NCLQ0100.RmtAddrLow = 0 ; // all remote addresses                                  
                 NCLQ0100.RmtAddrUpp = 0 ; // *only                                                 
              else ;                                                                                
                 NCLQ0100.RmtAddrLow = inet_addr(%trimR(rAddrlow)) ;                                
                 if rAddrupp = *blank ;                                                             
                    NCLQ0100.RmtAddrUpp = 0 ; // *only                                              
                 else ;                                                                             
                    NCLQ0100.RmtAddrUpp = inet_addr(%trimR(rAddrupp)) ;                             
                 endif ;                                                                            
              endif ;                                                                               
                                                                                                    
              if rPort = *blanks ;                                                                  
                 NCLQ0100.RmtPortLow = 0 ; // all local ports                                       
              else ;                                                                                
                 NCLQ0100.RmtPortLow = %INT(rPort) ;                                                
              endif ;                                                                               
                                                                                                    
              pName =    'GETNETSTATQTEMP     ' ;                                                   
              usPtr = CrtUsrspcP  (pName ) ;                                                        
                                                                                                    
              LstNetCnn ( pName                                                                     
                         :'NCNN0100'                                                                
                         :NCLQ0100                                                                  
                         :%Size( NCLQ0100 )                                                         
                         :'NCLQ0100'                                                                
                         :APIErr ) ;                                                                
                                                                                                    
              if APIErr.ErrLEN <> 0 ;                                                               
                 HandleErr() ;                                                                      
                 return ;                                                                           
              endif ;                                                                               
                                                                                                    
              if GenericHeader.numberList = 0 ;                                                     
                 return ;                                                                           
              endif ;                                                                               
                                                                                                    
              jlPtr = usPtr + GenericHeader.offsetList ;                                            
                                                                                                    
              for i = 1 to GenericHeader.numberList ;                                               
            //   dsply NCNN0100.NetConnT ;                                                          
            //   dsply NCNN0100.LclAddr ;                                                           
            //   dsply NCNN0100.LclPort ;                                                           
            //   dsply NCNN0100.RmtAddr ;                                                           
            //   dsply NCNN0100.RmtPort ;                                                           
                                                                                                    
                 Select ;                                                                           
                    when NCNN0100.TcpState  = 0 ;                                                   
                       Status  = 'Listen     ' ;                                                    
                    when NCNN0100.TcpState  = 1 ;                                                   
                       Status  = 'SYN-sent   ' ;                                                    
                    when NCNN0100.TcpState  = 2 ;                                                   
                       Status  = 'SYN-recived' ;                                                    
                    when NCNN0100.TcpState  = 3 ;                                                   
                       Status  = 'Established' ;                                                    
                    when NCNN0100.TcpState  = 4 ;                                                   
                       Status  = 'FIN-wait-1 ' ;                                                    
                    when NCNN0100.TcpState  = 5 ;                                                   
                       Status  = 'FIN-wait-2 ' ;                                                    
                    when NCNN0100.TcpState  = 6 ;                                                   
                       Status  = 'Close-wait ' ;                                                    
                    when NCNN0100.TcpState  = 7 ;                                                   
                       Status  = 'Closing    ' ;                                                    
                    when NCNN0100.TcpState  = 8 ;                                                   
                       Status  = 'Last-ACK   ' ;                                                    
                    when NCNN0100.TcpState  = 9 ;                                                   
                       Status  = 'Time-wait  ' ;                                                    
                    when NCNN0100.TcpState  = 10 ;                                                  
                       Status  = 'Closed     ' ;                                                    
                    when NCNN0100.TcpState  = 11 ;                                                  
                       Status  = 'Not Support' ;                                                    
                    other ;                                                                         
                       Status  = 'Unknown    ' ;                                                    
                 endsl ;                                                                            
             //  dsply Status ;                                                                     
                                                                                                    
                 Select ;                                                                           
                    when NCNN0100.ConnOpenT = 0 ;                                                   
                       OpenType  = 'Passive    ' ;                                                  
                    when NCNN0100.ConnOpenT = 1 ;                                                   
                       OpenType  = 'Active     ' ;                                                  
                    when NCNN0100.ConnOpenT = 2 ;                                                   
                       OpenType  = 'Not Support' ;                                                  
                    other ;                                                                         
                       OpenType  = 'Unknown    ' ;                                                  
                 endsl ;                                                                            
                                                                                                    
                 RemoteAddr = %trimR(NCNN0100.RmtAddr:x'00') ;                                      
                 RemotePort = %char(NCNN0100.RmtPort) ;                                             
                 LocalAddr = %trimR(NCNN0100.LclAddr:x'00') ;                                       
                 LocalPort = %char(NCNN0100.lCLPort) ;                                              
                 IdleMS    = %dec(NCNN0100.IdleMs) ;                                                
                 BytesIn   = %dec(NCNN0100.BytesIn) ;                                               
                 BytesOut  = %dec(NCNN0100.BytesOut) ;                                              
                                                                                                    
             //  wSECs = NCNN0100.IdleMs/1000 ;                                                     
             //  wMINs = wSECs/60 ;                                                                 
             //  wHOURs = wMINs/60 ;                                                                
             //  wDAYs = wHOURs/60 ;                                                                
                                                                                                    
             //  dsply wSECs ;                                                                      
                                                                                                    
                 RtvNetSQL (NCNN0100.NetConnT                                                       
                          :LocalAddr                                                                
                          :LocalPort                                                                
                          :RemoteAddr                                                               
                          :RemotePort                                                               
                          :count                                                                    
                          ) ;                                                                       
                                                                                                    
                 exec sql                                                                           
                    INSERT INTO NETSQLINF/NETSTAT                                                   
                    VALUES( :count ,                                                                
                            :RemoteAddr ,                                                           
                            :RemotePort ,                                                           
                            :LocalAddr,                                                             
                            :LocalPort,                                                             
                            :Status,                                                                
                            :IdleMS,                                                                
                            :BytesIn,                                                               
                            :BytesOut,                                                              
                            :OpenType,                                                              
                            :NCNN0100.NetConnT,                                                     
                            :NCNN0100.UsrPrf,                                                       
                            CURRENT_TIMESTAMP                                                       
                          ) ;                                                                       
                                                                                                    
                 jlPtr =  jlPtr + GenericHeader.sizeEntry ;                                         
                                                                                                    
              endfor ;                                                                              
                                                                                                    
              *inLR = *on ;                                                                         
              return ;                                                                              
                                                                                                    
      /End-Free                                                                                     
      *                                                                                             
      *                                                                                             
     P HandleErr       B                                                                            
     D HandleErr       PI                                                                           
      *                                                                                             
      /Free                                                                                         
                                                                                                    
      /End-Free                                                                                     
      *                                                                                             
     P HandleErr       E                                                                            

呼び出し用の CL プログラム

System API で NETSTAT 情報の取得 (V5R4)」とほぼ同じです。
やはり CL のループ制御は GOTO が一番”らしい”のではないかと思って、今回は GOTO 版をベースとして採用しています。

/*                                                          */                  
/*   CRTBNDCL PGM(NETSQL/GETNSDATAC)                       */                   
/*            SRCFILE(NETSQL/QCLSRC) DBGVIEW(*SOURCE)   */                      
/*                                                          */                  
                                                                                
             PGM        PARM(&LADDR &LPORT &RADDRLOW &RADDRUPP +                
                          &RPORT &INTERVAL &OPTION &TARGET &ENDTIME)            
                                                                                
             DCL        VAR(&OPTION) TYPE(*CHAR) LEN(6)                         
             DCL        VAR(&TIME) TYPE(*CHAR) LEN(6)                           
             DCL        VAR(&ENDTIME) TYPE(*CHAR) LEN(6)                        
             DCL        VAR(&INTERVAL) TYPE(*DEC) LEN(3 0)                      
             DCL        VAR(&COUNT) TYPE(*DEC) LEN(5 0)                         
             DCL        VAR(&COUNTC) TYPE(*CHAR) LEN(5) VALUE('0')              
             DCL        VAR(&TARGET) TYPE(*DEC) LEN(5 0)                        
             DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)                          
             DCL        VAR(&MSGDTA) TYPE(*CHAR) LEN(64) VALUE(' ')             
             DCL        VAR(&JOBTYPE) TYPE(*CHAR) LEN(1)                        
             DCL        VAR(&LPORT) TYPE(*DEC) LEN(5 0)                         
             DCL        VAR(&LPORTC) TYPE(*CHAR) LEN(5)                         
             DCL        VAR(&RPORT) TYPE(*DEC) LEN(5 0)                         
             DCL        VAR(&RPORTC) TYPE(*CHAR) LEN(5)                         
             DCL        VAR(&LADDR) TYPE(*CHAR) LEN(15)                         
             DCL        VAR(&RADDRLOW) TYPE(*CHAR) LEN(15)                      
             DCL        VAR(&RADDRUPP) TYPE(*CHAR) LEN(15)                      
                                                                                
             DCL        VAR(&I) TYPE(*INT)                                      
                                                                                
             IF         COND(&INTERVAL = 0) THEN(GOTO CMDLBL(EXIT))             
             SELECT                                                             
             WHEN       COND(&OPTION = '*COUNT') THEN(DO)                       
             IF         COND(&TARGET = 0) THEN(GOTO CMDLBL(EXIT))               
             ENDDO                                                              
             WHEN       COND(&OPTION = '*TIME') THEN(DO)                        
             IF         COND(&ENDTIME = '000000') THEN(GOTO +                   
                          CMDLBL(EXIT))                                         
             RTVSYSVAL  SYSVAL(QTIME) RTNVAR(&TIME)                             
             IF         COND(&TIME > &ENDTIME) THEN(GOTO CMDLBL(EXIT))          
             ENDDO                                                              
             ENDSELECT                                                          
             CHGVAR     VAR(&COUNT) VALUE(1)                                    
             RTVJOBA    TYPE(&JOBTYPE)                                          
             IF         COND(&LPORT = 0) THEN(CHGVAR VAR(&LPORTC) +             
                          VALUE(' '))                                           
             ELSE       CMD(CHGVAR VAR(&LPORTC) VALUE(&LPORT))                  
             IF         COND(&RPORT = 0) THEN(CHGVAR VAR(&RPORTC) +             
                          VALUE(' '))                                           
             ELSE       CMD(CHGVAR VAR(&RPORTC) VALUE(&RPORT))                  
 GETDATA:    CALLSUBR   SUBR(TRIMZERO)                                          
          /* SUBR(TRIMZERO) DOES CHGVAR AND            */                       
          /*                REMOVES TRADING ZEROS      */                       
          /* AND CHGVAR     VAR(&COUNTC) VALUE(&COUNT) */                       
             CALL       PGM(NETSQL/GETNETINF) PARM(&LADDR +                
                          &LPORTC &RADDRLOW &RADDRUPP &RPORTC &COUNTC)          
             CHGVAR     VAR(&MSGDTA) VALUE(&COUNTC |< +                         
                          '回目のデータを取得しました')                       
             CHGVAR     VAR(&MSGID) VALUE(CPF9898)                              
             SNDPGMMSG  MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +           
                          TOPGMQ(*EXT) MSGTYPE(*STATUS)                         
             IF         COND(&JOBTYPE = '0') THEN(DO)                           
             SNDPGMMSG  MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +           
                          TOPGMQ(*EXT) MSGTYPE(*INFO)                           
             ENDDO                                                              
             SELECT                                                             
             WHEN       COND(&OPTION = '*COUNT') THEN(DO)                       
             IF         COND(&COUNT = &TARGET) THEN(GOTO CMDLBL(EXIT))          
             ENDDO                                                              
             WHEN       COND(&OPTION = '*TIME') THEN(DO)                        
             RTVSYSVAL  SYSVAL(QTIME) RTNVAR(&TIME)                             
             IF         COND(&TIME > &ENDTIME) THEN(GOTO CMDLBL(EXIT))          
             IF         COND(&TIME = &ENDTIME) THEN(GOTO CMDLBL(EXIT))          
             ENDDO                                                              
             ENDSELECT                                                          
             DLYJOB     DLY(&INTERVAL)                                          
             CHGVAR     VAR(&COUNT) VALUE(&COUNT + 1)                           
             GOTO       CMDLBL(GETDATA)                                         
                                                                                
 EXIT:       CHGVAR     VAR(&MSGDTA) VALUE(&COUNTC |< +                         
                          '件データを取得しました')                           
             CHGVAR     VAR(&MSGID) VALUE(CPF9898)                              
             SNDPGMMSG  MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) +           
                          MSGTYPE(*INFO)                                        
                                                                                
             SUBR       SUBR(TRIMZERO)                                          
             CHGVAR     VAR(&COUNTC) VALUE(&COUNT)                              
             DOFOR      VAR(&I) FROM(1) TO(4) BY(1)                             
             IF         COND(%SST(&COUNTC &I 1) = '0') THEN(CHGVAR +            
                          VAR(%SST(&COUNTC &I 1)) VALUE(' '))                   
             ELSE       CMD(LEAVE)                                              
             ENDDO                                                              
             ENDSUBR                                                            
                                                                                
             ENDPGM                                                             

コマンド

コマンド用のソースです。

     /*                                          */                       
     /*      CRTCMD CMD(NETSQL/GETNETINF)        */                       
     /*             PGM(NETSQL/GETNSDATAC)       */                       
     /*             SRCFILE(NETSQL/QCMDSRC)      */                       
     /*                                          */                       
                                                                          
             CMD        PROMPT('NETSTAT データの取得 ')                   
             PARM       KWD(LCLIPADDR) TYPE(*CHAR) LEN(15) DFT(' ') +     
                          PROMPT(' ローカル IP アドレス ')                
             PARM       KWD(LOCALPORT) TYPE(*DEC) LEN(5 0) DFT(0) +       
                          RANGE(0 99999) PROMPT(' ローカル・ポート ')     
             PARM       KWD(RMTIPADDRL) TYPE(*CHAR) LEN(15) DFT(' ') +    
                          PROMPT(' リモート IP アドレス下限値 ')          
             PARM       KWD(RMTIPADDRU) TYPE(*CHAR) LEN(15) DFT(' ') +    
                          PROMPT(' リモート IP アドレス上限値 ')          
             PARM       KWD(REMOTEPORT) TYPE(*DEC) LEN(5 0) DFT(0) +      
                          RANGE(0 99999) PROMPT(' リモート・ポート ')     
             PARM       KWD(INTERVAL) TYPE(*DEC) LEN(3 0) RANGE(1 +       
                          999) PROMPT(' インターバル ')                   
             PARM       KWD(ENDOPT) TYPE(*CHAR) LEN(6) RSTD(*YES) +     
                          DFT(*COUNT) VALUES(*COUNT *TIME) +            
                          PROMPT(' 終了オプション ')                    
             PARM       KWD(ENDCOUNT) TYPE(*DEC) LEN(5 0) RANGE(1 +     
                          99999) PMTCTL(ENDCOUNTS) PROMPT(' 回数 ')     
             PARM       KWD(ENDTIME) TYPE(*TIME) PMTCTL(ENDTIME) +      
                          PROMPT(' 時間 ')                              
                                                                        
 ENDCOUNTS:  PMTCTL     CTL(ENDOPT) COND((*EQ '*COUNT'))                
 ENDTIME:    PMTCTL     CTL(ENDOPT) COND((*EQ '*TIME'))                 

作成用のコマンドなど

CRTSQLRPGI OBJ(NETSQL/GETNETINF) SRCFILE(NETSQL/QRPGLESRC) COMMIT(*NONE) OBJTYPE(*MODULE) DBGVIEW(*SOURCE)
CRTSQLRPGI OBJ(NETSQL/RTVNETSQL) SRCFILE(NETSQL/QRPGLESRC) COMMIT(*NONE) OBJTYPE(*MODULE) DBGVIEW(*SOURCE)
CRTRPGMOD MODULE(NETSQL/CRTUSRSPCP) SRCFILE(NETSQL/QRPGLESRC) DBGVIEW(*SOURCE)
CRTRPGMOD MODULE(NETSQL/RTVJOBSQL) SRCFILE(NETSQL/QRPGLESRC) DBGVIEW(*SOURCE)
CRTPGM PGM(NETSQL/GETNETINF) MODULE(NETSQL/GETNETINF NETSQL/RTVNETSQL NETSQL/RTVJOBSQL NETSQL/CRTUSRSPCP) ACTGRP(GETNETINF)
CRTBNDCL PGM(NETSQL/GETNSDATAC) SRCFILE(NETSQL/QCLSRC) DFTACTGRP(*NO) ACTGRP(GETNETINF) DBGVIEW(*SOURCE)
CRTCMD CMD(NETSQL/GETNETINF) PGM(NETSQL/GETNSDATAC) SRCFILE(NETSQL/QCMDSRC)

コマンドの実行例

GETNETINF LOCALPORT(8471) RMTIPADDRL('192.168.1.1') RMTIPADDRU('192.168.1.10') INTERVAL(2) ENDCOUNT(3)

[Top Pageに戻る]

Ads by TOK2