summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cb56b0b)
raw | patch | inline | side by side (parent: cb56b0b)
author | Sven Velt <sven@velt.de> | |
Tue, 27 Jul 2010 11:50:57 +0000 (13:50 +0200) | ||
committer | Sven Velt <sven@velt.de> | |
Tue, 27 Jul 2010 11:50:57 +0000 (13:50 +0200) |
The XML file is now read from STDIN (before: "nagixsc.xml") and output
shows human readable format ONLY. If you want a python list/dict, set
"-P" ("pprint") option at commandline.
Signed-off-by: Sven Velt <sven@velt.de>
shows human readable format ONLY. If you want a python list/dict, set
"-P" ("pprint") option at commandline.
Signed-off-by: Sven Velt <sven@velt.de>
nagixsc_read_xml.py | patch | blob | history |
diff --git a/nagixsc_read_xml.py b/nagixsc_read_xml.py
index 1cd436306e414f6141f6eb01af475be7823a1402..53bbf9b85ab4bcea416fd240e7d9bc9bff9ea28e 100755 (executable)
--- a/nagixsc_read_xml.py
+++ b/nagixsc_read_xml.py
parser.add_option('-f', '', dest='file', help='(Path and) file name of status file')
parser.add_option('-s', '', dest='seconds', type='int', help='Maximum age in seconds of xml timestamp')
parser.add_option('-m', '', action='store_true', dest='markold', help='Mark (Set state) of too old checks as UNKNOWN')
+parser.add_option('-P', '', action='store_true', dest='pprint', help='Output with Python\'s pprint')
parser.add_option('-v', '', action='count', dest='verb', help='Verbose output')
parser.set_defaults(url=None)
parser.set_defaults(httpuser=None)
parser.set_defaults(httppasswd=None)
-parser.set_defaults(file='nagixsc.xml')
+parser.set_defaults(file='-')
parser.set_defaults(seconds=14400)
parser.set_defaults(markold=False)
+parser.set_defaults(pprint=False)
parser.set_defaults(verb=0)
(options, args) = parser.parse_args()
checks = xml_to_dict(doc)
-# Loop over check results and output them
-for check in checks:
- check = check_mark_outdated(check, now, options.seconds, options.markold)
- print 'Host: %s\nService: %s\nRetCode: %s\nOutput: %r\nTimestamp: %s\n' % (check['host_name'], check['service_description'], check['returncode'], check['output'], check['timestamp'])
+if options.pprint:
+ # Print 'em all in one
+ import pprint
+ pprint.pprint(checks)
+else:
+ # Loop over check results and output them
+ for check in checks:
+ check = check_mark_outdated(check, now, options.seconds, options.markold)
+ print 'Host: %s\nService: %s\nRetCode: %s\nOutput: %r\nTimestamp: %s\n' % (check['host_name'], check['service_description'], check['returncode'], check['output'], check['timestamp'])
-import pprint
-pprint.pprint(checks)