Coder Social home page Coder Social logo

wernerfred / check_synology Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 25.0 82 KB

This plugin will check a lot of different values on your Synology DiskStation.

License: MIT License

Python 100.00%
icinga2 icinga2-plugin monitoring-plugin nagios synology snmpv3 python3 synology-diskstation

check_synology's Introduction

Hi ๐Ÿ‘‹, I'm Frederic

Mainly building stuff with containers

๐Ÿ”ญ Iโ€™m currently working on relink (private) and a terraform library wernerfred
๐ŸŒฑ Iโ€™m currently learning k8s
๐Ÿ‘ฏ Iโ€™m collaborating on docker-mailserver
๐Ÿค Iโ€™m looking for help with docker-dyndns
๐Ÿ‘จโ€๐Ÿ’ป All of my projects are available at https://github.com/wernerfred
๐Ÿ’ฌ Ask me about Docker, Ansible, Git and GitHub Actions

check_synology's People

Contributors

allcontributors[bot] avatar amotl avatar bigitag avatar byolock avatar cycloon avatar dommi22m avatar doomas avatar dropthemic avatar fibberblank avatar jebabin avatar kreativekrise avatar p-try avatar to-kn avatar wernerfred avatar

Stargazers

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

Watchers

 avatar  avatar

check_synology's Issues

Install on a container drops with errors: ERROR: For req: check-synology==1.0.0.

Hello,

I want to add the check on a container, based on Icinga/icinga2 image with something like this:

  • Dockerfile
FROM icinga/icinga2
ENV DEBIAN_FRONTEND=noninteractive
USER root
...
RUN apt install libcrypt-des-perl libdigest-hmac-perl python3 python3-pip netbase git -y
RUN pip install git+https://github.com/wernerfred/check_synology

but if gives me:

...
Building wheels for collected packages: check-synology
  Building wheel for check-synology (setup.py): started
  Building wheel for check-synology (setup.py): finished with status 'done'
  Created wheel for check-synology: filename=check_synology-1.0.0-py3-none-any.whl size=8176 sha256=f2f1cf3d04bd4484081d705530aed3cb0a0188667e1fca7fe46793d881267fd2
  Stored in directory: /tmp/pip-ephem-wheel-cache-nfvqtxp6/wheels/9e/5c/da/0bc31cf4a7ae73363ff391329abd3040ee651168e9307ddaa3
Successfully built check-synology
Installing collected packages: easysnmp, check-synology
ERROR: For req: check-synology==1.0.0. Invalid script entry point: <ExportEntry check_synology = check_synology:None []> - A callable suffix is required. Cf https://packaging.python.org/specifications/entry-points/#use-for-scripts for more information.
The command '/bin/sh -c pip install git+https://github.com/wernerfred/check_synology' returned a non-zero code: 1
...

it seems, that .. If I do this on an interactive shell .. the command itself works:

root@home:/# chmod +x  /usr/local/lib/python3.9/dist-packages/check_synology.py
root@home:/#   /usr/local/lib/python3.9/dist-packages/check_synology.py
usage: check_synology.py [-h] [-w W] [-c C] [-p PORT] [-t T] [-r R] hostname username authkey privkey {load,memory,disk,storage,update,status}
check_synology.py: error: the following arguments are required: hostname, username, authkey, privkey, mode

also, if I try to install v0.3.1

root@home:/# pip install git+https://github.com/wernerfred/[email protected]
Collecting git+https://github.com/wernerfred/[email protected]
  Cloning https://github.com/wernerfred/check_synology.git (to revision v0.3.1) to /tmp/pip-req-build-lyo9y90o
  Running command git clone -q https://github.com/wernerfred/check_synology.git /tmp/pip-req-build-lyo9y90o
  Running command git checkout -q 888097f25519f460d50b2a099d0e2a04827be527
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-lyo9y90o/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-lyo9y90o/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-hdyion9b
         cwd: /tmp/pip-req-build-lyo9y90o/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.9/tokenize.py", line 392, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-lyo9y90o/setup.py'
    ----------------------------------------
WARNING: Discarding git+https://github.com/wernerfred/[email protected]. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

is there maybe something, I miss ?

cu denny

Bring back option to configure target SNMP port

Hi,

