remote icinga: do not log (for now) + fix sending unquoted string
This commit is contained in:
parent
4c3b7612e0
commit
0a97ea78ce
@ -4,13 +4,14 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shlex
|
||||
from icinga_host_notify import assemble_sms
|
||||
import sms_functions
|
||||
|
||||
def main():
|
||||
sms_msg = assemble_sms()
|
||||
sms_number = os.environ.get('USERMOBILE')
|
||||
logger.info("Remote - Sending SMS to %s: %s", sms_number, sms_msg)
|
||||
# logger.info("Remote - Sending SMS to %s: %s", sms_number, sms_msg)
|
||||
|
||||
hostname = sys.argv[1]
|
||||
|
||||
@ -21,6 +22,9 @@ def main():
|
||||
while not success and retries < max_retries:
|
||||
retries += 1
|
||||
try:
|
||||
# Escape message and number for remote shell
|
||||
sms_msg = shlex.quote(sms_msg)
|
||||
sms_number = shlex.quote(sms_number)
|
||||
# Contact remote host
|
||||
subprocess.run([ '/usr/bin/ssh', hostname, '/opt/sms/send_sms.py', sms_msg, sms_number ], check=True)
|
||||
except:
|
||||
|
Loading…
Reference in New Issue
Block a user