ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: "\"KoLyA\" " <kolyag@mail.ru>
To: community@altlinux.ru
Subject: Re[2]: [Comm] Подсчет трафика
Date: Mon, 23 Jun 2003 16:05:56 +0400
Message-ID: <E19UQ56-0003Ok-00.kolyag-mail-ru@f23.mail.ru> (raw)
In-Reply-To: <20030620171749.7236efda.CityHawk@inbox.ru>



-----Original Message-----
From: "Eugene A. Suchkov" <CityHawk@inbox.ru>
To: community@altlinux.ru
Date: Fri, 20 Jun 2003 17:17:49 +0000
Subject: Re: [Comm]  Подсчет трафика

> 
> On Fri, 20 Jun 2003 18:55:41 +0600
> Леутин Александр <leutin-lists@rambler.ru> wrote:
> 
> > > Все бы ничего, только это все про ОБЪЕМ ТРАФИКА, а меня интересует
> > > именно СКОРОСТЬ.
> > Понял. Возможно, я перепутал выше сообщение с другим %-)
> > И всё же -- лучше помогите уже существующим проектам (уверен, такие
> > есть), не заставляйте других и сами не изобретайте велосипед :).
> 
> Именно это я и пытаюсь сделать...
> 

в общем так.

простой скриптик, снимает статистику преданных/принятых байтов с /proc/net/dev.

пускается по watch.

хотя есть конечно iptraf, скорость показывает, но не совсем точно (на линии 115кБИТ он показывает скорость иногда до 30кБАЙТ/с). + я не знаю как его заставить логи вести.

а вот и сам скриптик:
------------------------------------------------
#!/bin/sh
## "моментальная" скорость eth0
## будет считать точнее если брать не через 1, а 2-5 секунд. 
## тогда там где bc поменять 1 на соответственно 2 или 3 или ... etc.
###### САМОЕ ПЕРВОЕ: снять статистику
st=$(cat /proc/net/dev|grep eth0)

###### дальше спокойно разбираем
###### переданные байты: 
db=$(echo $st|awk '{print $9}')
###### принятые байты: то же самое только awk '{print substr($1,6)}'
db=$(echo $st|awk '{print substr($1,6)}')

da=$(cat /tmp/oldc)
echo $db>/tmp/oldc
sp=`echo "scale=4;($db-$da)/(1*1024*1024)"|bc`
echo $sp>>/tmp/speedlog
echo $sp Mb/s
------------------------------------------------
надеюсь все понятно
раскоментируйте снятие либо принятых либо переданных байтов
первая цифра в логе будет лажовая, дальше нормально. перед запуском надо
echo 0 > /tmp/oldc



           reply	other threads:[~2003-06-23 12:05 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20030620171749.7236efda.CityHawk@inbox.ru>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E19UQ56-0003Ok-00.kolyag-mail-ru@f23.mail.ru \
    --to=kolyag@mail.ru \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git