Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011
    Posts
    5

    Unanswered: Db2 long running query monitoring script

    Hi All,

    Can any one please provide me with a sample of a shell/bash script that monitors the db2 long running sql and send an email if any found,

    I am using the following to get the long running queries:

    SELECT ELAPSED_TIME_MIN,SUBSTR(AUTHID,1,10) AS AUTH_ID, AGENT_ID,APPL_STATUS,STMT_TEXT AS SQL_TEXT FROM SYSIBMADM.LONG_RUNNING_SQL WHERE ELAPSED_TIME_MIN > 0 ORDER BY ELAPSED_TIME_MIN DESC

  2. #2
    Join Date
    Mar 2003
    Posts
    280
    Quote Originally Posted by comerun View Post
    Hi All,

    Can any one please provide me with a sample of a shell/bash script that monitors the db2 long running sql and send an email if any found,

    I am using the following to get the long running queries:

    SELECT ELAPSED_TIME_MIN,SUBSTR(AUTHID,1,10) AS AUTH_ID, AGENT_ID,APPL_STATUS,STMT_TEXT AS SQL_TEXT FROM SYSIBMADM.LONG_RUNNING_SQL WHERE ELAPSED_TIME_MIN > 0 ORDER BY ELAPSED_TIME_MIN DESC
    Code:
    db2 "SELECT ELAPSED_TIME_MIN,SUBSTR(AUTHID,1,10) AS AUTH_ID ..."
    if [ $? -eq 0 ]; then
        # rows found, send mail...
    
    fi
    --
    Lennart

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •