Skip to content

Commit

Permalink
Lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeephb committed Jan 27, 2024
1 parent 2382ade commit 6be809b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/pkg_exporter/pkgmanager/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import apt.progress
from pathlib import Path


class AptPkgManager:
def __init__(self, rootdir=None):
self.rootdir = rootdir
Expand Down
17 changes: 12 additions & 5 deletions src/pkg_exporter/textfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

from prometheus_client import Gauge, write_to_textfile, start_http_server
from prometheus_client import GC_COLLECTOR, PLATFORM_COLLECTOR, PROCESS_COLLECTOR
from prometheus_client import GC_COLLECTOR, PLATFORM_COLLECTOR, PROCESS_COLLECTOR # noqa E501
from prometheus_client.core import REGISTRY
from time import sleep
from pkg_exporter.pkgmanager import apt
Expand All @@ -22,14 +22,19 @@ def populate_registry(rootdir=None):

# also add reboot metrics
rebootmanager = reboot.RebootManager()
reboot_gauge = REGISTRY._names_to_collectors.get("pkg_reboot_required", None)
reboot_gauge = REGISTRY._names_to_collectors.get(
"pkg_reboot_required", None)
if not reboot_gauge:
reboot_gauge = Gauge("pkg_reboot_required", "Node Requires an Reboot", [])
reboot_gauge = Gauge(
"pkg_reboot_required",
"Node Requires an Reboot",
[])

# add update statistics
meta_metric = pkgmanager.getMetaMetricDict()
for key, value in meta_metric.items():
meta_gauges[key] = REGISTRY._names_to_collectors.get(f"pkg_{key}", None)
meta_gauges[key] = REGISTRY._names_to_collectors.get(
f"pkg_{key}", None)
if not meta_gauges[key]:
meta_gauges[key] = Gauge(f"pkg_{key}", value["description"])

Expand Down Expand Up @@ -83,7 +88,9 @@ def processArgs():
"-f",
"--exporter-file",
type=str,
default=os.getenv("PKG_EXPORTER_FILE", "/var/prometheus/pkg-exporter.prom"),
default=os.getenv(
"PKG_EXPORTER_FILE",
"/var/prometheus/pkg-exporter.prom"),
help="File to export, if used the content will not be served",
)
group.add_argument(
Expand Down

0 comments on commit 6be809b

Please sign in to comment.