Module: check_mk
Branch: master
Commit: f0a90fb04eac266f213ee72ad1ef6b39c59d3eae
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f0a90fb04eac26…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Mon May 6 09:22:12 2019 +0200
agent_azure: remove metric names count
* remove the count of metric names. This was left over
from when the metrics list was created automatically
* rename 'rid' to 'resource_id'
* add some comments, as the second block will becom longer
Change-Id: I7c4ec93dc48653ceb0199f29e8824f65e3212016
---
agents/special/agent_azure | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/agents/special/agent_azure b/agents/special/agent_azure
index a5912f1..a1d659a 100755
--- a/agents/special/agent_azure
+++ b/agents/special/agent_azure
@@ -68,6 +68,7 @@ METRICS_SELECTED = {
# to add a new metric, just add a made up name, run the
# agent, and you'll get a error listing available metrics!
# key: list of (name(s), interval, aggregation, filter)
+ # NB: Azure API won't have requests with more than 20 metric names at once
'Microsoft.Network/virtualNetworkGateways': [
('AverageBandwidth,P2SBandwidth', 'PT1M', 'average', None),
('P2SConnectionCount', 'PT1M', 'maximum', None),
@@ -572,10 +573,7 @@ class MetricsCollecter(object):
def _fetch_specific_metrics(self, monitor_client, metricnames, interval, aggregation, filter_,
err):
- if metricnames.count(',') >= 20:
- raise ValueError("Azure API won't have requests with more than 20 metrics!")
-
- rid = self.resource.info["id"]
+ resource_id = self.resource.info["id"]
start = self.NOW - 3 * self.timedeltas[interval]
timespan = "%s/%s" % (start.strftime("%Y-%m-%dT%H:%M:%SZ"),
@@ -585,7 +583,7 @@ class MetricsCollecter(object):
response, raw_metrics = self._metric_api_call(monitor_client, timespan, interval,
metricnames, aggregation, filter_)
except () if self.debug else ErrorResponseException as exc:
- err.add("exception", rid, exc.message)
+ err.add("exception", resource_id, exc.message)
LOG.exception(exc)
return []
@@ -597,7 +595,7 @@ class MetricsCollecter(object):
try:
metrics.append(create_metric_dict(raw_metric, aggregation, interval, filter_))
except AzureMetricParseError as exc:
- err.add(exc[0], rid, exc[1])
+ err.add(exc[0], resource_id, exc[1])
LOG.warning(exc.args[1])
return metrics
@@ -615,13 +613,21 @@ class MetricsCollecter(object):
def process_resource(args):
resource, client = args
+ #
+ # process the resource with all clients specific to the resource type
+ #
client.process_specific(resource)
+ #
+ # gather all metrics of the resource
+ #
err = IssueCollecter() # pass this to methods to collect issues
-
metrics_collecter = MetricsCollecter(resource, debug=client.args.debug)
metrics_collecter.collect_metrics(client.monitor_client, err)
+ #
+ # create all sections
+ #
agent_info_section = AzureSection('agent_info')
agent_info_section.add(('remaining-reads', metrics_collecter.remaining_reads))
agent_info_section.add(err.dumpinfo())
Module: check_mk
Branch: master
Commit: 6b146239b460c64e28143beb4808a25626ff7c94
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6b146239b460c6…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Mon May 6 07:35:24 2019 +0200
cmk.special_agents.utils: DataCache: allow more arguments
Change-Id: Iff729ae111d5e53619c01f7cfefdc997bff23290
---
cmk/special_agents/utils.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/cmk/special_agents/utils.py b/cmk/special_agents/utils.py
index 60febc6..b0e8ff3 100644
--- a/cmk/special_agents/utils.py
+++ b/cmk/special_agents/utils.py
@@ -127,14 +127,14 @@ class DataCache(object):
pass
@abc.abstractmethod
- def get_validity_from_args(self, args):
+ def get_validity_from_args(self, *args):
"""
Decide whether we need to update the cache due to new arguments
"""
pass
@abc.abstractmethod
- def get_live_data(self, args):
+ def get_live_data(self, *args):
"""
This is the function that will be called if no cached data can be found.
"""
@@ -187,8 +187,9 @@ class DataCache(object):
raise
return content
- def get_data(self, args, use_cache=True):
- if (use_cache and self.get_validity_from_args(args) and self._cache_is_valid()):
+ def get_data(self, *args, **kwargs):
+ use_cache = kwargs.pop('use_cache', True)
+ if (use_cache and self.get_validity_from_args(*args) and self._cache_is_valid()):
try:
return self.get_cached_data()
except (OSError, IOError, ValueError) as exc:
@@ -196,7 +197,7 @@ class DataCache(object):
if self.debug:
raise
- live_data = self.get_live_data(args)
+ live_data = self.get_live_data(*args)
if use_cache:
try:
self._write_to_cache(live_data)
Module: check_mk
Branch: master
Commit: 65f75562e1d113b29424e4d14337360ab80a0212
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=65f75562e1d113…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Mon May 6 16:44:52 2019 +0200
7476 FIX Allow shell interpreted characters in agent encryption phrase
Perviously the passphrase was not properly escaped, such that
characters with special meaning to the shell lead to unencrypted
agent data.
Change-Id: I996831ea8bab5ca91180d4b0f38e3545e9c3c125
---
.werks/7476 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/.werks/7476 b/.werks/7476
new file mode 100644
index 0000000..d513894
--- /dev/null
+++ b/.werks/7476
@@ -0,0 +1,12 @@
+Title: Allow shell interpreted characters in agent encryption phrase
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1557153675
+Class: fix
+
+Perviously the passphrase was not properly escaped, such that
+characters with special meaning to the shell lead to unencrypted
+agent data.