With this code I'm sending data to zabbix using trapper:
def zabbix_sender(key, output):
server = "1.2.2.4"
hostname = "host"
cmd = "zabbix_sender -z " + server + " -s " + hostname + " -k " + key +\
" -o \"" + output +"\""
print os.system(cmd)
It outputs this to the screen
info from server: "processed: 1; failed: 0; total: 1; seconds spent: 0.000041"
sent: 1; skipped: 0; total: 1
I need to output above to variable so, if failed: 1
I can create error handling.
Currently I'm getting 0 as output when calling this function:
r = zabbix_sender (key,"failed")
print r
output:0
Tried with subprocesses:
r=subprocess.check_output(zabbix_sender (key,"failed"),shell=False)
print r
TypeError:None object is not iterable