Ramesh Polepalli
2007-Mar-23 06:56 UTC
[dtrace-discuss] Output redirection problem of DTrace
Hi, I am using prustat to monitor the DISK, CPU, MEM and NET usage by some specific users. I am using the following command for the purpose. prustat 5 | /usr/xpg4/bin/grep -E ''COMM|java|bash'' When I execute the above command from command line I am getting the output as shown below. root at MFIN-SOL01:scripts1 [561] prustat 5 | /usr/xpg4/bin/grep -E ''COMM|java|bash'' PID %CPU %Mem %Disk %Net COMM 1740 0.06 1.55 0.00 0.00 java 2160 0.53 1.01 0.00 0.00 java 16227 0.03 0.05 0.00 0.00 bash 17297 0.00 0.06 0.00 0.00 bash 17267 0.00 0.05 0.00 0.00 bash 16028 0.00 0.05 0.00 0.00 bash PID %CPU %Mem %Disk %Net COMM 1740 0.07 1.55 0.00 0.00 java 2160 0.40 1.01 0.00 0.00 java 16227 0.02 0.05 0.00 0.00 bash 17297 0.00 0.06 0.00 0.00 bash 17267 0.00 0.05 0.00 0.00 bash 16028 0.00 0.05 0.00 0.00 bash Till this point it is fine. But I am not able to redirect the output to some file. prustat 5 | /usr/xpg4/bin/grep -E ''COMM|java|bash'' > abc.out This command creates a file abc.out but no data will be recorded. It will be of size "0" even after few minutes. Kindly suggest/help me to understand and solve the problem? Thanks in advance for any help. Regards, Ramesh. Ramesh Polepalli mFormation Technologies Inc. Direct Line: +91 80 6620 5939 Switchboard: +91 80 6620 5900 http://www.mformation.com Visit us at CTIA in Orlando, Hall A3, booth 1683, from March 27-29, Orange County Convention Center, Orlando, FL, to find out how MFORMATION can help you -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20070323/091f1bd9/attachment.html>
Richard L. Hamilton
2007-Mar-23 09:25 UTC
[dtrace-discuss] Re: Output redirection problem of DTrace
Looks like egrep buffers when its stdout is not a terminal; and by more than the usual amount. The same thing happens if you pipe the output of egrep to cat; and also if you use sed or awk instead of egrep. If you have such programs, you might be able to make it think it''s talking to a terminal and thus not buffer by running it under "expect", "screen", or the like. I don''t know how to use those off the top of my head, so I can''t help you do that. This message posted from opensolaris.org
Brendan Gregg - Sun Microsystems
2007-Mar-23 17:01 UTC
[dtrace-discuss] Output redirection problem of DTrace
G''Day Ramesh, On Fri, Mar 23, 2007 at 12:26:11PM +0530, Ramesh Polepalli wrote:> Hi, > > > > I am using prustat to monitor the DISK, CPU, MEM and NET usage by some > specific users. > > I am using the following command for the purpose. > > > > prustat 5 | /usr/xpg4/bin/grep -E ''COMM|java|bash''If you are interested in usage by particular processes or users, it would be best to write your own custom DTrace script - rather than grepping the output from one. Brendan -- Brendan [CA, USA]