>>> "Soffen, Matthew" <[email protected]> schrieb am 03.02.2011 um 16:35 in
Nachricht <[email protected]>:
> Morning All,
>
> Please also keep in mind that /proc/stat is ONLY in Linux and Linux-HA
> despite the name is also used on FreeBSD and Solaris.
Hi!
Good thought: I was wondering whether the output format on other systems
matches that of Linux. Anyway, the other solutions are much faster than the
original. Maybe a $(uname) will help.
For example a Perl script that is supposed to get the list of running processes
on HP-UX and Linux (SLES10 SP3) uses a hash table like this:
use constant PS_CONF => {
# PID TTY TIME COMMAND
# 6714 ? 223:15 dw.sapC11_DVEBMGS00 pf=/usr/sap/C11/... bla bla
'hpux' => ['ps -ex', qr/^\s*(\d+)\s+\S+\s+\d+:\d+\s+(\S+)(.*)$/,
qr/^init$/],
# PID TTY STAT TIME COMMAND
# 15046 ? S 110:29 dw.sapC11_D09 pf=/usr/sap/C11/... bla bla
'linux' => ['ps ax', qr/^\s*(\d+)\s+\S+\s+\S+\s+\d+:\d+\s+(\S+)(.*)$/,
qr/^init$/],
}; # OS($^O)-dependent ps configuration
my $ps_conf = PS_CONF->{$^O};
Regards,
Ulrich
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems