Pb with % of CPU with options 'ug' and '-o pcpu' of ps command - Aix
This is a discussion on Pb with % of CPU with options 'ug' and '-o pcpu' of ps command - Aix ; Hi,
I'm writing a shell to spot the *current* worst CPU
percentage running on my server, but when I run 'ps'
commands and sort the output I've noticed I get values
greater than 100:
$ ps -e -o user= -o ...
-
Pb with % of CPU with options 'ug' and '-o pcpu' of ps command
Hi,
I'm writing a shell to spot the *current* worst CPU
percentage running on my server, but when I run 'ps'
commands and sort the output I've noticed I get values
greater than 100:
$ ps -e -o user= -o pid= -o pcpu= -o vsz= -o rss= -o s= -o time= -o
args= |sort -r -n +2
oracle 1503300 311004.1 22508 18460 Jul 13 84286931-15:48:10 /
local/user/pg ...
oracle 1859740 23788.8 18168 41192 May 11 84286931-10:11:47
ora_lck0_sid
oracle 1757314 23788.8 18232 39908 May 11 84286931-13:03:50
ora_lmon_sid
$ ps ug|sort -r -n +2|head -8
oracle 1503300 310413.2 1.0 24288 18448 - A Jul 13
-31227311:-26 /local/user/pg ...
oracle 1859740 23785.3 1.0 104648 41140 - A May 11
-31227648:-29 ora_lck0_sid
oracle 1773668 [...]
It seems that the %CPU is above 100 when the process's
been running for days or weeks.
Is there a way to tell the 'ps' to retain PID's that
have been running SINCE TODAY only ?
(if I do a 'grep' on 'Jul 19' I'll miss all lines looking
like
$ oracle 978970 0.0 2.0 95104 46324 - A 14:46:18 0:00
ora_j000_
i.e. lines containing only the hour/mn/sec of the current
date...)
Thanks in advance for any help,
Seb
-
Re: Pb with % of CPU with options 'ug' and '-o pcpu' of ps command
On 19 Jul, 13:53, Sébastien de Mapias wrote:
> Hi,
> I'm writing a shell to spot the *current* worst CPU
> percentage running on my server, but when I run 'ps'
> commands and sort the output I've noticed I get values
> greater than 100:
>
> $ ps -e -o user= -o pid= -o pcpu= -o vsz= -o rss= -o s= -o time= -o
> args= |sort -r -n +2
> oracle 1503300 311004.1 22508 18460 Jul 13 84286931-15:48:10 /
> local/user/pg ...
> oracle 1859740 23788.8 18168 41192 May 11 84286931-10:11:47
> ora_lck0_sid
> oracle 1757314 23788.8 18232 39908 May 11 84286931-13:03:50
> ora_lmon_sid
>
> $ ps ug|sort -r -n +2|head -8
> oracle 1503300 310413.2 1.0 24288 18448 - A Jul 13
> -31227311:-26 /local/user/pg ...
> oracle 1859740 23785.3 1.0 104648 41140 - A May 11
> -31227648:-29 ora_lck0_sid
> oracle 1773668 [...]
>
> It seems that the %CPU is above 100 when the process's
> been running for days or weeks.
>
> Is there a way to tell the 'ps' to retain PID's that
> have been running SINCE TODAY only ?
> (if I do a 'grep' on 'Jul 19' I'll miss all lines looking
> like
> $ oracle 978970 0.0 2.0 95104 46324 - A 14:46:18 0:00
> ora_j000_
> i.e. lines containing only the hour/mn/sec of the current
> date...)
>
> Thanks in advance for any help,
> Seb
if you write it in perl, you'll have greater control at what to find
open (PS, "ps -ef|") or die "unable to ps";
while () {
something in here - reg exp???
}