summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/inventory/nagios_livestatus.py11
-rwxr-xr-xcontrib/inventory/nagios_ndo.py10
2 files changed, 9 insertions, 12 deletions
diff --git a/contrib/inventory/nagios_livestatus.py b/contrib/inventory/nagios_livestatus.py
index 9aaf0d9fc2..91c72dac60 100755
--- a/contrib/inventory/nagios_livestatus.py
+++ b/contrib/inventory/nagios_livestatus.py
@@ -34,6 +34,8 @@ Livestatus API: http://www.naemon.org/documentation/usersguide/livestatus.html
import os
import re
import argparse
+import sys
+
try:
import configparser
except ImportError:
@@ -44,8 +46,7 @@ import json
try:
from mk_livestatus import Socket
except ImportError:
- print("Error: mk_livestatus is needed. Try something like: pip install python-mk-livestatus")
- exit(1)
+ sys.exit("Error: mk_livestatus is needed. Try something like: pip install python-mk-livestatus")
class NagiosLivestatusInventory(object):
@@ -160,8 +161,7 @@ class NagiosLivestatusInventory(object):
self.json_indent = 2
if len(self.backends) == 0:
- print("Error: Livestatus configuration is missing. See nagios_livestatus.ini.")
- exit(1)
+ sys.exit("Error: Livestatus configuration is missing. See nagios_livestatus.ini.")
for backend in self.backends:
self.query_backend(backend, self.options.host)
@@ -171,7 +171,6 @@ class NagiosLivestatusInventory(object):
elif self.options.list:
print(json.dumps(self.result, indent=self.json_indent))
else:
- print("usage: --list or --host HOSTNAME [--pretty]")
- exit(1)
+ sys.exit("usage: --list or --host HOSTNAME [--pretty]")
NagiosLivestatusInventory()
diff --git a/contrib/inventory/nagios_ndo.py b/contrib/inventory/nagios_ndo.py
index cae142d289..e5377119c7 100755
--- a/contrib/inventory/nagios_ndo.py
+++ b/contrib/inventory/nagios_ndo.py
@@ -28,6 +28,7 @@ Configuration is read from `nagios_ndo.ini`.
import os
import argparse
+import sys
try:
import configparser
except ImportError:
@@ -39,8 +40,7 @@ try:
from sqlalchemy import text
from sqlalchemy.engine import create_engine
except ImportError:
- print("Error: SQLAlchemy is needed. Try something like: pip install sqlalchemy")
- exit(1)
+ sys.exit("Error: SQLAlchemy is needed. Try something like: pip install sqlalchemy")
class NagiosNDOInventory(object):
@@ -101,10 +101,8 @@ class NagiosNDOInventory(object):
elif self.options.list:
print(json.dumps(self.result))
else:
- print("usage: --list or --host HOSTNAME")
- exit(1)
+ sys.exit("usage: --list or --host HOSTNAME")
else:
- print("Error: Database configuration is missing. See nagios_ndo.ini.")
- exit(1)
+ sys.exit("Error: Database configuration is missing. See nagios_ndo.ini.")
NagiosNDOInventory()