aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ansible/plays/ops-server-generate-telegraf-config.yml14
-rw-r--r--ansible/plays/ops-server.yml8
-rw-r--r--ansible/plays/templates/ops-server/docker-compose.yml13
-rw-r--r--ansible/plays/templates/ops-server/telegraf.conf238
-rw-r--r--ansible/plays/templates/ops-server/telegraf.conf.j284
-rw-r--r--docker/birgitte/unifi/docker-compose.yaml1
6 files changed, 357 insertions, 1 deletions
diff --git a/ansible/plays/ops-server-generate-telegraf-config.yml b/ansible/plays/ops-server-generate-telegraf-config.yml
new file mode 100644
index 0000000..9bafd2a
--- /dev/null
+++ b/ansible/plays/ops-server-generate-telegraf-config.yml
@@ -0,0 +1,14 @@
+- hosts: localhost
+ connection: local
+ tasks:
+ - template:
+ src: ops-server/telegraf.conf.j2
+ dest: templates/ops-server/telegraf.conf
+ vars:
+ - aps:
+ - name: Over stue
+ ip: 192.168.10.20
+ - name: Over kjøkken
+ ip: 192.168.10.21
+ - name: Kontor
+ ip: 192.168.10.22
diff --git a/ansible/plays/ops-server.yml b/ansible/plays/ops-server.yml
index adfcfc6..543b547 100644
--- a/ansible/plays/ops-server.yml
+++ b/ansible/plays/ops-server.yml
@@ -2,6 +2,7 @@
- birgitte
vars:
grafana_basedir: /pool0/ops/grafana
+ etc_dir: /etc/docker-service/ops-server
tasks:
- become: yes
name: mkdir /etc/docker-service/ops-server
@@ -14,7 +15,12 @@
- become: yes
template:
src: "templates/ops-server/influxdb.conf"
- dest: "/etc/docker-service/ops-server/"
+ dest: "{{ etc_dir }}/influxdb.conf"
+
+ - become: yes
+ template:
+ src: "templates/ops-server/telegraf.conf"
+ dest: "{{ etc_dir }}/telegraf.conf"
- become: yes
name: permissions
diff --git a/ansible/plays/templates/ops-server/docker-compose.yml b/ansible/plays/templates/ops-server/docker-compose.yml
index a3d7033..c459401 100644
--- a/ansible/plays/templates/ops-server/docker-compose.yml
+++ b/ansible/plays/templates/ops-server/docker-compose.yml
@@ -21,5 +21,18 @@ services:
- /home/trygvis/dev/io.trygvis/infra/docker/birgitte/ops/influxdb.conf:/etc/influxdb/influxdb.conf:ro
- /pool0/ops/influxdb:/var/lib/influxdb
+ telegraf:
+ image: telegraf:1.15
+ networks:
+ - influx
+ volumes:
+ - {{ etc_dir }}/telegraf.conf:/etc/telegraf/telegraf.conf:ro
+ environment:
+ INFLUX_URL: "http://idb:8086"
+ command:
+ - sh
+ - -c
+ - "sed -i -e 's/main/main non-free/' /etc/apt/sources.list && apt update && apt install --install-recommends=no -y snmp-mibs-downloader && exec telegraf"
+
networks:
influx:
diff --git a/ansible/plays/templates/ops-server/telegraf.conf b/ansible/plays/templates/ops-server/telegraf.conf
new file mode 100644
index 0000000..18a858b
--- /dev/null
+++ b/ansible/plays/templates/ops-server/telegraf.conf
@@ -0,0 +1,238 @@
+[[outputs.influxdb]]
+ urls = ["$INFLUX_URL"]
+ skip_database_creation = false
+
+# Access point: Over stue
+
+[[inputs.snmp]]
+ agents = [ "192.168.10.20" ]
+ version = 2
+ community = "public"
+ interval = "60s"
+ timeout = "30s"
+
+# meta information
+# this will be added automatically as a tag to the next snmp.table
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysName.0"
+ name = "ap_name"
+ is_tag = true
+
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysLocation.0"
+ name = "ap_location"
+ is_tag = true
+
+# table
+[[inputs.snmp.table]]
+# Using the oid here will query all fields automatically!
+# Be careful when using the oid on inputs.snmp.table as this will
+# produce a lot of information
+# oid = "IF-MIB::ifXTable"
+ name = "unifi_ap_if"
+ inherit_tags = ["ap_name", "ap_location"]
+
+# fields
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifName"
+ name = "name"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifOperStatus"
+ name = "status"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifAlias"
+ name = "ifAlias"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPromiscuousMode"
+ name = "promiscuous_mode"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifConnectorPresent"
+ name = "has_connector"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPhysAddress"
+ name = "mac"
+ conversion = "hwaddr"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInOctets"
+ name = "rx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInUcastPkts"
+ name = "rx_ucast_pkt"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutOctets"
+ name = "tx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutUcastPkts"
+ name = "tx_ucast_pkt"
+
+# Access point: Over kjøkken
+
+[[inputs.snmp]]
+ agents = [ "192.168.10.21" ]
+ version = 2
+ community = "public"
+ interval = "60s"
+ timeout = "30s"
+
+# meta information
+# this will be added automatically as a tag to the next snmp.table
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysName.0"
+ name = "ap_name"
+ is_tag = true
+
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysLocation.0"
+ name = "ap_location"
+ is_tag = true
+
+# table
+[[inputs.snmp.table]]
+# Using the oid here will query all fields automatically!
+# Be careful when using the oid on inputs.snmp.table as this will
+# produce a lot of information
+# oid = "IF-MIB::ifXTable"
+ name = "unifi_ap_if"
+ inherit_tags = ["ap_name", "ap_location"]
+
+# fields
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifName"
+ name = "name"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifOperStatus"
+ name = "status"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifAlias"
+ name = "ifAlias"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPromiscuousMode"
+ name = "promiscuous_mode"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifConnectorPresent"
+ name = "has_connector"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPhysAddress"
+ name = "mac"
+ conversion = "hwaddr"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInOctets"
+ name = "rx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInUcastPkts"
+ name = "rx_ucast_pkt"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutOctets"
+ name = "tx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutUcastPkts"
+ name = "tx_ucast_pkt"
+
+# Access point: Kontor
+
+[[inputs.snmp]]
+ agents = [ "192.168.10.22" ]
+ version = 2
+ community = "public"
+ interval = "60s"
+ timeout = "30s"
+
+# meta information
+# this will be added automatically as a tag to the next snmp.table
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysName.0"
+ name = "ap_name"
+ is_tag = true
+
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysLocation.0"
+ name = "ap_location"
+ is_tag = true
+
+# table
+[[inputs.snmp.table]]
+# Using the oid here will query all fields automatically!
+# Be careful when using the oid on inputs.snmp.table as this will
+# produce a lot of information
+# oid = "IF-MIB::ifXTable"
+ name = "unifi_ap_if"
+ inherit_tags = ["ap_name", "ap_location"]
+
+# fields
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifName"
+ name = "name"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifOperStatus"
+ name = "status"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifAlias"
+ name = "ifAlias"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPromiscuousMode"
+ name = "promiscuous_mode"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifConnectorPresent"
+ name = "has_connector"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPhysAddress"
+ name = "mac"
+ conversion = "hwaddr"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInOctets"
+ name = "rx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInUcastPkts"
+ name = "rx_ucast_pkt"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutOctets"
+ name = "tx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutUcastPkts"
+ name = "tx_ucast_pkt"
+
diff --git a/ansible/plays/templates/ops-server/telegraf.conf.j2 b/ansible/plays/templates/ops-server/telegraf.conf.j2
new file mode 100644
index 0000000..e973358
--- /dev/null
+++ b/ansible/plays/templates/ops-server/telegraf.conf.j2
@@ -0,0 +1,84 @@
+[[outputs.influxdb]]
+ urls = ["$INFLUX_URL"]
+ skip_database_creation = false
+
+{% for ap in aps %}
+# Access point: {{ ap.name }}
+
+[[inputs.snmp]]
+ agents = [ "{{ ap.ip }}" ]
+ version = 2
+ community = "public"
+ interval = "60s"
+ timeout = "30s"
+
+# meta information
+# this will be added automatically as a tag to the next snmp.table
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysName.0"
+ name = "ap_name"
+ is_tag = true
+
+[[inputs.snmp.field]]
+ oid = "RFC1213-MIB::sysLocation.0"
+ name = "ap_location"
+ is_tag = true
+
+# table
+[[inputs.snmp.table]]
+# Using the oid here will query all fields automatically!
+# Be careful when using the oid on inputs.snmp.table as this will
+# produce a lot of information
+# oid = "IF-MIB::ifXTable"
+ name = "unifi_ap_if"
+ inherit_tags = ["ap_name", "ap_location"]
+
+# fields
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifName"
+ name = "name"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifOperStatus"
+ name = "status"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifAlias"
+ name = "ifAlias"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPromiscuousMode"
+ name = "promiscuous_mode"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifConnectorPresent"
+ name = "has_connector"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifPhysAddress"
+ name = "mac"
+ conversion = "hwaddr"
+ is_tag = true
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInOctets"
+ name = "rx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCInUcastPkts"
+ name = "rx_ucast_pkt"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutOctets"
+ name = "tx_bytes"
+
+[[inputs.snmp.table.field]]
+ oid = "IF-MIB::ifHCOutUcastPkts"
+ name = "tx_ucast_pkt"
+
+{% endfor %}
diff --git a/docker/birgitte/unifi/docker-compose.yaml b/docker/birgitte/unifi/docker-compose.yaml
index 74da9ac..52dfcf2 100644
--- a/docker/birgitte/unifi/docker-compose.yaml
+++ b/docker/birgitte/unifi/docker-compose.yaml
@@ -19,6 +19,7 @@ services:
- 8843:8843
- 8880:8880
- 6789:6789
+ - 161:161/udp # snmp
network_mode: "host"
restart: unless-stopped