diff --git a/check_mk-azure/azure-spearhead-0.3.0.mkp b/check_mk-azure/azure-spearhead-0.3.0.mkp deleted file mode 100755 index 8d65f83..0000000 Binary files a/check_mk-azure/azure-spearhead-0.3.0.mkp and /dev/null differ diff --git a/check_mk-azure/azure-spearhead-0.4.0.mkp b/check_mk-azure/azure-spearhead-0.4.0.mkp new file mode 100755 index 0000000..9e94118 Binary files /dev/null and b/check_mk-azure/azure-spearhead-0.4.0.mkp differ diff --git a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_common b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_common index 60c662d..49c6f0e 100755 --- a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_common +++ b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_common @@ -147,6 +147,7 @@ def get_resource_group(obj): return None +resource_groups = {} command, tenant, username, password, proxy = get_args(sys.argv) token = get_token(tenant, username, password, proxy) @@ -161,11 +162,13 @@ for subscription in list_subscriptions(token, proxy): if not status in ['Active', 'InProgress']: continue - print_json({ + group = get_resource_group(alert) + + resource_groups.setdefault(group, []).append({ 'type': command, 'name': alert['name'], 'location': re.search(REGION_RE, alert['id'])[1], - 'resource_group': get_resource_group(alert), + 'resource_group': group, 'alert': { 'status': status, 'severity': properties['severity'], @@ -178,7 +181,9 @@ for subscription in list_subscriptions(token, proxy): elif command == 'firewall': for firewall in list_firewalls(token, proxy, subscription_id): metrics = get_recent_metrics(token, proxy, firewall['id'], FIREWALL_METRICS) - print_json({ + group = get_resource_group(firewall) + + resource_groups.setdefault(group, []).append({ 'type': command, 'name': firewall['name'], 'location': firewall['location'], @@ -189,10 +194,22 @@ for subscription in list_subscriptions(token, proxy): elif command == 'keyvault': for vault in list_vaults(token, proxy, subscription_id): metrics = get_recent_metrics(token, proxy, vault['id'], VAULT_METRICS) - print_json({ + group = get_resource_group(vault) + + resource_groups.setdefault(group, []).append({ 'type': command, 'name': vault['name'], 'location': vault['location'], - 'resource_group': get_resource_group(vault), + 'resource_group': group, 'metrics': metrics_to_lookup(metrics), }) + +for group, results in resource_groups.items(): + if group is None: + print(f"<<<<>>>>") + else: + print(f"<<<<{group}>>>>") + + print(f"<<>>") + for result in results: + print_json(result) diff --git a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_defender b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_defender index 57d7514..88c654f 100755 --- a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_defender +++ b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_defender @@ -1,6 +1,4 @@ #!/bin/bash -echo '<<>>' - dir=$(dirname -- "${BASH_SOURCE[0]}") "$dir"/agent_azure_common defender "$1" "$2" "$3" "$4" diff --git a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_firewall b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_firewall index 6091096..9f69ef0 100755 --- a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_firewall +++ b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_firewall @@ -1,6 +1,4 @@ #!/bin/bash -echo '<<>>' - dir=$(dirname -- "${BASH_SOURCE[0]}") "$dir"/agent_azure_common firewall "$1" "$2" "$3" "$4" diff --git a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_keyvault b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_keyvault index 65d9793..d0bba93 100755 --- a/check_mk-azure/local/share/check_mk/agents/special/agent_azure_keyvault +++ b/check_mk-azure/local/share/check_mk/agents/special/agent_azure_keyvault @@ -1,6 +1,4 @@ #!/bin/bash -echo '<<>>' - dir=$(dirname -- "${BASH_SOURCE[0]}") "$dir"/agent_azure_common keyvault "$1" "$2" "$3" "$4"