Skip to content

Commit

Permalink
Merge pull request #182 from anarcat/apt-cache-timestamp
Browse files Browse the repository at this point in the history
report the apt cache timestamp
  • Loading branch information
SuperQ committed Oct 14, 2023
2 parents 34dd42e + dc6568e commit b579cf5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apt_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def _write_autoremove_pending(registry, cache):
g.set(len(autoremovable_packages))


def _write_cache_timestamps(registry):
g = Gauge('apt_package_cache_timestamp_seconds', "Apt update last run time.", registry=registry)
try:
g.set(os.stat('/var/cache/apt/pkgcache.bin').st_mtime)
except OSError:
pass


def _write_reboot_required(registry):
g = Gauge('node_reboot_required', "Node reboot is required for software updates.",
registry=registry)
Expand All @@ -96,6 +104,7 @@ def _main():
_write_pending_upgrades(registry, cache)
_write_held_upgrades(registry, cache)
_write_autoremove_pending(registry, cache)
_write_cache_timestamps(registry)
_write_reboot_required(registry)
print(generate_latest(registry).decode(), end='')

Expand Down

0 comments on commit b579cf5

Please sign in to comment.