python - Plugin in Nagios does not work when using paramiko? -
we're experiencing strange issues nagios. wrote script in python uses paramiko, httplib , re. when comment out code written use paramiko script returns ok in nagios. when uncomment script status returns (null).
this our code
ssh = paramiko.sshclient() ssh.set_missing_host_key_policy(paramiko.autoaddpolicy()) #ssh.connect(self.get('hostname'),int(self.get('port')),self.get('username'),allow_agent=true) ssh.connect('192.168.56.102' , 22 , 'oracle' ,allow_agent=true) link = '127.0.0.1:4848' stdin,stdout,stderr = ssh.exec_command('wget --no-proxy ' + link + ' 2>&1 | grep -i "failed\|error"') result = stdout.readlines() result = " ".join(result) if result == "": return monitoringresult(monitoringresult.ok,'webservice up') else: return monitoringresult(monitoringresult.critical,'webservice down %s' % result)
so when comment out part above
if result =="":
and add result="" above if, return 'webservice up' in nagios. when enable code above if return (null). there conflict paramiko or something?
when running code in terminal returns correct status doesn't show when implemented in nagios
i found although nagios runs effective user "nagios"
using environment settings user "root"
, not able read root private key make connection.
adding key_filename='/nagiosuserhomedir/.ssh/id_dsa'
options ssh.connect()
solved same problem me (pass private key nagios user explicitly in code).
Comments
Post a Comment