Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion libpassiveagent/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ def run_check(c, pc, reschedule_and_post=True):
if reschedule_and_post:
schedule.reschedule(c, pc)
logging.info('run_check(): %s', c['passive checks'][pc]['command'].split())
res = subprocess.run(c['passive checks'][pc]['command'].split(), capture_output=True, text=True)
if sys.version_info[:3] > (3,7):
res = subprocess.run(c['passive checks'][pc]['command'].split(), capture_output=True, text=True)
else:
from subprocess import PIPE
res = subprocess.run(c['passive checks'][pc]['command'].split(), stdout=PIPE, stderr=PIPE)
stdout_str = res.stdout
res.stdout = stdout_str.decode("utf-8")
logging.info('run_check(): returncode: %s; stdout: %s', res.returncode, res.stdout.rstrip())
if reschedule_and_post:
post_results(c, pc, { "code": res.returncode, "stdout": res.stdout.rstrip() })
Expand Down Expand Up @@ -57,6 +63,8 @@ def post_results(c, pc, res):
r = requests.post(u, data=postdata, timeout=10)
except requests.Timeout:
logging.warning('Timeout posting results to %s', u)
except requests.exceptions.ConnectionError:
logging.warning('Connection Error posting results to %s', u)
else:
if r.status_code == requests.codes.ok:
logging.info('Submitted successfully to NRDP: %s', u)
Expand Down