Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process question

Status
Not open for further replies.

nyck

Technical User
Mar 10, 2004
447
GB
One of my AIX5.2 servers keeps on running out of swap, this is probably due to a stray process. What is the best way to identify this process?
 
Use the following script

run ps vg > ps_vg.before

wait 1 hour

run ps vg > ps_vg.after

then run the following post_vg.sh script

(Bet it's Java related btw)

Code:
#!/bin/ksh 
#
#
# Correlate ps.before and ps.after data .. 
#
#   command output from ps vg 
#
ONE_FILE=temp_ps_vg

print_help() {

        print  "Usage: post_vg.sh [single_file|before_ps after_ps]"
        print  "       Post process ps vg output "
        print  "       "
        print  "       where, "
        print  "       single_file contains a before and after snapshot"
        print  "       "
        print  "       No files specified - assume"
        print  "       ==> ps_vg.before "
        print  "       ==> ps_vg.after "
        exit -1 


}

main() {

        if [[ $1 == "-?" ]]
        then
                print_help 
                exit -1 
        fi

        if [[ $# == 2 ]] 
        then
                cat $1 $2 > $ONE_FILE

        elif [[ $# == 1 ]]
        then
                cat $1 > $ONE_FILE

        else 
                cat ps_vg.before ps_vg.after > $ONE_FILE

        fi

        post_vg

        rm $ONE_FILE


}

post_vg() {


cat $ONE_FILE | awk 'BEGIN {

        list_label = "None"

}

/PID/ { 

        if( list_label == "None" ) 
                list_label = "Before" 
        else 
                list_label = "After" 

        next
}

{

        pid_list[$1]
        pid_size[$1, list_label ] = $6 
}

END {


        printf("pid\tBefore Size\tAfter Size\t     Delta\n")
        printf("-------\t-----------\t----------\t----------\n")

        for( pid in pid_list ) {

                if( (pid,"Before") in pid_size && (pid,"After") in pid_size ) {

                        delta = pid_size[pid, "After"] - pid_size[pid, "Before"] 
                        d_total += delta 

                        printf("%s\t%11d\t%10d\t%10d\n", \
                                                        pid, \
                                                        pid_size[pid, "Before"], \
                                                        pid_size[pid, "After"], \
                                                        delta  )

                }

        }

        printf("*** Total Delta %d\n", d_total) 


}'

}

main $@

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top