Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2011
    Posts
    3

    Unanswered: Shell script help

    Hi Friends,

    I am composing small script to find an agentid of the Runstats job.

    DB2_DATABASE is an environment variable, so the snapshot part work fine. but am not getting agent which is active from Runstats point of view.

    Please help me.


    rm -f /tmp/.d_agent
    db2 get snapshot for applications on $DB2_DATABASE | egrep 'Application handle|Most recent operation|Statement' | while read AGENT
    do
    read OPERATION
    AGENTI_ID=$(echo ${AGENT} | awk -F\= '{print $2}')
    TYPE=$(echo ${OPERATION} | awk -F\= '{print $2}'
    if [[ "${TYPE}" = "Run statistics" ]]; then
    if [[ $? = 0 ]]; then
    if echo ${AGENTI_ID} | grep "^[0-9]*$" ; then
    if [[ $? = 0 ]]; then
    echo ${AGENTI_ID} >> /tmp/.d_agent
    else
    print "It is not an agent"
    fi
    fi
    fi
    fi
    done
    Last edited by trainee_unix; 07-29-11 at 13:13.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    I doubt that echo ${AGENTI_ID} | grep "^[0-9]*$" will ever return anything.
    Last edited by n_i; 07-29-11 at 14:28. Reason: And it does not have anything to do with DB2

  3. #3
    Join Date
    Jul 2011
    Posts
    3

    Shell script help

    Thanks for the replay.

    It is returning the agent_id when I limited the snapshot to only Runstats agent, but when I took the snapshot on DB level, it is not retuning.

    Regarding below. My intention was to chase only integer number.

    echo ${AGENTI_ID} | grep "^[0-9]*$"

    Please advise if you have any workaround for that.

    Thanks.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    The workaround would be to use a correct regex. Look at what's in ${AGENTI_ID}.

  5. #5
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    if you are on DB2 V9.1, 9.5,9.7 you can simply write a sql query on sysibmadm view for applications for the required fields, say application_name & agentid where you don't need to do any further filtering or formatting.

    Jayanta Datta
    DB2 UDB DBA
    IBM India, Global Delivery
    New Delhi

  6. #6
    Join Date
    Jul 2011
    Posts
    3

    Shell script help

    Thanks for the response.

    I did take a look on all admin views, But did not find any admin view will pull the Agenti_id and utility/application as Runstats.

    Please advise if I miss anything.

  7. #7
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    you can try combination of system adm views of application and utilities to get the info.

    Jayanta Datta
    DB2 UDB DBA
    IBM India, Global Delivery
    New Delhi

Posting Permissions

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