ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Monitor Inactivity for a program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Monitor Inactivity for a program

    I need a program or something that can monitor how long a user is sitting in a program with NO inactivity. Lets say a user is sitting in order mod for 30 minutes.. I would like something monitoring that program and then doing something to that session etc..

    Anyone have something like that and would like to share or steer me in the right direction?

    Thanks

  • #2
    Re: Monitor Inactivity for a program

    Hi CaptinRon:

    If you are talking about a system wide....all user approach....look at the following:


    If you are talking about a specific interactive program....

    Code:
    FMYSCREEN  CF   E             WORKSTN                                                             
    F                                     MAXDEV(*FILE)
    F                                     INFDS(INFWS) 
    D INFWS           DS                 
    D  STAT                  11     15  0
    C                   WRITE     SCREEN5                                  
    C                   READ      MYSCREEN                             8480
    C     *IN84         IFEQ      *ON                                      
    C     STAT          ANDEQ     1331                                     
    C                   EXSR       tattletale
    C                   MOVE      *ON           *INLR                      
    C                   UNLOCK    MYFILE                                 
    C                   UNLOCK    MYFILE2                                 
    C                   UNLOCK    MYFILE3
    C                   END
    When you compile your screen pay particular attention to the following values:
    Maximum file wait time . . . . . *IMMED
    Maximum record wait time . . . . *NOMAX
    These values can be modified using OVRDSPF in CL.

    Note I am using write and read to the screen not exfmt.

    Sorry this is old code but i don't have anything using free.

    Best of Luck
    GLS
    Last edited by GLS400; June 9, 2014, 12:23 PM.
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: Monitor Inactivity for a program

      So I cannot use this with an EXFMT? If I set those parms it will wait for a specific number of seconds and then do what? Just trying to make sure this is what I want to do.. I can run some test later..

      Thanks

      Comment


      • #4
        Re: Monitor Inactivity for a program

        Originally posted by CaptainRon
        I need a program or something that can monitor how long a user is sitting in a program with NO inactivity. Lets say a user is sitting in order mod for 30 minutes.. I would like something monitoring that program and then doing something to that session etc..

        Anyone have something like that and would like to share or steer me in the right direction?

        Thanks
        Set the system value QINACTITV to 30, QINACTMSGQ can be set to do 1 of three things - Disconnect the job (*DSCJOB), End the job (*ENDJOB) or send a message to a message queue (you specify the message queue). The latter you write a program that monitors the message queue and that program decides on what action to take on that particular job.

        Comment


        • #5
          Re: Monitor Inactivity for a program

          Sorry CaptainRon...Those brain cells have been replaced by Captain Morgan (sorry couldn't resist)
          But it has been a long time since I used that technique.
          My memory is that yes you should replace exfmt with write/read.

          and then do what?
          You can do anything you can code....
          send a message/email
          seton lr and return
          unlock any locked files and call the inqury program
          message his boss that he has been on break too long
          send an electrical charge to his seat (oh that one is from the future)

          When I used that technique the same program was inquiry/maintenance depending on a parm....I changed the parm to inquiry and returned to the display part of the program. The inquiry part un-locked all files so I didn't care if the user spent the rest of the day looking at that screen.

          Best of Luck
          GLS
          Last edited by GLS400; June 9, 2014, 01:21 PM.
          The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

          Comment


          • #6
            Re: Monitor Inactivity for a program

            Set the system value QINACTITV to 30, QINACTMSGQ can be set to do 1 of three things - Disconnect the job (*DSCJOB), End the job (*ENDJOB) or send a message to a message queue (you specify the message queue). The latter you write a program that monitors the message queue and that program decides on what action to take on that particular job.
            Does this above do it to all programs or can I sent the ones I want?

            Comment


            • #7
              Re: Monitor Inactivity for a program

              its a system wide. You can NOT pick and chose.
              Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

              Comment


              • #8
                Re: Monitor Inactivity for a program

                Originally posted by CaptainRon View Post
                Does this above do it to all programs or can I sent the ones I want?
                It does it for all.

                However, it can send a notification that some job has been inactive. The notice tells you which job it is, so you would have programming that receives notices and retrieves info about the job. Your programming could then determine if it's a job or a user that it should do something about. That choice would be something you'd need to set up regardless of the method that was used.

                There are various details you'll need to understand if this sounds useful.
                Tom

                There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                Comment


                • #9
                  Re: Monitor Inactivity for a program

                  However, it can send a notification that some job has been inactive. The notice tells you which job it is, so you would have programming that receives notices and retrieves info about the job. Your programming could then determine if it's a job or a user that it should do something about. That choice would be something you'd need to set up regardless of the method that was used.

                  There are various details you'll need to understand if this sounds useful.
                  I think this will work.. What parts do I need to understand more? I don't need to code the message that is sent or can I? I assume it puts the program that caused the timeout etc.. I think I will need to create a test program and play around with it.. All this is very helpful. Thank you all for helping me out. Its something I have not had to do yet and always thought about. Now its becoming something I need to do.. Users just are not behaving...lol
                  Thanks again for all your help...

                  Comment


                  • #10
                    Re: Monitor Inactivity for a program

                    Create a msgq - specify that msgq in QINACTMSGQ system value. Write a CL program that uses command RCVMSG. The variable you specify for MSGDTA has the values you're interested in - positions 1-10 is the device name, 11-20 is the user name, 21-26 is the job number. You can either ignore it - or use DSCJOB command to disconnect it, ENDJOB to end it, SNDBRKMSG to send a message or whatever is deemed necessary. Have this job run in a loop, always monitoring the msgq and submit it to batch.

                    Comment


                    • #11
                      Re: Monitor Inactivity for a program

                      A specific thing to understand about the system's QINACTITV and QINACTMSGQ process is that the interval that you put into QINACTITV is not exactly the limit that a job can be inactive. It actually sets the interval between times that the system will check for inactive jobs, and all jobs are checked at the same time.

                      There is an implication from that that causes confusion at times.

                      Say you have 100 interactive jobs and QINACTITV is set for 30 minutes. Also, say that the first time the system makes its check is at 1:35 PM. The first check finds no inactive jobs, so the process goes to sleep for 30 minutes. Then, at 1:45 PM, job #1 goes inactive. At 2:05 PM, the system checks all jobs again.

                      In that second check, no jobs have been inactive for 30 minutes, so no notifications are sent. Job #1 has only been inactive for 20 minutes, so it doesn't meet the criteria yet. If the job remains inactive, it will be caught at the third check. When that happens, total inactive time will be 50 minutes.

                      In short, if you set QINACTITV for N minutes, it's technically possible a job to be inactive for as many as approx (2N-1) minutes. That's simply the way it works. That's often not a big problem, but only you can decide if it's okay. If you're interested in catching inactive jobs in some reasonable time and you don't need exactly precise intervals, then you shouldn't have much trouble using this process.
                      Tom

                      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                      Comment


                      • #12
                        Re: Monitor Inactivity for a program

                        Originally posted by tomliotta View Post
                        A specific thing to understand about the system's QINACTITV and QINACTMSGQ process is that the interval that you put into QINACTITV is not exactly the limit that a job can be inactive. It actually sets the interval between times that the system will check for inactive jobs, and all jobs are checked at the same time.

                        There is an implication from that that causes confusion at times.

                        Say you have 100 interactive jobs and QINACTITV is set for 30 minutes. Also, say that the first time the system makes its check is at 1:35 PM. The first check finds no inactive jobs, so the process goes to sleep for 30 minutes. Then, at 1:45 PM, job #1 goes inactive. At 2:05 PM, the system checks all jobs again.

                        In that second check, no jobs have been inactive for 30 minutes, so no notifications are sent. Job #1 has only been inactive for 20 minutes, so it doesn't meet the criteria yet. If the job remains inactive, it will be caught at the third check. When that happens, total inactive time will be 50 minutes.

                        In short, if you set QINACTITV for N minutes, it's technically possible a job to be inactive for as many as approx (2N-1) minutes. That's simply the way it works. That's often not a big problem, but only you can decide if it's okay. If you're interested in catching inactive jobs in some reasonable time and you don't need exactly precise intervals, then you shouldn't have much trouble using this process.
                        If that was the case, then I suppose you could set the inactive timer to a shorter duration and have the backend message queue monitor track the total amount of inactive time that is allowed. (ie: If you want to monitor for 30 minutes of inactivity, set the inactive timer to 5 minutes, then the monitor program flags the job as inactive after 6 successive inactive reports. )
                        Michael Catalani
                        IS Director, eCommerce & Web Development
                        Acceptance Insurance Corporation
                        www.AcceptanceInsurance.com
                        www.ProvatoSys.com

                        Comment


                        • #13
                          Re: Monitor Inactivity for a program

                          Originally posted by tomliotta View Post
                          A specific thing to understand about the system's QINACTITV and QINACTMSGQ process is that the interval that you put into QINACTITV is not exactly the limit that a job can be inactive. It actually sets the interval between times that the system will check for inactive jobs, and all jobs are checked at the same time.
                          FYI, IBM released PTF SI46398 for v7.1 (has been superceded since) to address this issue. Sadly I have not seen a PTF for any other release.
                          Depending on the value of QINACTITV, it will check inactive jobs every 10 mins instead.

                          Comment


                          • #14
                            Re: Monitor Inactivity for a program

                            Originally posted by john.sev99 View Post
                            FYI, IBM released PTF SI46398 for v7.1 (has been superceded since) to address this issue.
                            Good thing to know. Thanks!

                            The PTF and one or two related ones look like steps in the right direction. A few experiments should clarify some of the newly documented behaviors that seem less clear, but it all seems reasonable at first look.
                            Tom

                            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                            Comment

                            Working...
                            X