Skip to content

Commit

Permalink
Fix command not found index metric collector
Browse files Browse the repository at this point in the history
  • Loading branch information
andersson1234 committed Sep 12, 2023
1 parent 3010b68 commit c57bdfb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions metrics/collectors/cnf/command_not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_cnf_ages_in_days(self):
data = []
for s in self.active_series:
url = URL.replace("release", s)
count = 0
count = None
try:
with urllib.request.urlopen(url) as fp:
bytes_resp = fp.read()
Expand All @@ -58,16 +58,17 @@ def get_cnf_ages_in_days(self):
date_str, "%Y-%m-%d %H:%M"
)
age = self.date_now - datetime_object
count = age.total_seconds()
count = age.total_seconds() / 86400
except urllib.error.HTTPError:
count = None
data.append(
{
"measurement": "command_not_found_age",
"fields": {"count": count},
"tags": {
"release": s
}
"fields": {
"cnf_age": count,
"out_of_date": ((count > 1) if count is not None else True),
},
"tags": {"release": s},
}
)
return data
Expand Down

0 comments on commit c57bdfb

Please sign in to comment.