Add Synology NAS monitoring

This commit is contained in:
Leon Morten Richter 2021-08-01 15:00:09 +02:00
parent 0b8c8b4662
commit 7c8b4dfac5
No known key found for this signature in database
GPG key ID: 268100ABB6E5776A
6 changed files with 10202 additions and 4 deletions

View file

@ -6,6 +6,7 @@ Over the past years I replaced all my networking gear with Mikrotik devices. I a
- [A somewhat useable Grafana Dashboard](https://grafana.com/grafana/dashboards/10950)
- [A Prometheus exporter for Mikrotik devices written in Python](https://github.com/akpw/mktxp).
- [A Prometheus exporter for Mikrotik devices written in Go](https://github.com/nshttpd/mikrotik-exporter)
## Setup
- Router running RouterOS 7.x.x
@ -29,9 +30,43 @@ Create a user that is part of the group:
`/user add name=prometheus group=prometheus password=TOP_SECRET`
Because the library makes a new connection for every API request, your logs are getting cluttered:
`system logging set 0 topics=info,!account`
## Prepare Synology NAS
Firstly, activate SNMPv3 in your Synology NAS und set a username and password (md5).
In order to get stats from a Synology NAS into Prometheus an exporter is needed.
-> https://github.com/prometheus/snmp_exporter
This exporter comes with a pre-build docker image.
There is a pre-build `snmp.yml`, where you only need to update the username and password in the bottom `auth` section.
<details>
<summary>Optional: How to generate `snmp.yml`</summary>
The generator file can be found in `./synology/generator.yml`.
Create the `snmp.yml` exporter config:
1. Change `auth.username` and `auth.password` to match the Synology NAS
2. Make a temporary directory: `mkdir tmp && cd tmp`
3. Get the SNMP exporter repo: `git clone git@github.com:prometheus/snmp_exporter.git && cd snmp_exporter`
4. Copy the generator file: `cp ../../synology/generator.yml ./generator && cd generator` (yes override)
5. Prepare the MIB files: `make mibs`
6. Generate the `snmp.yml` file using Docker:
```bash
docker build -t snmp-generator .
sudo docker run -ti \
-v "${PWD}:/opt/" \
snmp-generator generate
```
7. If everything went well, a config file has been written to `./snmp.yml`
8. Copy this file into the Synology folder (next to the generator.yml): `cp ./snmp.yml ../../../synology/`
</details>
## Prepare Raspi
You need Ubuntu Server for ARM 64 bit in order to use this setup. You may also use Raspian, but then you are limited to 32bit ARM executables. This would mean, that you need to compile the `mikrotik-exporter` by hand, because there are no predefined 32-bit Docker images.

View file

@ -58,3 +58,13 @@ services:
networks:
- default
restart: unless-stopped
# SNMP Exporter
# https://github.com/prometheus/snmp_exporter
synology_snmp:
image: "prom/snmp-exporter"
restart: unless-stopped
ports:
- 9116:9116
volumes:
- ./synology/snmp.yml:/etc/snmp_exporter/snmp.yml

File diff suppressed because it is too large Load diff

View file

@ -29,3 +29,25 @@ scrape_configs:
static_configs:
- targets: ['mikrotik_exporter:9436', 'mktxp:49090']
# This job queries the Synology Exporter
- job_name: 'synology-snmp'
static_configs:
- targets:
- 192.168.0.114 # Actual IP of the Synology NAS
# Non default metrics path
# Full URL looks something like: http://<EXPORTER_IP>:9116/snmp?module=synology&target=<NAS_IP>
metrics_path: /snmp
params:
module: [synology] # Tell the exporter to use the synology module
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: synology_snmp:9116 # SNMP exporter's hostname:port.

89
synology/generator.yml Normal file
View file

@ -0,0 +1,89 @@
# Synology
#
# Synology MIBs can be found here:
# http://www.synology.com/support/snmp_mib.php
# http://dedl.synology.com/download/Document/MIBGuide/Synology_MIB_File.zip
#
# Tested on RS2414rp+ NAS
#
modules:
synology:
version: 3
auth:
username: monitoring
password: 333monitoring
auth_protocol: MD5
security_level: authNoPriv
walk:
- interfaces
- sysUpTime
- ifXTable
- laNames
- laLoadInt
- ssCpuUser
- ssCpuSystem
- ssCpuIdle
- memory
- hrStorage
- 1.3.6.1.4.1.6574.1 # synoSystem
- 1.3.6.1.4.1.6574.2 # synoDisk
- 1.3.6.1.4.1.6574.3 # synoRaid
- 1.3.6.1.4.1.6574.4 # synoUPS
- 1.3.6.1.4.1.6574.5 # synologyDiskSMART
- 1.3.6.1.4.1.6574.6 # synologyService
- 1.3.6.1.4.1.6574.101 # storageIO
- 1.3.6.1.4.1.6574.102 # spaceIO
- 1.3.6.1.4.1.6574.104 # synologyiSCSILUN
lookups:
- source_indexes: [spaceIOIndex]
lookup: spaceIODevice
drop_source_indexes: true
- source_indexes: [storageIOIndex]
lookup: storageIODevice
drop_source_indexes: true
- source_indexes: [serviceInfoIndex]
lookup: serviceName
drop_source_indexes: true
- source_indexes: [ifIndex]
# Use OID to avoid conflict with Netscaler NS-ROOT-MIB.
lookup: 1.3.6.1.2.1.31.1.1.1.1 # ifName
drop_source_indexes: true
- source_indexes: [diskIndex]
lookup: diskID
drop_source_indexes: true
- source_indexes: [raidIndex]
lookup: raidName
drop_source_indexes: true
- source_indexes: [laIndex]
lookup: laNames
drop_source_indexes: true
- source_indexes: [hrStorageIndex]
lookup: hrStorageDescr
drop_source_indexes: true
overrides:
diskModel:
type: DisplayString
diskSMARTAttrName:
type: DisplayString
diskSMARTAttrStatus:
type: DisplayString
diskSMARTInfoDevName:
type: DisplayString
diskType:
type: DisplayString
ifType:
type: EnumAsInfo
modelName:
type: DisplayString
raidFreeSize:
type: gauge
raidName:
type: DisplayString
raidTotalSize:
type: gauge
serialNumber:
type: DisplayString
serviceName:
type: DisplayString
version:
type: DisplayString

2755
synology/snmp.yml Normal file

File diff suppressed because it is too large Load diff