Skip to content

Instantly share code, notes, and snippets.

@asraful
Created November 14, 2016 09:32
Show Gist options
  • Save asraful/56b2f3aa1eeb0929b2e0241dde357e37 to your computer and use it in GitHub Desktop.
Save asraful/56b2f3aa1eeb0929b2e0241dde357e37 to your computer and use it in GitHub Desktop.
def logIN():
from zabbix_client import ZabbixServerProxy
request = ZabbixServerProxy('http://192.168.70.172/zabbix')
request.user.login(user='admin', password='zabbix')
data = request.host.get(output=['hostid', 'host'])
request.user.logout()
return data;
def writer(output_data):
import json
try:
with open('data.txt', 'w') as outfile:
json.dump(output_data, outfile)
except IOError:
print ("Error: can\'t write data")
else:
print ("Written content in the file successfully")
def execute():
data = logIN()
writer(data)
execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment