Overview
Comment: | Added loadwatch |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.60 |
Files: | files | file ages | folders |
SHA1: |
69157830fb3b1473b06979337f394114 |
User & Date: | matt on 2015-06-18 05:59:45 |
Other Links: | branch diff | manifest | tags |
Context
2015-06-18
| ||
06:00 | Added loadwatch check-in: 610dd685d1 user: matt tags: v1.60 | |
05:59 | Added loadwatch check-in: 69157830fb user: matt tags: v1.60 | |
00:39 | More on multi-dboard check-in: b8e14b73cd user: matt tags: v1.60 | |
Changes
Added loadwatch/loadwatch.scm version [edb46feb54].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | (use regex srfi-69) (define-record processdat %cpu virt res %mem count ) (define (snagload) (let ((dat (make-hash-table)) ;; user => hash-of-processdat (hdr (regexp "^\\s+PID")) (rx (regexp "\\s+")) (wht (regexp "^\\s+")) ) (with-input-from-pipe "top -n 1 -b" (lambda () (let loop ((inl (read-line)) (inbod #f)) (if (eof-object? inl) dat (if (not inbod) (if (string-search hdr inl) (loop (read-line) #t) (loop (read-line) #f)) (let* ((lparts (map (lambda (x) (let ((num (string->number x))) (if num num x))) (string-split-fields rx (string-substitute wht "" inl) #:infix))) (user (list-ref lparts 1)) (virt (list-ref lparts 4)) (res (list-ref lparts 5)) (%cpu (list-ref lparts 8)) (%mem (list-ref lparts 9)) (time (list-ref lparts 10)) (pname (list-ref lparts 11)) (udat (or (hash-table-ref/default dat user #f) (let ((u (make-hash-table))) (hash-table-set! dat user u) u))) (pdat (or (hash-table-ref/default udat pname #f) (let ((p (make-processdat 0 0 0 0 0))) (hash-table-set! udat pname p) p)))) (print "User: " user ", pname: " pname ", virt: " virt ", res: " res ", %cpu: " %cpu ", %mem: " %mem) (processdat-%cpu-set! pdat (+ (processdat-%cpu pdat) %cpu)) (processdat-%mem-set! pdat (+ (processdat-%mem pdat) %mem)) (processdat-virt-set! pdat (+ (processdat-virt pdat) virt)) (processdat-res-set! pdat (+ (processdat-res pdat) res)) (processdat-count-set! pdat (+ (processdat-count pdat) 1)) (loop (read-line) inbod))))))))) (processdat-%cpu (hash-table-ref (hash-table-ref x "matt") "evolution-calen")) |