mrtg und gigabit
Florian Lohoff
flo at rfc822.org
Wed Jun 8 01:41:34 CEST 2005
On Tue, Jun 07, 2005 at 09:55:36PM +0200, Jan 'Red Bully' Seiffert wrote:
> sed -ne "/eth0:/ { s/.*://; p; }" /proc/net/dev | tr -s '\t ' ' ' | \
> { while read line ; do echo $line | cut -d' ' -f1; echo $line | cut \
> -d' ' -f9 ; done };
>
> Oder so aehnlich...
Eben nicht - das kann ja jeder - Nur am rande - Das dingen forken beim
ausfueren parallel einen sed, tr, eine shell die je nach anzahl der
interfaces - also mindestens mal 2 ein echo(shell internal) cut und das
selbe nochmal.
Also 2 forks im loop, mal 2 interfaces. Macht 4 forks. Dazu kommen
parallen forks von sed und tr und der subshell. Macht 7 forks.
Ich mache es dir in einem ;)
flo at source:~$ cat /usr/local/sbin/mrtg-iface
#!/bin/sh
IFACE=$1
cat /sys/class/net/${IFACE}/statistics/rx_bytes \
/sys/class/net/${IFACE}/statistics/tx_bytes \
/proc/uptime \
/proc/sys/kernel/hostname
Wenns ganz perfekt werden soll vor das cat noch nen exec dann wird aus
dem "fork/exec/waitpid" ein "exec" also wieder mind. 2 syscalls und eine
menge copy on write gespart.
Flo
--
Florian Lohoff flo at rfc822.org +49-171-2280134
Heisenberg may have been here.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lug-owl.de/pipermail/linux/attachments/20050608/bae47b02/attachment.sig>
More information about the Linux
mailing list