From 293815afb74c3ce1d8d97179a099fa672d3037fd Mon Sep 17 00:00:00 2001 From: Mikhail Grebenkin Date: Fri, 27 Apr 2018 11:57:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRST_mon.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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: