Search code examples
pythonzabbix

Python - Pyzabbix Output Format


I'm learning Python as i need to interact with Pyzabbix. So, in the following output i just needed the last field, but i cant find a way to do this:

**EXAMPLE_HOSTNAME

{u'triggerid': u'8119464', u'description': u'Agent Zabbix unreacheable for 1 minutes'}**

And the script is:

!/usr/bin/python -*- coding: iso-8859-1 -*- from pyzabbix import ZabbixAPI import sys,csv from url='http://xxx.xxx.xxx.xxx/zabbix' zh = ZabbixAPI(url) zh.login(user="Admin",password="XXXXXX") hostname = sys.argv[1] triggers = zh.trigger.get(filter={"host": [hostname]}, active="1", output=['description']) print hostname for a in triggers: print a

I appreciate any help. Thank you !


Solution

  • Description field:

    print a['description']