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