Module: check_mk
Branch: master
Commit: 301a242b39793625e3b0ec19f8318f7e0f7f8a34
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=301a242b397936…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri Nov 23 14:53:25 2018 +0100
various minor azure fixes
Change-Id: I12bbef3e35d75a047f077f7117286d458c20aa3a
---
agents/special/agent_azure | 9 ++++-----
checks/azure_agent_info | 38 ++++++++++++++++++++++++++------------
2 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/agents/special/agent_azure b/agents/special/agent_azure
index b0ea323..25bcf03 100755
--- a/agents/special/agent_azure
+++ b/agents/special/agent_azure
@@ -142,11 +142,10 @@ def parse_arguments(argv):
parser.add_argument(
"--dump-config", action="store_true",
help='''Dump parsed configuration and exit''')
parser.add_argument(
- "--pjoin-timeout",
+ "--timeout",
default=10,
type=int,
- help='''Timeout for process joining in seconds
- (default 10)''')
+ help='''Timeout for individual processes in seconds (default
10)''')
parser.add_argument(
"--piggyback-vms",
default="",
@@ -664,9 +663,9 @@ def main(argv=None):
write_groups(resources)
- args = ((resource, client, config) for resource in resources)
+ func_args = ((resource, client, config) for resource in resources)
map_ = map if args.sequential else AsyncMapper(args.timeout, args.debug)
- for sections in map_(process_resource, args):
+ for sections in map_(process_resource, func_args):
for section in sections:
section.write()
diff --git a/checks/azure_agent_info b/checks/azure_agent_info
index ff0ce2a..dc948d5 100644
--- a/checks/azure_agent_info
+++ b/checks/azure_agent_info
@@ -33,27 +33,41 @@ factory_settings['azure_agent_info_levels'] = {
}
+def _update_remaining_reads(parsed, value):
+ try:
+ value = int(value)
+ except ValueError:
+ pass
+
+ current = parsed.get('remaining-reads', '_some_string')
+ if isinstance(current, str):
+ parsed['remaining-reads'] = value
+ return
+ parsed['remaining-reads'] = min(current, value)
+
+
def parse_azure_agent_info(info):
parsed = {}
for row in info:
- k, v = row[0], json.loads(_AZURE_AGENT_SEPARATOR.join(row[1:]))
-
- if k == 'remaining-reads':
- try:
- v = int(v)
- v = min(int(parsed.get(k, 'fail')), v)
- except ValueError:
- pass
- parsed[k] = v
+ key = row[0]
+ value = _AZURE_AGENT_SEPARATOR.join(row[1:])
+
+ if key == 'remaining-reads':
+ _update_remaining_reads(parsed, value)
continue
- elif k == 'issue':
+ try:
+ value = json.loads(value)
+ except ValueError:
+ pass
+
+ if key == 'issue':
issues = parsed.setdefault('issues', {})
- issues.setdefault(v['type'], []).append(v)
+ issues.setdefault(value['type'], []).append(value)
continue
- parsed.setdefault(k, []).append(v)
+ parsed.setdefault(key, []).append(value)
return parsed