Custom script output not recognized

CMK version:2.1.0p14
OS version: Ubuntu 18.04

Error message: Custom check status not changing always OK

I have created the script below to check the available space in my vcenter appliance. I created the files and tested they run using the correct account, the status will not change to CRTITICAL… I have installed the check as a rule in Integrate Nagios plugins using the config as in the screenshot. The output shows as if it is not get processed by check_mk. (screenshot attached). This is the first check I created using python.

get_space.py

import subprocess

overquota = []
multiline = ''
cmd = ["bash", "/opt/omd/sites/mysite/custom/vcenter/get_data.sh"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
for line in proc.stdout:
   data = line.decode("utf-8")
   if '/' in data:
       columns = (data.replace("%","")).split()
       if int(columns[4]) > 5:
           overquota.append("Mountpoint " + columns[5] + " is " + columns[4] + "% full")
if len(overquota) > 0:
   for i in range(len(overquota)):
       multiline = multiline + ('\n' + overquota[i])
   print('2 vcenter_space count='+ str(len(overquota)) + ';1;2 Server free space error! ' + multiline)
else:
   print('0 vcenter_space count=0;1;2 Server free space normal.')

get_data.sh

#!/bin/bash
ssh -q root@10.22.33.44 'df -h'


For anybody with the same newbee question I found it…

import subprocess, sys

overquota = []
multiline = ''
cmd = ["bash", "/opt/omd/sites/mysite/custom/vcenter/get_data.sh"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
for line in proc.stdout:
    data = line.decode("utf-8")
    if '/' in data:
        columns = (data.replace("%","")).split()
        if int(columns[4]) > 80:
            overquota.append("Mountpoint " + columns[5] + " is " + columns[4] + "% full")
if len(overquota) > 0:
    for i in range(len(overquota)):
        multiline = multiline + ('\n' + overquota[i])
    print('Server free space error! ' + multiline)
    sys.exit(2)
else:
    print('Server free space normal.')
    sys.exit(0)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.