>>>>> Regarding 'Re: cool for CPU/memory/etc monitor for XWEM'; Steve Youngs
>>>>> adds:
Ugh, I've just noticed that the subject line is kind of gibberish, sorry
for that. :)
> * Richard Klinda <ignotus@xxxxxxxxxxx> writes:
>> XWEM watches bandwidth utilization
> How? Where? What?
For bandwidth notifier I use cban, this is a very little command line
utility that reports bandwidth usage, supposed to be used with MRTG or
other data loggers.
,----
| <ignotus> .freshmeat cban
| -Mojojojo- ((freshmeat)) Current Bandwidth (CBan) displays current
traffic
| on a selected interface. Traffic can be seen in
(kilo)bytes/bits in
| console in an output suitable for mrtg (config file
included) or sent to a
| RRDTOOL database (database creation, stats.cgi, and cron
examples
| included). http://panic.eu.org/linux/cban/
`----
The lisp snippet is here (doesn't contain any XWEM specific stuff),
please skim through the comments.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;;; ----------------------------------------------------------------------
;; "when is my download over" monitor for XEmacs. Uses cban.
(defvar cban-speed-limit 50) ; if speed is > 50 KiB/sec
; then we are downloading
(defvar cban-downloading-count 0) ; >1 if downloading is in
; progress
(defvar cban-signal-p nil) ; t when long download is
; over, there should be a
; signal...
;; (cban-start-query)
(defun cban-start-query ()
(let ((p (start-process "cban" nil
"~/.bin/cban" "-i" "eth0" "-m" "-k" "-u" "20")))
;; "-u 20" <- measure for 20 seconds
(set-process-filter p 'cban-process-filter)))
(defun cban-process-filter (process output)
(let ((speed (car (read-from-string output))))
(unless cban-signal-p
(cond
;; a long download is over, we need signalling
((and (> cban-downloading-count 1)
(< speed cban-speed-limit))
(setq cban-signal-p t))
;; we are still downloading, increase the download count
((> speed cban-speed-limit)
(incf cban-downloading-count))
;; short download is over, no need to signal...
((and (> cban-downloading-count 0)
(< speed cban-speed-limit))
(setq cban-downloading-count 0))))))
;; (cban-ack-signal) run this when you want to get rid of the signal
(defun cban-ack-signal ()
(interactive)
(setq cban-downloading-count 0
cban-signal-p nil))
;; measure speed every 5 minutes, so when two consequtive speed
;; measurments are over 50 KiB/sec then the first time it drops below
;; that I get the signal.
(start-itimer "cban"
'cban-start-query
300 300)
;(delete-itimer "cban")
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
For signalling I use this snippet, I put it into a function that is
being run by every couple of seconds, this puts a nice "pink" box on one
of my XWEM OSDs. When I notice it I have to run M-x cban-ack-signal to
get rid of it.
,----
| (when cban-signal-p
| (xwem-osd-rect-add ign-erc-osd
| 66 0 8 10
| 4
| "pink"))
`----
I hope that maybe you or someone finds it useful.:)
--
Richard Klinda \/
/\ Show me your init.el and I'll you tell who you are.
|