How to send vnstat info to rsyslog server

Hi,

I’m sending all logs from my IPFire server to a rsyslog server with the intention of visualising some stuff using grafana / loki / promtail. However, the data I’m most interested in is the upload volume per day on the Red interface. I figured out I can get this using vnstat on the ipfire server. (I think this is where the nice graphs on Status → Network External come from?)
Is there any way to have this data rsynclogged? Or can I get this data from one of the other log files?
Any help/tips/suggestions are greatly appreciated

best regards,
Andy

I think for IPFire ecosystem, pmacct is the best way to solve the problem you are addressing.

Here the official documentation:

This is one of the numerous discussions in the forum, you might find more searching the forum:

https://community.ipfire.org/t/pmacct-a-lightweight-passive-network-monitoring-tool

2 Likes

Hi, thank you cfusco for your reply
I ended up writing a small script that runs hourly (put script in /etc/fcron.hourly) on our ipfire box and sends the data I need to the logfile. This logfile are rsyslogged to my grafana/loki/promtail server and I can now process them there. For my purpose this is enough.
I’ll provide my (very simple) script below if anyone is interested.

#!/bin/bash
traffic=`vnstat -i red0 -h |tail --lines=2 | head --lines=1`
#remove preceding spaces
traffic=${traffic##*( )}
#remove trailing spaces   
traffic=${traffic%%*( )}
today="`date "+%F"`"
read -ra partsarray <<<"$traffic"
logger -n 10.31.13.15 -d  "date=${today} time=${partsarray[0]} rx=${partsarray[1]} rxunit=${partsarray[2]} tx=${partsarray[4]} txunit=${partsarray[5]} total=${partsarray[7]} totalunit=${partsarray[8]} avgrate=${partsarray[10]} avgrateunit=${partsarray[11]}"
3 Likes