edir-version.py 950 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/python
  2. #
  3. # (c) Michael Honkoop <mhonkoop@comsolve.nl>
  4. # License: GNU General Public License v2
  5. # Version 0.1
  6. # - Initial release
  7. # A similar check is available in this repository written in bash (edir-version.sh)
  8. #
  9. # This check should be placed in /usr/lib/check_mk_agent/local and made executable with `chmod +x edir-version.py`
  10. # The script assumes that you have exported the environment variables when installing eDirectory, if not it will fail/not get detected on discovery.
  11. import subprocess
  12. # The process to be executed
  13. myexec = "ndsd"
  14. # Attempt to execute the process, if successful output CheckMK formatted data, if not return nothing.
  15. try:
  16. output = subprocess.check_output([myexec, "--version"])
  17. output_arr = output.split(' ')
  18. print("0 \"" + output_arr[1] + "\" - Binary Version: " + output_arr[2] + ", DS Version: " + output_arr[3])
  19. except subprocess.CalledProcessError as e:
  20. print("3 \"" + e)
  21. exit()