Code

Changed license to GPL-2+ (from GPL-2only).
[nagixsc.git] / nagixsc_live2xml.py
index 4702f95207361b548af9b0e1d3801d5ba97cd6ef..426d5259fb7d892aa54229fb4800ec1dd1fe28c7 100755 (executable)
@@ -1,4 +1,22 @@
 #!/usr/bin/python
+#
+# Nag(ix)SC -- nagixsc_live2xml.py
+#
+# Copyright (C) 2009-2010 Sven Velt <sv@teamix.net>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
 import optparse
 import sys
@@ -18,6 +36,7 @@ parser.add_option('-H', '', dest='host', help='Hostname/section to search for in
 parser.add_option('-D', '', dest='service', help='Service description to search for in config file (needs -H)')
 parser.add_option('-l', '', dest='httpuser', help='HTTP user name, if outfile is HTTP(S) URL')
 parser.add_option('-a', '', dest='httppasswd', help='HTTP password, if outfile is HTTP(S) URL')
+parser.add_option('-q', '', action='store_true', dest='quiet', help='Be quiet')
 parser.add_option('-v', '', action='count', dest='verb', help='Verbose output')
 
 parser.set_defaults(socket=None)
@@ -53,5 +72,7 @@ checks = livestatus2dict(s_opts, options.host, options.service)
 xmldoc = xml_from_dict(checks, options.encoding)
 
 # Output
-write_xml(xmldoc, options.outfile, options.httpuser, options.httppasswd)
+response = write_xml_or_die(xmldoc, options.outfile, options.httpuser, options.httppasswd)
+if response and not options.quiet:
+       print response