1

I'm trying to write a local python check which sends an XML request to a WSDL service and get the response as XML. The script works fine on the server (Ubuntu 18.04.2 LTS Server) and prints the results I want. But check_mk (installed on another server) doesn't read this output completely.

The server which I would like to run the script runs Python 2.7.15rc1 on Ubuntu 18.04.2 LTS but check_mk server runs Python 2.7.5 on CentOS Linux 7 (Core). Also, I've noticed that the same script works on check_mk server different than I expect. I should change the try-except block to make the script work on Check_MK server.

#!/usr/bin/python

import requests, base64, re

xml_file = 'request.xml'

hdr = {'Content-Type' : 'text/xml',
    'Authorization' : 'Basic somestring')
    }

with open(xml_file) as xml:
  req = requests.post('http://192.168.39.17:8080/GatewayWebservicesBean?wsdl', data=xml, headers=hdr)
  scode = req.status_code

try:
  resp = re.search(r'<message>(.*?)</message>', req.content).group(1)
except AttributeError:
  print '2 gw_check c=1;0;1;0 Cannot Access to Gateway! Status Code: %s' %scode       #Check_MK doesn't read this output
else:
  if resp == 'Access':
    print '0 eagw_check c=0;0;1;0 OK - Gateway works well'
  else:
    print '2 eagw_check c=1;0;1;0 Please check internal system! Respond from internal system: %s' %resp
4

2 に答える 2