Commit 269ceada by René Moser

zabbix inventory: print errors to stderr

parent a563ea13
...@@ -38,7 +38,7 @@ import ConfigParser ...@@ -38,7 +38,7 @@ import ConfigParser
try: try:
from zabbix_api import ZabbixAPI from zabbix_api import ZabbixAPI
except: except:
print "Error: Zabbix API library must be installed: pip install zabbix-api." print >> sys.stderr, "Error: Zabbix API library must be installed: pip install zabbix-api."
sys.exit(1) sys.exit(1)
try: try:
...@@ -111,7 +111,7 @@ class ZabbixInventory(object): ...@@ -111,7 +111,7 @@ class ZabbixInventory(object):
api = ZabbixAPI(server=self.zabbix_server) api = ZabbixAPI(server=self.zabbix_server)
api.login(user=self.zabbix_username, password=self.zabbix_password) api.login(user=self.zabbix_username, password=self.zabbix_password)
except BaseException, e: except BaseException, e:
print "Error: Could not login to Zabbix server. Check your zabbix.ini." print >> sys.stderr, "Error: Could not login to Zabbix server. Check your zabbix.ini."
sys.exit(1) sys.exit(1)
if self.options.host: if self.options.host:
...@@ -123,11 +123,11 @@ class ZabbixInventory(object): ...@@ -123,11 +123,11 @@ class ZabbixInventory(object):
print json.dumps(data, indent=2) print json.dumps(data, indent=2)
else: else:
print "usage: --list ..OR.. --host <hostname>" print >> sys.stderr, "usage: --list ..OR.. --host <hostname>"
sys.exit(1) sys.exit(1)
else: else:
print "Error: Configuration of server and credentials are required. See zabbix.ini." print >> sys.stderr, "Error: Configuration of server and credentials are required. See zabbix.ini."
sys.exit(1) sys.exit(1)
ZabbixInventory() ZabbixInventory()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment