Skip to content

Commit

Permalink
opsviewreporter instantiated when necessary to retrieve logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sametd committed Dec 20, 2023
1 parent 7032e59 commit 4089bc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def __init__(self, *args, **kwargs):
self.critical_t = kwargs["critical_t"]
self.req_timeout = kwargs["req_timeout"]
self.metric_server_url = kwargs["metric_server_url"]
self.opsview_reporter = OpsviewReporter()
super().__init__(*args, **kwargs)

def metric(self):
Expand All @@ -209,13 +210,13 @@ def metric(self):

# fetch the cluster metrics
if self.metric_server_url:
metrics = OpsviewReporter.retrieve_metrics([self.metric_server_url], self.req_timeout)[
metrics = self.opsview_reporter.retrieve_metrics([self.metric_server_url], self.req_timeout)[
self.metric_server_url
]
if metrics:
logger.debug(f"Processing tlm {self.metric_name}...")

av_pod = OpsviewReporter.read_from_metrics(metrics, pattern)
av_pod = self.opsview_reporter.read_from_metrics(metrics, pattern)
if av_pod:
av_pod = int(av_pod)
if av_pod <= self.critical_t:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def __init__(self, *args, **kwargs):
self.critical_t = kwargs["critical_t"]
self.req_timeout = kwargs["req_timeout"]
self.metric_server_url = kwargs["metric_server_url"]
self.opsview_reporter = OpsviewReporter()
super().__init__(*args, **kwargs)

def metric(self):
Expand All @@ -190,13 +191,13 @@ def metric(self):

# fetch the cluster metrics
if self.metric_server_url:
metrics = OpsviewReporter.retrieve_metrics([self.metric_server_url], self.req_timeout)[
metrics = self.opsview_reporter.retrieve_metrics([self.metric_server_url], self.req_timeout)[
self.metric_server_url
]
if metrics:
logger.debug(f"Processing tlm {self.metric_name}...")

av_pod = OpsviewReporter.read_from_metrics(metrics, pattern)
av_pod = self.opsview_reporter.read_from_metrics(metrics, pattern)
if av_pod:
av_pod = int(av_pod)
if av_pod <= self.critical_t:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, config, *args, **kwargs):
self.req_timeout = self.etcd_config["req_timeout"]
self.member_urls = self.etcd_config["member_urls"]
self.tlms = self.etcd_config["tlms"]
self.opsview_reporter = OpsviewReporter()
super().__init__(config, *args, **kwargs)

def process_messages(self):
Expand All @@ -33,7 +34,7 @@ def process_messages(self):
logger.debug("Etcd processing metrics...")

# fetch the raw tlms provided by etcd
raw_tlms = OpsviewReporter.retrieve_metrics(self.member_urls, self.req_timeout) # noqa: F841
raw_tlms = self.opsview_reporter.retrieve_metrics(self.member_urls, self.req_timeout) # noqa: F841

# array of metric to return
metrics = []
Expand Down

0 comments on commit 4089bc2

Please sign in to comment.