Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Apr 2010 13:01:01 +0400
From:      Dmitry Banschikov <ubique@peterhost.ru>
To:        freebsd-hackers@freebsd.org
Subject:   netstat count option
Message-ID:  <20100421130101.1d9511f1@amnesiac.pht>

next in thread | raw e-mail | index | archive | help
--MP_/ktqoCc4IQ7gk79MSWG86aWv
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello,

I wrote small patch to the netstat utility.
The patch allows to specify how many times, the display output should be continue,
in case of option -w.
Usage:
# ./netstat -w2 -c2
            input        (Total)           output
   packets  errs      bytes    packets  errs      bytes colls
        15     0       2268         13     0       1190     0
         4     0        240          5     0        278     0
# 

Option -c [count] is simillar to the same option in iostat utility.
In linux -c means continious output:
   -c, --continuous
       This will cause netstat to print the selected information every second continuously.
       

-- 

Dmitry Banshchikov
--MP_/ktqoCc4IQ7gk79MSWG86aWv
Content-Type: application/octet-stream; name=patch-netstat
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=patch-netstat

LS0tIGlmLmMJMjAwOS0xMC0yNSAwNDoxMDoyOS4wMDAwMDAwMDAgKzAzMDAKKysrIGlmLmMJMjAx
MC0wNC0yMSAxMTozMjoxNS4wMDAwMDAwMDAgKzA0MDAKQEAgLTY3Niw2ICs2NzYsMTAgQEAKIAlp
ZiAoIWZpcnN0KQogCQlwdXRjaGFyKCdcbicpOwogCWZmbHVzaChzdGRvdXQpOworCWlmIChjZmxh
ZykKKwkJY291bnQtLTsKKwlpZiAoY291bnQgPCAwICYmIGNmbGFnKQorCQlleGl0KDApOwogCW9s
ZG1hc2sgPSBzaWdibG9jayhzaWdtYXNrKFNJR0FMUk0pKTsKIAl3aGlsZSAoIXNpZ25hbGxlZCkK
IAkJc2lncGF1c2UoMCk7Ci0tLSBtYWluLmMJMjAwOS0xMC0yNSAwNDoxMDoyOS4wMDAwMDAwMDAg
KzAzMDAKKysrIG1haW4uYwkyMDEwLTA0LTIxIDExOj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Xh0ZXJuIGludAloZmxhZzsJ
Lyogc2hvdyBjb3VudGVycyBpbiBodW1hbiByZWFkYWJsZSBmb3JtYXQgKi8KQEAgLTU1LDYgKzU2
LDcgQEAKIGV4dGVybiBpbnQJemZsYWc7CS8qIHplcm8gc3RhdHMgKi8KIAogZXh0ZXJuIGludAlp
bnRlcnZhbDsgLyogcmVwZWF0IGludGVydmFsIGZvciBpL2Ygc3RhdHMgKi8KK2V4dGVybiBpbnQJ
Y291bnQ7CSAgLyogcmVwZWF0ZSBkaXNwbGF5IG91dHB1dCAqLwogCiBleHRlcm4gY2hhcgkqaW50
ZXJmYWNlOyAvKiBkZXNpcmVkIGkvZiBmb3Igc3RhdHMsIG9yIE5VTEwgZm9yIGFsbCBpL2ZzICov
CiBleHRlcm4gaW50CXVuaXQ7CS8qIHVuaXQgbnVtYmVyIGZvciBhYm92ZSAqLwo=

--MP_/ktqoCc4IQ7gk79MSWG86aWv--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100421130101.1d9511f1>