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 > Informix > Long running Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-20-07, 09:37
sunindia sunindia is offline
Registered User
 
Join Date: Oct 2006
Posts: 15
Long running Query

All-

I am trying to find out a long running job on the database .
But as i am new to informix , i need some help in tracting that thread.

Can some one help about waht commands i should use to find out a long running job .


thanks
Reply With Quote
  #2 (permalink)  
Old 03-27-07, 10:16
Tyveleyn Tyveleyn is offline
Registered User
 
Join Date: Aug 2006
Location: The Netherlands
Posts: 248
Hi,

Is your server UNIX based? Then here's a script I once made to check out the currently most consuming sessions in IDS.
Code:
#!/bin/bash                                                                    
                                                                               
w | sed -n '1p'                                                                
echo                                                                           
onstat -u|awk '                                                                
BEGIN   {                                                                      
            file = substr(ARGV[1], index(ARGV[1], "=")+1)                      
            file = file "/" substr(ARGV[2], index(ARGV[1], "=")+1) ".hlp"      
            while(getline prev[++j] < file > 0) {}
        }                                                                      
NR==2   {printf("%s\n", substr($0, 1, (i = index($0, "days")) > 0 ? i+3 : 80))}
NR==3   {for(i = 0; i < 80; i++) printf("%c", "=")}                            
NR==5   {printf("%s\n", $0)}                                                   
        {                                                                      
            if (NR > 5 && NF > 9)                                              
            {                                                                  
                line[++y] = $1 " " $3 " " $9 " " $10                             
                for(i = 1; i <= j; i++)                                        
                    if(line[y] == prev[i])                                     
                        break                                                  
                    else if(i == j)                                             
                        print $0                                           
                    else                                                   
                        continue                                           
            }                                                                  
        }                                                                      
END     {                                                                      
            for(i = 1; i <= y; i++)                                            
                print line[i] > file                                           
            print                                                              
        }' v=$HOME f=`basename $0`
It makes use of the Informix utility 'onstat -u' to monitor the active usersessions in the database and displays a list of active sessions that were not existing the previous time the script was run or whose nreads or nwrites have changed since then. It stores a helpfile in the users $HOME for comparisson of the active sessions with the one's in the next run and it's designed for use with IDS 7.x / 9.x under Linux. A few alterations might be needed for use with other UNIX flavours.
With the 'sessid' number in the third column of the output you can further investigate a particular session with e.g. 'onstat -g ses sessid' or 'onstat -g sql sessid'.

Last edited by Tyveleyn; 03-27-07 at 18:02.
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