Vnstat sensors

I recently (read today) started using vnstat to monitor my server’s bandwidth usage.
Since it has the option to show monthly usage data, it would be nice to have an integration with HA.

This way an automation could be triggered when the monthly (current month) usage exceeds a certain amount, notifying you, or all downloaders to slow down.

I couldn’t find a python wrapper for it yet (I found one on pypi) but I’m not sure if it still works, since it’s from 2009 (I’ve yet to try it out)

Maybe you could try “command line sensor” ???

Well, the thing is that it doesn’t just return a number, it’s formatted in a table (unless I missed some config, cmd options)

EDIT: After checking some stuff, it seems that the version in the ubuntu repos is a bit behind, manually installing the newest version gives me more possibilities, will try with command line sensor

The system monitor sensor can record network traffic.

Yes I know, I used that previously, but that only records traffic from the current uptime, so when you restart it gets reset, and you also can’t get data for the current month

Command line sensor did it for now. I’ll have to check back when the month changes, since it currently uses 0 as month, I’m not sure how vnstat returns that data (if it puts the present month in the 0 index always it won’t be a problem, otherwise I’ll have to fiddle with the length).

Also, when monitoring multiple interfaces the command line sensor wouldn’t be sufficient, hence having a component for it would be nicer

Mind sharing your setup? I’m looking for the same. Looks like vnstat can output as json.