Skip to content

Commit

Permalink
Add support for multiple origins per packet (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
margau authored Jan 14, 2022
1 parent a573a65 commit d1b17a7
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/pkg_exporter/pkgmanager/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ def query(self):
selected_package = self.cache[package_name]
if not selected_package.is_installed:
continue
origin = selected_package.candidate.origins[0]
key = str(origin)
if key not in self.metricsByOrigin:
self.metricsByOrigin[key] = {}
for k, _ in self.metricDict.items():
self.metricsByOrigin[key][k] = 0
for origin in selected_package.candidate.origins:
key = str(origin)
if key not in self.metricsByOrigin:
self.metricsByOrigin[key] = {}
for k, _ in self.metricDict.items():
self.metricsByOrigin[key][k] = 0

self.metricsByOrigin[key]["label_values"] = \
self.labelValues(origin)
self.metricsByOrigin[key]["label_values"] = \
self.labelValues(origin)

# Count Packages for the metrics
if selected_package.is_installed:
self.metricsByOrigin[key]["installed"] += 1
if selected_package.is_upgradable:
self.metricsByOrigin[key]["upgradable"] += 1
if selected_package.is_auto_removable:
self.metricsByOrigin[key]["auto_removable"] += 1
if selected_package.is_now_broken:
self.metricsByOrigin[key]["broken"] += 1
# Count Packages for the metrics
if selected_package.is_installed:
self.metricsByOrigin[key]["installed"] += 1
if selected_package.is_upgradable:
self.metricsByOrigin[key]["upgradable"] += 1
if selected_package.is_auto_removable:
self.metricsByOrigin[key]["auto_removable"] += 1
if selected_package.is_now_broken:
self.metricsByOrigin[key]["broken"] += 1
# apt update time
preUpdatePath = Path("/tmp/pkg-exporter-apt-update-pre")
postUpdatePath = Path("/tmp/pkg-exporter-apt-update-post")
Expand Down

0 comments on commit d1b17a7

Please sign in to comment.