mirror of
https://github.com/mag37/dockcheck.git
synced 2026-02-15 15:58:13 +01:00
* Ensures DSM GUI refreshes its updates
* Removed whale icon and changed verbosity
* Added addon for Prometheus+node_exporter
* Changed local image check to check on image ID rather than name
* Update podcheck.sh
changed docker->podman, typo
* - **v0.6.0**:
- **Grafana & Prometheus Integration:**
- Added a detailed Prometheus metrics exporter that now reports not only the number of containers with updates, no-updates, and errors, but also the total number of containers checked, the duration of the update check, and the epoch timestamp of the last check.
- Enhanced documentation with instructions on integrating these metrics with Grafana for visual monitoring.
- **Improved Error Handling & Code Refactoring:**
- Introduced `set -euo pipefail` and local variable scoping within functions to improve reliability and prevent unexpected behaviour.
- Standardised container name handling and refined the Quadlet detection logic.
- **Self-Update Enhancements:**
- Updated the self-update mechanism to support both Git-based and HTTP-based updates, with an automatic restart that preserves the original arguments.
- **Miscellaneous Improvements:**
- Enhanced dependency installer to support both package manager and static binary installations for `jq` and `regctl`.
- General code refactoring across the project for better readability and maintainability.
* Update podcheck.sh
* increment version
* Update Quadlet detection logic
Update Quadlet detection logic to support flexible service naming
- Modified the quadlet update block to first try an exact match for "$i.service".
- If no exact match is found, build a regex pattern from the container name (allowing underscores and hyphens interchangeably) and search user service units.
- When multiple candidate units are found, the script attempts to choose the one that exactly matches (ignoring case) or defaults to the first candidate.
- This update allows containers like "containera" to match service units named "container_a.service" and supports scenarios with multiple counterparts (e.g., matrix-a, matrix-b, matrix_db).
* search name fix
* fixes to arg parsing
* Logic overhaul, verbose output and better syntax
* Added support for prometheus
---------
Co-authored-by: mag37 <robin.ivehult@gmail.com>
62 lines
2.3 KiB
Bash
62 lines
2.3 KiB
Bash
#!/usr/bin/env bash
|
|
# prometheus_collector.sh - Exports detailed update metrics for Prometheus node_exporter.
|
|
#
|
|
# This script generates metrics about the state of Podman container update checks.
|
|
# It is designed to be sourced by podcheck.sh and then invoked with:
|
|
#
|
|
# prometheus_exporter <num_no_updates> <num_updates> <num_errors> <total_containers> <check_duration_seconds>
|
|
#
|
|
# Metrics:
|
|
# podcheck_no_updates:
|
|
# Number of containers that are already on the latest image.
|
|
# podcheck_updates:
|
|
# Number of containers with updates available.
|
|
# podcheck_errors:
|
|
# Number of containers that encountered errors during the update check.
|
|
# podcheck_total:
|
|
# Total number of containers checked.
|
|
# podcheck_check_duration:
|
|
# Duration (in seconds) it took to perform the update check.
|
|
# podcheck_last_check_timestamp:
|
|
# Epoch timestamp when the update check was performed.
|
|
#
|
|
# The metrics are written to a file named podcheck.prom in the specified
|
|
# CollectorTextFileDirectory, or /tmp if not specified.
|
|
#
|
|
|
|
prometheus_exporter() {
|
|
local no_updates="$1"
|
|
local updates="$2"
|
|
local errors="$3"
|
|
local total="$4"
|
|
local check_duration="$5"
|
|
local collector_dir="${CollectorTextFileDirectory:-/tmp}"
|
|
local last_check_timestamp
|
|
last_check_timestamp=$(date +%s)
|
|
|
|
{
|
|
echo "# HELP podcheck_no_updates Number of containers already on latest image."
|
|
echo "# TYPE podcheck_no_updates gauge"
|
|
echo "podcheck_no_updates $no_updates"
|
|
|
|
echo "# HELP podcheck_updates Number of containers with updates available."
|
|
echo "# TYPE podcheck_updates gauge"
|
|
echo "podcheck_updates $updates"
|
|
|
|
echo "# HELP podcheck_errors Number of containers with errors during update check."
|
|
echo "# TYPE podcheck_errors gauge"
|
|
echo "podcheck_errors $errors"
|
|
|
|
echo "# HELP podcheck_total Total number of containers checked."
|
|
echo "# TYPE podcheck_total gauge"
|
|
echo "podcheck_total $total"
|
|
|
|
echo "# HELP podcheck_check_duration Duration in seconds for the update check."
|
|
echo "# TYPE podcheck_check_duration gauge"
|
|
echo "podcheck_check_duration $check_duration"
|
|
|
|
echo "# HELP podcheck_last_check_timestamp Epoch timestamp of the last update check."
|
|
echo "# TYPE podcheck_last_check_timestamp gauge"
|
|
echo "podcheck_last_check_timestamp $last_check_timestamp"
|
|
} > "$collector_dir/podcheck.prom"
|
|
}
|