diff --git a/README.md b/README.md index da95988c20f01645139cbbf79b95c15117a4055b..335a35c274cab7079a5b5b5c9b9ffb2ba33e124a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ version-checker =============== -Tool for checking if software versions are out of date. Supports (for now) checking against github releases, dockerhub images, debian packages and arbitrary web sites (using regexp). Will start a webserver that exposes the version status as prometheus metyrics under the path '/metrics' and show a status page for all other paths. +Tool for checking if software versions are out of date. Supports (for now) checking against github releases, dockerhub images, debian packages and arbitrary web sites (using regexp). Will start a webserver that exposes the version status as prometheus metrics under the path '/metrics' and show a status page for all other paths. Installation: ------------- @@ -65,3 +65,16 @@ Further keys depend on the check used: * website * url: url of the website * pattern: regex pattern for the version string, must contain exactly one capture group (for the version) + +Metrics +------- + +Prometheus compatible metrics are available at the path /metrics. The series have the name `fhg_iam_version`. They have three labels: +* `name` - corresponds to `name` in the config +* `latest` - latest version available (according the the pattern) +* `running` - this is `version` given in the config + +There are three possible values: +* 0 - up to date, i.e. latest and running are identical +* 1 - out of date, i.e. latest and running differ +* 2 - unknown, the `latest` version could not be determined; latest will be `None` in this case diff --git a/vcheck.py b/vcheck.py index d0680b3874666ac56641aa7d7d7d01278655abbd..a1aa328d91831c0086ac9ce9e20fa1210e30e88d 100755 --- a/vcheck.py +++ b/vcheck.py @@ -267,9 +267,10 @@ def check(confd, v): if not current: res += td(c['name'], c['version'], f'UNKNOWN: {error}', 'unknown') + v.labels(name=c['name'], running=c['version'], latest=current).set(2) err += 1 else: - uptodate = c['version'] == current + uptodate = not c['version'] == current res += td(c['name'], c['version'], current, 'uptodate' if uptodate else 'outofdate') v.labels(name=c['name'], running=c['version'], latest=current).set(uptodate) ood += not uptodate @@ -319,7 +320,7 @@ def params(): def run(port, confd, recheck): - v = prometheus_client.Gauge('version', 'Software version, value: 1 if up to date', ['name', 'running', 'latest']) + v = prometheus_client.Gauge('fhg_iam_version', 'Software version, value: 0 if up to date, 2 unknown', ['name', 'running', 'latest']) global content global running