Skip to content

Instantly share code, notes, and snippets.

@kleo
Last active October 29, 2020 01:48
Show Gist options
  • Select an option

  • Save kleo/dea8ee9252bc2cae0e0c7b13de6796f4 to your computer and use it in GitHub Desktop.

Select an option

Save kleo/dea8ee9252bc2cae0e0c7b13de6796f4 to your computer and use it in GitHub Desktop.

TIG Stack AN5506-04-FA and Raspberry Pi

Defaults has UTC configured to GMT+8, configure NTP with adminpldt

Management > Device Management > NTP Check Time

time.google.com
time.google.com

Set timezone to (GMT)Gambia, Liberia, Morocco

telegraf setup

Download telegraf armel-linux latest release from https://github.com/influxdata/telegraf/releases

tar xvf telegraf-*.*.*_linux_armel.tar.gz

You can yeet the contents to the device /etc, /usr, and /var

For me I'm using a fat32 flash drive which is symlinked from /sda1 -> /dev/shm/usb/media/sda1

Configure telegraf

vi /etc/telegraf/telegraf.conf

You can set the device hostname and you can also choose to just omit it.

hostname = ""

omit_hostname = true

Configure influxdb connection

Output options

[[outputs.influxdb]]

urls = ["http://<rpi>:8086"]

database = "pldt"

HTTP Basic Auth
username = "telegraf"
password = "password"

Input options

[[inputs.net]]

interfaces = ["wan0"]

Test telegraf config

telegraf --test

Start telegraf on boot

Add telegraf to /fh/extend/initialize.sh

[...]
pldc &
telegraf &

We need to collect telegraf stats from our router to somewhere else. I'll use a Raspberry Pi for this guide.

  • Raspberry Pi Model B Plus Rev 1.2
  • 2020-08-20-raspios-buster-armhf-lite.img

Install influxdb

sudo apt install influxdb
sudo systemctl enable influxdb
sudo systemctl start influxdb

Create user and database

create user telegraf with password [REDACTED] with all privileges
create database pldt

You can test out your queries using influxdb-client

influx

> auth
username: telegraf
password:

> use pldt
> show measurements

SELECT last("bytes_recv") FROM "net" WHERE "interface" = 'wan0'

Grafana setup

Download Grafana from https://grafana.com/grafana/download?platform=arm

I'm using an older Raspberry Pi so I'm going to use Ubuntu and Debian(ARMv6)

sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana-rpi_7.3.0_armhf.deb
sudo dpkg -i grafana-rpi_7.3.0_armhf.deb

Enable Grafana so that it starts on boot and start it

sudo systemctl enable grafana-server
sudo systemctl start grafana-server

We can now go to http://:3000 and login admin:admin

Set data source

Configuration > Data Sources > Add data source

Select InfluxDB

URL: http://localhost:8086

enable basic Auth

user

password

db pldt

http method get

Field

Unit Data rate > bytes/sec(SI)

A

ALIAS BY Download

SELECT derivative("bytes_recv", 10s) FROM "net" WHERE "interface" = 'wan0'
B

ALIAS BY Upload

SELECT derivative("bytes_sent", 10s) FROM "net" WHERE "interface" = 'wan0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment