<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=us-ascii" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Dave,<br>
<br>
Thanks for thinking about this.<br>
<br>
David L. Anselmi wrote:
<blockquote cite="mid:4DF266A7.50902@anselmi.us" type="cite">
  <pre wrap="">Jim Ockers wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">What I was thinking was, since we are allowed 5GB in a month, that I would figure out the total
bandwidth used in the last 3 weeks, and if the total bandwidth was 3/4 * 5GB then I would start
throttling down the available bandwidth on the interface using tc and traffic shaping.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">I'd like a 3 week time interval, and I want it to interpolate and use zero for NaNs, and give me
the AVERAGE BANDWIDTH USAGE FOR THE LAST 3 WEEKS IN ONE NUMBER.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
So you don't really want average bandwidth.  You want bytes transferred.  (You want a value, not a 
rate, and a total, not an average.)
  </pre>
</blockquote>
That's correct, I need a total, but that SHOULD be fairly easy to get
by taking ( elapsed time ) * (average data rate xferred during that
elapsed time) .<br>
<blockquote cite="mid:4DF266A7.50902@anselmi.us" type="cite">
  <pre wrap="">
What numbers are you getting from the interface?  If you're just using tx/rx_bytes what does rrdtool 
get you (since tx/rx_bytes is what you want)?
  </pre>
</blockquote>
Sure, those would be dandy, I want the tx/rx bytes, so I can subtract
the start value from the end value for a 3 week interval.&nbsp;
Unfortunately this system gets rebooted a lot and could be powered off
for extended periods of time, and so we need something to keep
continuous statistics for whenever the thing is running, to preserve
the state, if you will.&nbsp; rrdtool is perfect for saving the state so
that it persists over time and across reboots, because it stores the
rate and not the actual bytes tx/rx.<br>
<blockquote cite="mid:4DF266A7.50902@anselmi.us" type="cite">
  <pre wrap="">
Seems to me that tx/rx_bytes have these problems:

They roll over eventually.  On a 32 bit system that might be before 5GB.
  </pre>
</blockquote>
These things get rebooted often enough that the counters won't roll
over.&nbsp; But yeah I think the counter rollover is 4GB on an interface for
32-bit Linux.<br>
<blockquote cite="mid:4DF266A7.50902@anselmi.us" type="cite">
  <pre wrap="">
They can't be zeroed unless you reload the driver module (maybe things are different now but I 
didn't quickly find another way to reset them).

If you reset the counters at the beginning of the month you'll need a way to detect premature 
resets.  Maybe rrdtool can help with that.
  </pre>
</blockquote>
Yes, that's exactly what rrdtool is best for.<br>
<blockquote cite="mid:4DF266A7.50902@anselmi.us" type="cite">
  <pre wrap="">
rrdtool seems intent on thinking about your raw numbers in intervals and I don't think that's the 
problem you have.  But maybe there's an example of people using it to notice thresholds being 
crossed (running out of disk space or memory).

If you're just looking at the kernel counters, does SNMP offer a way to get the data differently?
  </pre>
</blockquote>
Using SNMP would mean preserving the state somewhere else.&nbsp; I need to
preserve the state on this system itself so that it can keep track of
the bandwidth usage of its own 3G card, and throttle itself back if it
starts to approach the limit, to keep the usage under 5GB in any given
month.<br>
<br>
Thanks,<br>
Jim<br>
<pre class="moz-signature" cols="72">-- 
Jim Ockers, P.Eng. (<a class="moz-txt-link-abbreviated" href="mailto:ockers@ockers.net">ockers@ockers.net</a>)
Contact info: <a class="moz-txt-link-freetext" href="http://www.ockers.net/msi.html">http://www.ockers.net/msi.html</a>

</pre>
</body>
</html>