Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: give cnf data a measurement tag #26

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions metrics/collectors/cnf/command_not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def get_cnf_ages_in_days(self):
"""
metrics collecting function
"""
data = {}
data = []
for s in self.active_series:
data[s] = {}
url = URL.replace("release", s)
count = None
try:
with urllib.request.urlopen(url) as fp:
bytes_resp = fp.read()
Expand All @@ -58,10 +58,17 @@ def get_cnf_ages_in_days(self):
date_str, "%Y-%m-%d %H:%M"
)
age = self.date_now - datetime_object
age = age.total_seconds()
data[s]["age (days)"] = age / 86400
count = age.total_seconds() / 86400
except urllib.error.HTTPError:
data[s]["age (days)"] = None
count = None
continue
data.append(
{
"measurement": "command_not_found_age",
"fields": {"cnf_age": count, "out_of_date": (count > 1),},
"tags": {"release": s},
}
)
return data

def collect(self):
Expand Down