Coder Social home page Coder Social logo

synology-nas-monitoring's Introduction

Synology NAS monitoring

Configuration files and tutorial on how to monitor your Synology NAS using SNMP, Telegraf, InfluxDB and Grafana.

Dashboard

Motivation

There are already few SNMP/Grafana monitoring solutions available. However, they are usually:

  • outdated
  • simply wrong (e.g. monitoring Docker's CPU & disk I/O instead of Synology NAS)
  • full of hard coded values
  • based on older InfluxDB 1 & InfluxQL

This Synology NAS monitoring uses InfluxDB 2 with Flux query language and the dashboard is configurable with virtually zero hard coded values.

Configuration

Enable SNMP service on Synology NAS. In DSM:

  • Control Panel -> Terminal & SMNP -> SNMP tab
  • Check Enable SNMP service
  • Check SNMPv1, SNMPv2c service
  • Community: public
  • Click [Apply]

Warning: this setting is not secure, especially if your NAS is exposed to the Internet. For more security, choose different Community (e.g. random string) or enable and configure SNMPv3 service. Note that if you change Community or enable SNMPv3 service, you have to make appropriate changes to the Telegraf configuration. Please, consult the documentation.

  • Install Docker
  • Download telegraf, influxdb and grafana/grafana images from the Docker registry
    • Download latest tag for all images
  • Copy telegraf and influxdb folders from this repository into the docker shared folder on the NAS

Create influxdb container

In Advanced Settings:

  • Advanced Settings
    • Check Enable auto-restart
  • Volume
    • Folder docker/influxdb/var/lib/influxdb2 -> /var/lib/influxdb2 (as read-write)
  • Network
    • Check Use the same network as Docker Host
  • Envorinment
    • DOCKER_INFLUXDB_INIT_MODE -> setup
    • DOCKER_INFLUXDB_INIT_USERNAME -> my-user
    • DOCKER_INFLUXDB_INIT_PASSWORD -> my-password
    • DOCKER_INFLUXDB_INIT_ORG -> NAS
    • DOCKER_INFLUXDB_INIT_BUCKET -> telegraf

InfluxDB should be now available at http://your-nas:8086/.

Create telegraf container

In Advanced Settings:

  • Advanced Settings
    • Check Enable auto-restart
  • Volume
    • File docker/telegraf/etc/telegraf/telegraf.conf -> /etc/telegraf/telegraf.conf (as read-only)
    • Folder docker/telegraf/mibs -> /mibs (as read-only)
  • Network
    • Check Use the same network as Docker Host

Before running the container:

  • Edit docker/telegraf/etc/telegraf/telegraf.conf appropriately
    • In [[outputs.influxdb_v2]], you must change urls & token (eventually organisation & bucket if you wish to change them)
      • InfluxDB token can be found on http://your-nas:8086/, in the Data menu (on the left), on the API Tokens tab, after clicking on my-user's Token
    • In each instance of [[inputs.snmp]], you must change agents (you can choose IP or hostname)
      • You can specify multiple agents if you wish to monitor multiple NAS devices

Create grafana container

In Advanced Settings:

  • Advanced Settings
    • Check Enable auto-restart
  • Network
    • Check Use the same network as Docker Host

Grafana should be now available at http://your-nas:3000/. Default credentials are admin:admin. After login, it will ask you for a new password.

After logging into Grafana web interface:

  • Go to Configuration -> Data sources
    • Add data source -> InfluxDB
    • Check Default
    • Query Language -> Flux
    • HTTP
      • URL -> http://your-nas:8086
    • Auth
      • Disable Basic auth
      • (Everything should be disabled in this group)
    • InfluxDB Details
      • Organization -> NAS (or whatever specified previously in DOCKER_INFLUXDB_INIT_ORG)
      • Token -> Your InfluxDB token (as described above)
      • Default Bucket -> telegraf
    • Click [Save & test]
  • Go to Create [+] -> Import (http://your-nas:3000/dashboard/import)
    • Click [Upload JSON file]
    • Select grafana/dashboard.json
    • Click [Import]

If not selected by default, choose appropriate Data source at the top.

License

Content of this repository - except the telegraf/mibs folder - is open-source under the MIT license. See the LICENSE.txt file in this repository.

telegraf/mibs folder contains following files:

If you find this project interesting, you can buy me a coffee

  BTC 3GwZMNGvLCZMi7mjL8K6iyj6qGbhkVMNMF
  LTC MQn5YC7bZd4KSsaj8snSg4TetmdKDkeCYk

synology-nas-monitoring's People

Contributors

rpawlik avatar wbenny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

synology-nas-monitoring's Issues

field corresponding to `path' is not defined in `*snmp.Snmp'

Hello,
I'm trying to get some data from my Synology to Telegraf with snmp into influxdb2. Now I have found your dashboard and its awesome. But when I start Telegraf, I got this message:

2022-04-07T21:32:23Z E! [telegraf] Error running agent: Error parsing /etc/telegraf/telegraf.conf, line 203: field corresponding to path' is not defined in *snmp.Snmp' | stdout

Before I had telegraf running without snmp which was working, but there are not as many metrics as in your dashboard.

How can I solve this issue?

Thank you for your help.

Stephan

Running on a custom bucket

Adding a ${bucket} to the dashboard and replacing v.defaultBucket with ${bucket:doublequote} everywhere

Dashboard not working

Hi, first the project looked promising, but I still have problems.
I do not know, if this is still supported, as found errors are not updated in the installation hints.
e.g.: docker/telegraf/mibs -> /mibs ==> docker/telegraf/mibs -> /usr/share/snmp/mibs
But perhaps another user may give me a hint.

I have a running environment with Grafana and InfluxDB2.
Influx seems to get some date from synology, but the dashboard gets no values.
I use an own DB (user, organization) with the bucket= Telegraf.
Do I have to change the dashboard example for my environment?
I am just starting with Grafana and InfluxDB2/Telegraf and wanted to use this as start.

any ideas?

no data collected

After telegraf was booted up he can't collect data - simply request timeouts
Ecample:
2022-04-19T11:40:30Z E! [inputs.snmp] Error in plugin: agent 192.168.178.22: performing get on field sysName: request timeout (after 3 retries) | stdout

do you or anybody else have the same issue with DSM7?
Seems to be something with snmp and DSM7

Getting Unauthorized Access 401

Not sure what I am doing wrong. I am getting unauthorized access error when trying to connect to influx. Here is the log output from docker.

2022-11-26T21:13:47Z I! Loaded outputs: influxdb
2022-11-26T21:13:47Z I! Loaded inputs: cpu disk diskio kernel mem processes swap system
2022-11-26T21:13:47Z I! Starting Telegraf 1.24.3
2022-11-26T21:13:47Z I! Available plugins: 221 inputs, 9 aggregators, 26 processors, 20 parsers, 57 outputs
2022-11-26T21:13:47Z I! Loaded aggregators:
2022-11-26T21:13:47Z I! Loaded processors:
2022-11-26T21:13:47Z I! Tags enabled: host=telegraf
2022-11-26T21:13:47Z W! [outputs.influxdb] When writing to [http://localhost:8086]: database "telegraf" creation failed: 401 Unauthorized
2022-11-26T21:13:47Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"telegraf", Flush Interval:10s
2022-11-26T21:13:57Z E! [outputs.influxdb] E! [outputs.influxdb] Failed to write metric (will be dropped: 401 Unauthorized):
2022-11-26T21:14:07Z E! [outputs.influxdb] E! [outputs.influxdb] Failed to write metric (will be dropped: 401 Unauthorized):
2022-11-26T21:14:17Z E! [outputs.influxdb] E! [outputs.influxdb] Failed to write metric (will be dropped: 401 Unauthorized):

Here is my config file.

image

I have tried creating different tokens but that doesn't work either. Any idea what I am doing wrong?

memory no data in grafana

Hello

There is something wrong when I import the grafana json file,it like below

memory view
image

physical memory view
image

Other views are working properly,I don`t know how to fix it, can you help me ,thank you

v3 Support

Thanks for providing the only really working repository so far lol.
Everything else was horribly outdated ...

for me I added support for snmp v3 by adding the following wherever agents were queued. Not elegant, but it works!

interval = "60s"
timeout = "10s"
retries = 3
version = 3
sec_name = "snmp_user"
auth_protocol = "SHA"
auth_password = "$(PASSWORD)"
sec_level = "authPriv"
context_name = ""
priv_protocol = "AES"
priv_password = "$(PASSWORD)"
max_repetitions = 30

Keep hitting an issue with 'Cannot find module (SNMPv2-MIB)'

I'm following the guide step by step, but having an issue where it's unable to find SNMPv2-MIB module

E! [telegraf] Error running agent: could not initialize input inputs.snmp: initializing field sysName: translating: MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf
Cannot find module (SNMPv2-MIB): At line 1 in (none) SNMPv2-MIB::sysName.0: Unknown Object Identifier: exit status 2

Is there anything missing from the guide? I setup influxdb, enabled SNMPv2 and modified the telegraf .conf as mentioned

Flux Query Failed errors

Hello,

I've setup influxdb and telegraf following the guide and that appears to work. I can log into influxdb and see data specific to my NAS. I already have a Grafana (same container the guide suggests though) container with other dashboards. When I import the dashboard, data does not populate and I get an error generated on the page. Looking at the logs in docker, there's a ton of error messages similar to this:

logger=tsdb.influx_flux t=2022-10-11T21:04:28.19280429Z level=warn msg="Flux query failed" err="invalid: compilation failed: error @5:43-5:44: invalid expression: invalid token for primary expression: RPAREN" query="from(bucket: \"telegraf\")\r\n |> range(start: 2022-10-11T20:34:27.998Z, stop: 2022-10-11T21:04:27.998Z)\r\n |> filter(fn: (r) => r[\"_measurement\"] == \"storageIOTable\")\r\n |> filter(fn: (r) => r[\"_field\"] == \"storageIONWrittenX\")\r\n |> filter(fn: (r) => r[\"agent_host\"] == )\r\n |> filter(fn: (r) => contains(value: r[\"storageIODevice\"], set: []))\r\n |> derivative()\r\n |> aggregateWindow(every: 1m, fn: mean)\r\n"

Any ideas why the dashboard might not be working? I verified the datasource is set to use "flux".

Thanks in advance!

telegraf not booting up

Hi
I tired your config but the telegraf container doesn't boot up

Here is the message from the log:
2022-04-19T11:12:36Z E! [telegraf] Error running agent: could not initialize input inputs.snmp: initializing field sysName:
translating: MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf
Cannot find module (SNMPv2-MIB): At line 1 in (none)

So I mapped my mibs folder to /usr/share/snmp/mibs and now the container is booting up.

Is that normal?

Only some UPS values are in Influxdb2

I added the UPS data into the telegraf.conf: added below
But only some values are sent to the DB. Also from these data not all contain usable values, but at least an entry is done.
in the comment I added the result: # ok = value in the DB // # err = no DB entry
Is the anybody, which can explain the error?

This is the Synology UPS mib information:
SYNOLOGY-UPS-MIB.txt

telegraf.conf:

[[inputs.snmp]]
    agents = ["udp://192.168.xxx.xxx:161"]
    path = ["/mibs"]

    name = "synoUPS"
# ok
    [[inputs.snmp.field]]
        name = "upsDeviceModel"
        oid = "SYNOLOGY-UPS-MIB::upsDeviceModel.0"
# ok
    [[inputs.snmp.field]]
        name = "upsDeviceManufacturer"
        oid = "SYNOLOGY-UPS-MIB::upsDeviceManufacturer.0"
# ok
    [[inputs.snmp.field]]
        name = "upsDeviceSerial"
        oid = "SYNOLOGY-UPS-MIB::upsDeviceSerial.0"
# ok
    [[inputs.snmp.field]]
        name = "upsDeviceType"
        oid = "SYNOLOGY-UPS-MIB::upsDeviceType.0"
# err
    [[inputs.snmp.field]]
        name = "upsDeviceDescription"
        oid = "SYNOLOGY-UPS-MIB::upsDeviceDescription.0"
# ok
    [[inputs.snmp.field]]
        name = "upsInfoStatus"
        oid = "SYNOLOGY-UPS-MIB::upsInfoStatus.0"
# err
    [[inputs.snmp.field]]
        name = "upsInfoAlarm"
        oid = "SYNOLOGY-UPS-MIB::upsInfoAlarm.0"
# err
    [[inputs.snmp.field]]
        name = "upsInfoDate"
        oid = "SYNOLOGY-UPS-MIB::upsInfoDate.0"
# ok
    [[inputs.snmp.field]]
        name = "upsInfoModel"
        oid = "SYNOLOGY-UPS-MIB::upsInfoModel.0"
# ok
    [[inputs.snmp.field]]
        name = "upsInfoSerial"
        oid = "SYNOLOGY-UPS-MIB::upsInfoSerial.0"
# err
    [[inputs.snmp.field]]
        name = "upsInfoTemperature"
        oid = "SYNOLOGY-UPS-MIB::upsInfoTemperature.0"
# ok
    [[inputs.snmp.field]]
        name = "upsInfoLoadValue"
        oid = "SYNOLOGY-UPS-MIB::upsInfoLoadValue.0"
# ok
    [[inputs.snmp.field]]
        name = "upsInfoDelayShutdown"
        oid = "SYNOLOGY-UPS-MIB::upsInfoDelayShutdown.0"
# err
    [[inputs.snmp.field]]
        name = "upsInfoEffciency"
        oid = "SYNOLOGY-UPS-MIB::upsInfoEffciency.0"
# err
    [[inputs.snmp.field]]
        name = "upsInfoPowerValue"
        oid = "SYNOLOGY-UPS-MIB::upsInfoPowerValue.0"
# err
    [[inputs.snmp.field]]
        name = "upsInfoRealPowerValue"
        oid = "SYNOLOGY-UPS-MIB::upsInfoRealPowerValue.0"
# ok
    [[inputs.snmp.field]]
        name = "upsBatteryChargeLow"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryChargeLow.0"
# ok
    [[inputs.snmp.field]]
        name = "upsBatteryChargeValue"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryChargeValue.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryChargeRestart"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryChargeRestart.0"
# err
    [[inputs.snmp.field]]
        name = "upsBatteryChargeWarning"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryChargeWarning.0"
# err
    [[inputs.snmp.field]]
        name = "upsBatteryVoltageValue"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryVoltageValue.0"
# err
    [[inputs.snmp.field]]
        name = "upsBatteryVoltageNominal"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryVoltageNominal.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryVoltageLow"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryVoltageLow.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryVoltageHigh"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryVoltageHigh.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryCapacity"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryCapacity.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryCurrent"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryCurrent.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryTemperature"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryTemperature.0"

# ok
    [[inputs.snmp.field]]
        name = "upsBatteryRuntimeValue"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryRuntimeValue.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryAlarmThreshold"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryAlarmThreshold.0"

# err
    [[inputs.snmp.field]]
        name = "upsBatteryDate"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryDate.0"

# ok
    [[inputs.snmp.field]]
        name = "upsBatteryType"
        oid = "SYNOLOGY-UPS-MIB::upsBatteryType.0"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.