somewhat unusual top output problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers somewhat unusual top output problem
# 1  
Old 07-15-2004
Question somewhat unusual top output problem

i'm a relative newbie to unix (i'm on OSX) and i have a specific problem i'm tripped up on:

i'm piping the output of top (in log format) into an awk command which formats the information (and eventually will send it out continuously via udp/osc to another app). my problem is with what comes up in the terminal when i try running top -l1000 | awk -f filterfile. the samples pop up two at a time! i need for them to be at relatively constant intervals for this application. does anyone know why this might be happening? i've included my (simple and kludgy) awk file below. thanks in advance for any help.


----

$1 !~ /Processes:|Load|SharedLibs:|MemRegions:|PhysMem:|VM:|PID/ && $2 !~ /Window|AOL|awk|top|tcsh|login|lookupd|AppleSpell|iChatAgent|UniversalA|SystemUISe|pbs|DirectoryS|log inwindo|NortonMiss|cron|cupsd|inetd|automount|nfsiod|coreservic|netinfod|crashrepor|mDNSRespon|syslo gd|autodiskmo|NortonAuto|ATSServer|SecuritySe|configd|dynamic_pa|update|kextd|mach_init|init|kernel_ tas|fix_prebin|Norton|NortonMiss|SecurityAg|SETI@home_|SETI@homeI|S@hScreenS|System|CPU|Internet|DVD |Audio|Echo24|SuperColli|scsynth|MaxMSP|MIDIServer|Image|Key|Burning|Sloppy|Adobe/ { print $2, $3, $5, $6, $7 }
$2 ~ /Window|AOL/ { print $2$3, $4, $6, $7, $8 }
$2 ~ /MaxMSP/ { print $2, $4, $6, $7, $8 }
$2 ~ /Norton|Image|System|CPU|Internet|DVD|Audio|Echo24|Key|Burning|Sloppy|Adobe/ && $3 ~ /Caps|Ant|Pre|Capt|Monito|E|Player|Hija|Con|Mo|Sok|Phot/ { print $2$3, $4, $6, $7, $8 }
# 2  
Old 07-15-2004
A reasonable guess would be buffering. A program like top may change its buffering stragety based on the output file. I don'y use OSX. Does your cat command have -u? If so try

top -l1000 | cat -u

I'll bet you get a similiar result.
# 3  
Old 07-15-2004
my cat does have -u but it's doin some odd things here. really doesn't change the way anything looks.

"top -l4 -s1" posts 1 sample a second.

"top -l4 -s1 | cat -u" posts 2 samples every 2 seconds.

"top -l4 -s1 | awk -f myfile" still posts 2 samples every 2 seconds.

oddly enough, adding cat -u to the end of my command causes it to wait until all of the samples have gone through before it posts anything. so "top -l4 -s1 | awk -f myfile | cat -u" waits four seconds and then posts all four samples at once.

it's interesting to see these differences. a little frustrating too, but interesting. =) could this be some buffering in the pipe?
# 4  
Old 07-16-2004
The point of trying the "cat -u" instead of your awk script was to show that it's not the awk script. The top command is buffering the output.
# 5  
Old 07-17-2004
i wound up making a script that just loops the command for each sample. works well enough.

thanks for your help!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unusual output of sed

i have a sed command that is looking for the workds OK, WARNING and CRITICAL and add html color to those words. e.g: echo $CONSUMABLE |$SED s/OK./\<span\ style\=\"background-color\:green\;font-weight\:bold\;\"\>OK\<\\\/span\>/g the output breaks every so often and changes my output as... (10 Replies)
Discussion started by: adispi
10 Replies

2. UNIX for Dummies Questions & Answers

unusual problem with cp command

I have made a simple script to zip a file then first copy it to a specific directory using cp command then move it to another directory. Files are getting generated at regular intervals in the dir. /one/two/three/four/. I have entry of my script in cron to run after every 2 min. #!/bin/sh... (9 Replies)
Discussion started by: Devesh5683
9 Replies

3. Solaris

top output and swap -s output are differing

Solaris experts, Am struggling, and wondering for the past more than one week that, how to calculate the total available and used memory/swap space. Finally installed and used top & got some understanding, but while cross-checking, there are mismatches. Main Memory top o/p - 2GB... (7 Replies)
Discussion started by: thegeek
7 Replies

4. Shell Programming and Scripting

Understanding the output of TOP

ok, so I have a script im running on a linux box that uses "egrep" a lot. now, when i run this script, i check the TOP to see how much system resource it is using. the "top" command gives the following output: last pid: 25384; load avg: 1.06, 1.04, 0.76; up 351+06:30:24 ... (0 Replies)
Discussion started by: SkySmart
0 Replies

5. Shell Programming and Scripting

Unusual Problem

what is wrong with the below script: --------------------------------------------------------------------------------- #!/bin/bash echo "Setting JrePath..." grep -w "export JrePath" /etc/profile Export_Status=$? if echo "JrePath declared" elif echo "JrePath not declared" echo... (4 Replies)
Discussion started by: proactiveaditya
4 Replies

6. Shell Programming and Scripting

top output for six processes with the same name, output changed from column to row

Hi, I have a system under test, and I use a script that does a ps. The output, is in the following format, it's basically the timestamp, followed by the rss and vsize. 09:03:57 68404 183656 68312 181944 69860 217360 67536 182564 69072 183172 69032 199276 09:04:27 68752 183292 70000 189020... (5 Replies)
Discussion started by: Bloke
5 Replies

7. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

8. UNIX for Advanced & Expert Users

Unusual NFS mount problem on only ONE client: Red Hat WS Rel 3

This is an unusual situation where I have an NFS server currently serving out MULTIPLE clients over several variants of Linux and UNIX successfully (world permissions) except for a SINGLE client. Even the other Linux (SuSE) clients in the same room are mounting successfully with defaults without... (6 Replies)
Discussion started by: neelpert1
6 Replies

9. UNIX for Advanced & Expert Users

top output

Hi all, below is the output of my 'top' Tasks: 91 total, 2 running, 89 sleeping, 0 stopped, 0 zombie Cpu(s): 3.9% us, 20.5% sy, 0.0% ni, 75.6% id, 0.0% wa, 0.0% hi, 0.0% si Can someone tell me what does us, sy,ni,id,wa,hi,si stands stand for? (4 Replies)
Discussion started by: new2ss
4 Replies

10. Solaris

pleaseee help with unusual crontab problem

Helllo folks... I tryed to edit crontab and I have this problem when I do crontab -l it shows my crontab correctly and if I do crontab -e I get this. baafh-99.03# baafh-99.03# crontab -e 1063 ? ? ? ? ? and that is all ...:( I have to type "q" and hit enter and I am back... (4 Replies)
Discussion started by: amon
4 Replies
Login or Register to Ask a Question