diff --git a/IRST_mon.py b/IRST_mon.py index cdaafe2..3b12987 100755 --- a/IRST_mon.py +++ b/IRST_mon.py @@ -12,10 +12,18 @@ server = '192.168.1.56' def exec(exe): result = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - return result.communicate()[0].decode('utf-8') + try: + ret = result.communicate()[0].decode('utf-8') + except Exception: + return False + else: + return ret def discovery(txt): + if not txt: + print('ERROR') + exit(1) array = 0 volume = 0 data = {'data': []} @@ -47,6 +55,9 @@ def discovery(txt): def sender(txt): + if not txt: + print(1) + exit(1) array = 0 arraysec = False volume = 0 @@ -147,7 +158,13 @@ def sender(txt): line.split(":")[1].strip())) zbx = ZabbixSender(server) - zbx.send(packet) + try: + zbx.send(packet) + except Exception: + print(1) + else: + print(0) + def args(): if len(sys.argv) > 2: