Module: check_mk
Branch: master
Commit: 973bc99d6412a7c2c43fbd4548a89c1b9297e124
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=973bc99d6412a7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jan 28 14:40:24 2015 +0100
Implement new option --cap
---
modules/check_mk.py | 17 ++++++++++++-----
modules/check_mk_base.py | 7 +++++--
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 2a8d31c..069e820 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -253,7 +253,7 @@ config_variable_names = set.difference(set(vars().keys()) -
known_vars)
# at check time (and many of what is also needed at administration time).
try:
- modules = [ 'check_mk_base', 'discovery', 'snmp',
'notify', 'prediction', 'cmc', 'inline_snmp',
'agent_bakery' ]
+ modules = [ 'check_mk_base', 'discovery', 'snmp',
'notify', 'prediction', 'cmc', 'inline_snmp',
'agent_bakery', 'cap' ]
for module in modules:
filename = modules_dir + "/" + module + ".py"
if os.path.exists(filename):
@@ -4212,6 +4212,7 @@ def usage():
cmk -i, --inventory [HOST1 HOST2...] Do a HW/SW-Inventory of some ar all hosts
cmk --inventory-as-check HOST Do HW/SW-Inventory, behave like check plugin
cmk -A, --bake-agents [-f] [H1 H2..] Bake agents for hosts (not in all versions)
+ cmk --cap pack|unpack|list FILE.cap Pack/unpack agent packages (not in all versions)
cmk --show-snmp-stats Analyzes recorded Inline SNMP statistics
cmk -V, --version print version
cmk -h, --help print this help
@@ -5447,11 +5448,11 @@ long_options = [ "help", "version",
"verbose", "compile", "debug", "interactive"
"man", "nowiki", "config-check",
"backup=", "restore=",
"check-inventory=", "check-discovery=",
"paths",
"checks=", "inventory",
"inventory-as-check=", "hw-changes=", "sw-changes=",
- "cmc-file=", "browse-man", "list-man",
"update-dns-cache" ]
+ "cmc-file=", "browse-man", "list-man",
"update-dns-cache", "cap" ]
non_config_options = ['-L', '--list-checks', '-P',
'--package', '-M', '--notify',
'--man', '-V', '--version' ,'-h',
'--help', '--automation',
- '--create-rrd', '--convert-rrds',
'--keepalive' ]
+ '--create-rrd', '--convert-rrds',
'--keepalive', '--cap' ]
try:
opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
@@ -5669,14 +5670,20 @@ try:
done = True
elif o in [ '-A', '--bake-agents' ]:
if 'do_bake_agents' not in globals():
- sys.stderr.write("Agent baking is not implemented in your version of
Check_MK. Sorry.\n")
- sys.exit(1)
+ bail_out("Agent baking is not implemented in your version of
Check_MK. Sorry.")
if args:
hostnames = parse_hostname_list(args, with_clusters = False)
else:
hostnames = None
do_bake_agents(hostnames)
done = True
+
+ elif o == '--cap':
+ if 'do_cap' not in globals():
+ bail_out("Agent packages are not supported by your version of
Check_MK.")
+ do_cap(args)
+ done = True
+
elif o in [ '--show-snmp-stats' ]:
if 'do_show_snmp_stats' not in globals():
sys.stderr.write("Handling of SNMP statistics is not implemented in
your version of Check_MK. Sorry.\n")
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 9071f29..0ea9407 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -139,8 +139,11 @@ else:
# Output text if opt_verbose is set (-v). Adds no linefeed
def verbose(text):
if opt_verbose:
- sys.stdout.write(text)
- sys.stdout.flush()
+ try:
+ sys.stdout.write(text)
+ sys.stdout.flush()
+ except:
+ pass # avoid exception on broken pipe (e.g. due to | head)
# Output text if, opt_verbose >= 2 (-vv).
def vverbose(text):