If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Shell script help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-29-11, 12:05
trainee_unix trainee_unix is offline
Registered User
 
Join Date: Jul 2011
Posts: 3
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 12:13.
Reply With Quote
  #2 (permalink)  
Old 07-29-11, 13:27
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I doubt that echo ${AGENTI_ID} | grep "^[0-9]*$" will ever return anything.

Last edited by n_i; 07-29-11 at 13:28. Reason: And it does not have anything to do with DB2
Reply With Quote
  #3 (permalink)  
Old 07-29-11, 15:28
trainee_unix trainee_unix is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 07-29-11, 15:43
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
The workaround would be to use a correct regex. Look at what's in ${AGENTI_ID}.
Reply With Quote
  #5 (permalink)  
Old 07-29-11, 17:00
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
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
Reply With Quote
  #6 (permalink)  
Old 07-29-11, 17:42
trainee_unix trainee_unix is offline
Registered User
 
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.
Reply With Quote
  #7 (permalink)  
Old 07-30-11, 04:51
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On