Zembower, Kevin wrote:
> I'm trying to capture the number of bytes transmitted and received on
> my eth0 interface for use with RRD. I'm using this source for the
> data: 
> 
> 
> 
> [EMAIL PROTECTED]:~/rrdmonitoring$ cat /proc/net/dev
> 
> Inter-|   Receive                                                |
> Transmit
> 
>  face |bytes    packets errs drop fifo frame compressed
> multicast|bytes packets errs drop fifo colls carrier compressed
> 
>     lo:31738431  323299    0    0    0     0          0         0
> 31738431  323299    0    0    0     0       0          0
> 
>   eth0:147992894 45634695    0    0    0     0          0         0
> 1722980290 70429910    0    0    4     0       0          0
> 
>   sit0:       0       0    0    0    0     0          0         0
> 0       0    0    0    0     0       0          0
> 
> [EMAIL PROTECTED]:~/rrdmonitoring$
> 
> 
> 
> When I try to grab just the number of received bytes on eth0, it
> duplicates the number:
> 
> 
> 
> [EMAIL PROTECTED]:~/rrdmonitoring$ cat /proc/net/dev|perl -ne
> '/eth0:(\d+)\s+.*/; print $1;'
        Once you do get a hit, then $1 will stay at the last successful hit, so 
you get it printed twice. One way is to
tie with if and success:

        print $1 if ( /eth0:(\d+)\s+.*/ );
  Will only print if you are successful.

Wags ;)
> 
> [EMAIL PROTECTED]:~/rrdmonitoring$
> 
> 
> 
> Note that the number repeats after 9 digits. Any ideas why?
> 
> 
> 
> Any suggestions on how to improve my script overall?  I'm actually
> reduced to doing this, to grab the received and transmitted bytes:
> 
> 
> 
> [EMAIL PROTECTED]:~/rrdmonitoring$ rrdtool update /var/log/rrd/wwweth0.rrd
> N:`cat /proc/net/dev|perl -ne 'm[eth0:(\d+).*]; print "$1";'`:`cat
> /proc/net/dev|perl -ne 'm[eth0:(\d+\s+){9}(\d+).*]; print "$1";'`
> 
> ERROR: expected 2 data source readings (got 0) from 1735196319:...
> 
> [EMAIL PROTECTED]:~/rrdmonitoring$
> 
> 
> 
> What I'd really like to do is just run the perl script once and return
> both values. The only way I know to interface this with rrd is to
> assign each of the values to shell variables, and I don't know how to
> do this within perl or in the shell.
> 
> 
> 
> Thanks for your suggestions.
> 
> 
> 
> -Kevin Zembower



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to