Please help with Top and SIZE of process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help with Top and SIZE of process
# 1  
Old 06-24-2005
Question Please help with Top and SIZE of process

Hi, what I want to do is get the SIZE of a particular process from top into a shell script so I can put it in a while loop. I want to display a warning message when the process size gets up to a certain amount, but I don't know how to get that one line spit out from Top and thrown into my shell script. I tried ps -ey but it says it doesn't support the "y". I tried ps -el but the SZ I get back does not match what the TOP command says for SIZE.
Can anybody help? Thanks so much
Amy
# 2  
Old 06-24-2005
MySQL

Try this

top -b > $filename
grep -i $process_name $filename | awk '{print $6 }'

jus see if u get right column...
# 3  
Old 06-24-2005
Thanks RishiPahuja, but when I try top -b it says "top: illegal option --b"
I am on an HP UX machine using a ksh
uname -a shows HP-UX b.11.11

Thanks for your help, any other suggestions? I thought maybe top -d 1 > /tmp/file, then cat /tmp/file | grep process_name | awk but that seems like it takes too long.
# 4  
Old 06-24-2005
Code:
NAME=blah #assume only 1 of these?
THRES=1234 #KB

while true; do
    SIZE=`ps -C $NAME -o rss=`
    if [ "$SIZE" -gt "$THRES" ]; then
        echo "Warning: $NAME is using more that $THRES RAM"
    fi
done

# 5  
Old 06-24-2005
try top -f. This will write the output of top to a file. You can get the content from file and process it later
# 6  
Old 06-24-2005
Thanks so much SSSOW and Pixelbeat and Rish....

I ended up using top -f and output to file. Then grepped and awked at the file until I got what I wanted.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Kill top 5 memory uses process

Hi All, how to kill 5 top memory used process in my hp-ux. Thanks, Kki (9 Replies)
Discussion started by: kki
9 Replies

2. Shell Programming and Scripting

Script to Monitor a Process with Top.

Hi, I have written a script to monitor a Process with the help of top command. This is my script. ====================== #!/bin/sh DATE=`date +%Y%m%d%H%M%S` HOME=/home/xmp/testing/xmp_report RADIUS_PID=`xms -xmp sh pr | grep "RADIUS.iamsp02ldv" |awk '{ print $3 }'` PSE_PID=`xms -xmp sh... (5 Replies)
Discussion started by: Siddheshk
5 Replies

3. Solaris

Programatically read 'size' shown in top?

How can the 'size' of a process, that is shown by 'top', be read programatically? I'm fixing a memory leak in a large (20,000 lines) program. (The main.cpp is itself 7400 lines!). (3 Replies)
Discussion started by: douglaskbell
3 Replies

4. Shell Programming and Scripting

Display top ten directories by size

Hi, I am new to Unix. I want to display top 10 folders by size. I tried with du -ksl * | sort -nr | head -10 command .But I am getting the following error -bash: /usr/bin/du: Argument list too long Can some one help me. Thanks. (5 Replies)
Discussion started by: Satyak
5 Replies

5. HP-UX

Shortlived Process Don't Appear in 'top' or 'ps'

We are running a field specific middle tier application server on HP-UX. We've recently been experiencing performance problems with it and the database back end (Oracle on a separate HP-UX box). We resolved a few issues on the DB server (some kernel parameters to free up RAM that was extremely... (5 Replies)
Discussion started by: deckard
5 Replies

6. UNIX for Advanced & Expert Users

to understand stopped process in top

Hi, top process is shows like this in solaris server oracle 8i running: load averages: 5.01, 3.35, 2.82 18:24:45 344 processes: 332 sleeping, 5 running, 2 stopped, 5 on cpu CPU states: 22.2% idle, 29.6% user, 14.7% kernel, 33.5% iowait, 0.0% swap... (3 Replies)
Discussion started by: prakash.gr
3 Replies

7. UNIX for Dummies Questions & Answers

Unix shell script for finding top ten files of maximum size

I need to write a Unix shell script which will list top 10 files in a directory tree on basis of size. i.e. first file should be the biggest in the whole directory and all its sub directories. Please suggest any ideas (10 Replies)
Discussion started by: abhilashnair
10 Replies

8. UNIX for Advanced & Expert Users

Top running process

Hi, I have an oracle process running on top for a week now, but I couldnt see the same process with in oracle. how do I know what this process is? -GK P.S: when I say i didn't see within oracle, what I mean is I didn't see this process through oracle utility which shows all the oracle process (1 Reply)
Discussion started by: caprikar
1 Replies

9. UNIX for Dummies Questions & Answers

top shows stopped process

When I run the top command, it shows 1 process as being Stopped. This is not a zombie, but simply a stopped process. Unfortunately, I can't figure out how to tell which process this is, nor why it is in a stopped state? Any way of finding this out? (7 Replies)
Discussion started by: IrishRogue
7 Replies
Login or Register to Ask a Question