Collect Network Statistic With Telegraf & VNSTAT

I use Telegraf on various hosts without any problem, but in some cases I'm facing issues using sysstat plugin on Orange PI zeros.

One of the most important thing for me to collect network bandwidth statistic. For this sysstat plugin is perfect, but how to achieve this without it?

I was thinking a bit, and found out that with exec plugin and vnstat I can gather information about bandwidth.

Here is the configuration:

[[inputs.exec]]
  commands = [
    "/usr/bin/vnstat -i eth0 -tr --short --json",
    "/usr/bin/vnstat -i tun0 -tr --short --json"
    ]
  timeout = "10s"
  name_suffix = "_vnstat"
  data_format = "json"
  json_name_key="vnstat"
  tag_keys= ["interface"]

References:

Example InfluxDB Commands

  • List avaiable hosts:
SHOW TAG VALUES  ON telegraf from "system" WITH KEY = "host"  
  • Show MEASUREMENTS
SHOW MEASUREMENTS  WITH MEASUREMENT =~ /exec.*/  

Output:

name: measurements  
name  
----
exec_vnstat  
  • List Series:
SHOW SERIES ON telegraf FROM exec_vnstat;  

Output:

key  
---
exec_vnstat,dc=barber,host=*****-opi0,interface=eth0,rack=opi0  
exec_vnstat,dc=barber,host=*****-opi0,interface=tun0,rack=opi0  

Vincze Janos Istvan

Read more posts by this author.

Hungary

Subscribe to Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!