From 8e592025e12824bbbc4a03efed0fe245f77c9105 Mon Sep 17 00:00:00 2001 From: Martin Gasbichler Date: Mon, 25 Oct 2004 14:38:46 +0000 Subject: [PATCH] Add %cpu --- scsh/pps/README | 5 +++-- scsh/pps/packages.scm | 1 + scsh/pps/pkg-def.scm | 2 +- scsh/pps/pps.scm | 14 ++++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/scsh/pps/README b/scsh/pps/README index 129eb37..eaf9f7c 100644 --- a/scsh/pps/README +++ b/scsh/pps/README @@ -1,6 +1,6 @@ The structure pps implements a portable version of the ps command. It -currently supports FreeBSD (4.6), Mac OS X/Darwin (10.2/6.3), Linux -(2.4.19), AIX (4.3.2), Solaris (SunOS 5.8) (tested version). As the ps +currently supports FreeBSD (4.6,5.2), Mac OS X/Darwin (10.2/6.3), Linux +(2.4.19), AIX (4.3.2), Solaris (SunOS 5.8,5.9) (tested version). As the ps command is not part of any standard this package is likely to fail if the version of your system differs from the one I tested. Please report incompatible versions and, if possible, provide an adapted @@ -38,6 +38,7 @@ Type predicate for process-info. (process-info-effective-gid process-info) -> number (process-info-saved-set-gid process-info) -> number (process-info-time process-info) -> number +(process-info-%cpu process-info) -> float-number (process-info-tty process-info) -> string (process-info-executable process-info) -> string (process-info-command-line process-info) -> string diff --git a/scsh/pps/packages.scm b/scsh/pps/packages.scm index bdb7810..553e8d6 100644 --- a/scsh/pps/packages.scm +++ b/scsh/pps/packages.scm @@ -12,6 +12,7 @@ process-info-effective-gid process-info-saved-set-gid process-info-time + process-info-%cpu process-info-tty process-info-executable process-info-command-line)) diff --git a/scsh/pps/pkg-def.scm b/scsh/pps/pkg-def.scm index a4269b3..89f2755 100644 --- a/scsh/pps/pkg-def.scm +++ b/scsh/pps/pkg-def.scm @@ -1,5 +1,5 @@ (define-package "pps" - (1 0) + (1 1) ((install-lib-version (1 0))) (write-to-load-script `((config) diff --git a/scsh/pps/pps.scm b/scsh/pps/pps.scm index c152647..e715369 100644 --- a/scsh/pps/pps.scm +++ b/scsh/pps/pps.scm @@ -8,7 +8,7 @@ (really-make-process-info pid ppid logname real-uid effective-uid saved-set-uid real-gid effective-gid saved-set-gid - time tty executable command-line) + time %cpu tty executable command-line) process-info? (pid process-info-pid) (ppid process-info-ppid) @@ -20,6 +20,7 @@ (effective-gid process-info-effective-gid) (saved-set-gid process-info-saved-set-gid) (time process-info-time) + (%cpu process-info-%cpu) (tty process-info-tty) (executable process-info-executable) (command-line process-info-command-line)) @@ -33,7 +34,7 @@ pid ppid logname real-uid effective-uid saved-set-uid real-gid effective-gid saved-set-gid - time tty executable . command-line) + time %cpu tty executable . command-line) (really-make-process-info (string->number pid) (string->number ppid) logname (string->number real-uid) (string->number effective-uid) @@ -41,6 +42,7 @@ (string->number real-gid) (string->number effective-gid) (string->number saved-set-gid) ((ps-time->seconds ps-functions) time) + (string->number %cpu) tty executable command-line)) (define *os-pss* '()) @@ -87,7 +89,7 @@ (let ((res (run/strings (ps -axww ;; uses rgid instead of gid - "-opid,ppid,user,ruid,uid,svuid,rgid,rgid,svgid,time,tty,ucomm,command")))) + "-opid,ppid,user,ruid,uid,svuid,rgid,rgid,svgid,time,%cpu,tty,ucomm,command")))) (if (null? res) (error "ps failed") (cdr res)))) @@ -136,7 +138,7 @@ (define (linux-ps-command) (let ((res (run/strings (ps -A ;axww - "-opid,ppid,user,ruid,uid,svuid,rgid,gid,svgid,time,tty,ucomm,command")))) + "-opid,ppid,user,ruid,uid,svuid,rgid,gid,svgid,time,%cpu,tty,ucomm,command")))) (if (null? res) (error "ps failed") (cdr res)))) @@ -164,7 +166,7 @@ (let ((res (run/strings (ps -A ;; uses ruid/rgid instead of svuid/svgid - -opid -oppid -ouser -oruid -ouid -oruid -orgid -ogid -orgid -otime -otty -oucomm -oargs)))) + -opid -oppid -ouser -oruid -ouid -oruid -orgid -ogid -orgid -otime -opcpu -otty -oucomm -oargs)))) (if (null? res) (error "ps failed") (cdr res)))) @@ -195,7 +197,7 @@ (let ((res (run/strings (ps -A ;; uses ruid/rgid instead of svuid/svgid - -opid -oppid -ouser -oruid -ouid -oruid -orgid -ogid -orgid -otime -otty -ocomm -oargs)))) + -opid -oppid -ouser -oruid -ouid -oruid -orgid -ogid -orgid -otime -opcpu -otty -ocomm -oargs)))) (if (null? res) (error "ps failed") (cdr res))))