On Thursday, May 30, 2002, at 09:44 AM, bob ackerman wrote:
>
> On Thursday, May 30, 2002, at 07:31 AM, Sudarsan Raghavan wrote:
>
>> "Kipp, James" wrote:
>>
>>> I am reading output from a pipe to a command called 'prstat' (like top)
>>> .
>>> just wanted to get some ideas on the best way to capture the data i am
>>> looking for. below is an example of the output:
>>
>> # INPUTDATA is the filehandle through which you are getting the input
>> while (<INPUTDATA>) {
>> chomp;
>> s/^\s+//;
>> next if (m/^$/ || (1 .. /^NPROC/));
>
> what does the range thing do?
> wouldn't just ... || /^NPROC/ be enough?
ok. opposite sense: || ! /^NPROC/
>
>> unless (/^Total/) {
>> # Assumes the line to stop searching for input starts with Total
>> my ($user, $mem, $cpu) = (split (/\s+/))[1, 4, 6];
>> print "user = $user, mem = $mem, cpu = $cpu\n";
>> }
>> }
>> close (INPUTDATA);
>>
>>>
>>> --
>>> PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
>>>
>>> 13261 prago 5728K 5240K cpu49 0 0 0:40.04 9.4% cfprsdrv/1
>>> 20318 oracle 519M 496M cpu46 0 0 35:47.20 3.2% oracle/1
>>> 12924 prago 1720K 1056K sleep 1 0 0:06.55 1.6% zcat/1
>>> 21244 oracle 514M 494M sleep 0 0 0:00.01 0.3% oracle/1
>>> 21107 oracle 526M 507M sleep 0 0 0:00.13 0.3% oracle/1
>>> 13310 prago 392M 101M sleep 59 0 0:01.07 0.2% syncsort/1
>>> NPROC USERNAME SIZE RSS MEMORY TIME CPU
>>>
>>> 17 prago 1596M 394M 2.9% 0:48.54 11%
>>> 47 oracle 13G 12G 91% 38:17.25 4.1%
>>> 5 patrol 36M 23M 0.2% 10:53.17 0.2%
>>> 11 dbmsys 52M 20M 0.1% 0:00.53 0.1%
>>> 53 root 173M 113M 0.8% 5:32.40 0.1%
>>> Total: 208 processes, 875 lwps, load averages: 2.03, 2.04, 2.12
>>> --
>>>
>>> I want to capture some fields after the line starting with NPROC. the
>>> problem is as you can see is the output columns change format after this
>>> line. I want to capture the USERNAME MEMORY and CPU.
>>> any ideas?
>>>
>>> thanks
>>> jim
>>>
>>> --
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> --
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
> -- To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]