0

I have code to get bandwidth:

counter = psutil.net_io_counters(pernic=True, nowrap=True).bytes_received

while True:
    bytes_received = psutil.net_io_counters(pernic=True, nowrap=True).bytes_received
    result = counter - bytes_received
    print(result)
    counter = bytes_received

I want to calculate this difference in COMPUTE field.
DS:input_traffic - will be store result of psutil.net_io_counters(pernic=True, nowrap=True).bytes_received

So I added rrdtool create

rrdtool.create(
    "123.rrd",
    "--start",
    "now",
    "--step",
    "300",
    "DS:input_traffic:GAUGE:600:0:U",
    "DS:result:COMPUTE:input_traffic,PREV,-",
    "RRA:AVERAGE:0.5:1:576",
    "RRA:AVERAGE:0.5:6:672",
    "RRA:AVERAGE:0.5:24:732",
    "RRA:AVERAGE:0.5:144:1460",
) 

But something went wrong.
Is it real to implement this calculation in RRDtool? Thanks

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
antl
  • 3
  • 2
  • I can't see why you would do this using a GAUGE and a COMPUTE type, rather than just a COUNTER or a DERIVE. RRDtool was designed to record the input data rate of change, no need to implement it yourself in a calculated DS. – Steve Shipway Sep 30 '22 at 04:00

0 Answers0