A custom port can be specified by using -p. The default value is 161.

I just discovered that the refactoring coming from #4/#19 dropped that feature to specify the target SNMP port number (#2), so we will have to bring it back when there is demand.

Also, after integrating #21, the Icinga configuration snippets will provide access to almost all parameters this program has to offer. However, the -p option is still missing there. Also depending on community demand, this can be added every time.

With kind regards,
Andreas.

Storage check throws 'NOSUCHINSTANCE'

Hello,
First, thank you for this great check script. I am using it on the models DS918+ and DS920+.

The storage check did not work for me and gave me following error:
File "./check_synology", line 202, in <module> storage_size = int((int(allocation_units) * int(size)) / 1000000000) ValueError: invalid literal for int() with base 10: 'NOSUCHINSTANCE'

this is because we get an invalid or more over-useless value for oid in line 193.

i = item.oid.split('.')[-1]

So it simply needs to be changed to:
i = item.oid_index.split('.')[-1]

I hope this can help somebody else.

pkg_resources is deprecated as an API

The script uses the following code to check the version of pywbem:

# pywbem 0.7.0 handling is special, some patched 0.7.0 installations work differently
try:
  pywbemversion = pywbem.__version__
except:
  pywbemversion = pkg_resources.get_distribution("pywbem").version
else:
  pywbemversion = pywbem.__version__
verboseoutput("Found pywbem version "+pywbemversion)

A deprecation warning appears:
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

Zero Division Error with mode Storage & Docker Container Volumes

I have got a ZeroDivisionError with the storage check :
File "/etc/icinga2/scripts/check_synology.py", line 149, in <module> storage_used_percent = int(storage_used * 100 / storage_size) ZeroDivisionError: integer division or modulo by zero

I was able to trace it back to the following volume :
STRING: "/volume2/@docker/containers/782c5829828d901c73d57e223e84300ea4f95bf0005024912aea33de85e618f7/mounts/shm"
So its apparently some kind of docker configuration which is able to create a volume with size 0.
Disabling checks for Volumes with storage_size 0 would be an easy fix i guess? I don't know python but i will try to implement a fix myself when i got some spare time. If anybody else would provide a fix, that would be much appreciated.

SystemError: returned NULL without setting an error

Hi again,

with the refactoring coming from #4/#19, we might need to adjust some bits on certain error conditions.

We spotted this outcome yesterday night and wanted to share it here in order to get back to it within one of the next development iterations.

While we haven't investigated into the details about the root cause of this condition yet, I imagine it could be related to network timeouts (see also #17).

Traceback (most recent call last):
  File "/opt/check_synology_easysnmp/check_synology.py", line 186, in <module>
    for item in snmpwalk('1.3.6.1.2.1.25.2.3.1.3'):
  File "/opt/check_synology_easysnmp/check_synology.py", line 61, in snmpwalk 
    res = session.walk(oid) 
  File "/opt/check_synology/.venv/lib/python3.9/site-packages/easysnmp/session.py", line 467, in walk 
    interface.walk(self, varlist)
SystemError: <built-in function walk> returned NULL without setting an error

With kind regards,
Andreas.

image

Support for Python3

Python 2 was sunsetted on January 1st, 2020 and it gets more and more difficult to run it on modern systems, so having this plugin ported to Python 3 would be great. Thanks for considering!

Disk health status is not evaluated

I have a Synology NAS here with a failed disk and a degraded RAID, yet the script tells me everything is fine. I will add a pull request to introduce support for the 'disk health' value. Currently, only 'disk status' is evaluated which only refers to partitioning of the disk but not to its health.

Where do authkey privkey come from?

Hello wernerfred,

how do I get the authkey privkey for running the script. It was not explained where they come from.

So, please give me a hint.

Thanks in advance,
Chris

Connect to different Port

Hi,
can you please add the option to connect to a different port than 161?
That seems to be not possible for now.
Thank you!

Getting "Wrong SNMP PDU digest" when executing a check

Hello there,

as the captions mentions, I receive an error when executing any check against a Synology NAS (7.0.1-42218 Update 2).
On the other hand nwc_health gets a valid response with the same credentials.

wrong_pdu

Am I doing something wrong? Or ist this a bug?

Thanks for reply

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.