Hi
I have a fairly basic local check written in python and while it prints the correct output (I believe) Check_Mk is not picking up the output correctly. I have
done a re-inventory several times, restarted Check_MK and made sure the script is executable and other checks.
Check_MK CEE 1.2.8p26 shows this output when I run:
#> cmk -d VSSOLUTIONS | grep –C1 mrpe
<<>>
(check_pdn.py) PDN_STATUS 127
But when I run the check with check_mk_agent on the host I get:
<<>>
(check_pdn.py) PDN_STATUS 0 0 PDN_STATUS - OK - Normal Parameters
Running the script manually I get:
0 PDN_STATUS - OK - Normal Parameters
Just trying to figure out where the discrepancy is.
Only 1 line in /etc/check_mk/mrpe.cfg:
PDN_STATUS /root/scripts/python/nagios-checks/check_pdn.py
Any help appreciated,
Rgds
Paraic
···
Full Script:
#!/opt/rh/rh-python34/root/usr/bin/python3.4
‘’’
this file is the backend for a Check_Mk script to check the PDN_Status.txt file
‘’’
import os
from datetime import datetime
Set the time to report the current hour
timenow=datetime.now().strftime(’%H’)
set the date to today’s date
datestr=datetime.now().strftime(’%d/%m/%Y’)
Initialise the two strings we will use
newlist = []
list1=[]
This is the file that CT Solutions use to check the status of the lines
PDN_FILE="/mnt/koteleq4u/PDN_Status.txt"
read the file into a lines string
with open(PDN_FILE) as file1:
lines = file1.readlines()
Split into columns and check Col 4 to see if it registers 0 which means it’s available and not in error state
then append the available lines into the string newlist
for line in lines[1:] :
columns = line.split()
if columns[4] == ‘0’:
newlist.append(columns[:])
iterate thru the newlist and pick the ones that are on today’s date and select the column with the time and then select the digits and add the strings to
make the hour
for item in newlist :
if item[2] == datestr :
str1=item[3][0]
str2=item[3][1]
str3=str1+str2
list1.append(str3)
check the difference in hours between now and the latest hour represented in the status file
timehour=int(max(list1))
if the time in the file is greater than two hours old, output a ‘2’ which is a CRIT for Nagios, otherwise a ‘0’ which is an OK, alonmg with some other info
for the check
if timehour > int(timenow) - 2 :
print(“0”,“PDN_STATUS”,"-",“OK - Normal Parameters”)
else:
print(“2”,“PDN_Status”,"-", “CRIT - No Dialup in the last 2 hours!”)