mirror of
https://github.com/mag37/dockcheck.git
synced 2026-04-17 18:07:46 +00:00
Compare commits
30 Commits
v0.5.1
...
swarm_supp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc6a3529c7 | ||
|
|
01b9b33751 | ||
|
|
9ed2a0bad0 | ||
|
|
43307350ca | ||
|
|
b3600f26ac | ||
|
|
79def47754 | ||
|
|
e6ff634394 | ||
|
|
6444e18a4f | ||
|
|
14872b0471 | ||
|
|
07ad241e9f | ||
|
|
58d53d3aaf | ||
|
|
15ce226a0a | ||
|
|
cce5438aca | ||
|
|
be6f5edf52 | ||
|
|
99befd6938 | ||
|
|
8a63fd360c | ||
|
|
d3786d6f75 | ||
|
|
487cfb2822 | ||
|
|
b4943df46c | ||
|
|
8603c8d4b6 | ||
|
|
ae66a6f0fd | ||
|
|
3ac0521a9b | ||
|
|
00ae250511 | ||
|
|
704387a7fe | ||
|
|
1a6826e2ac | ||
|
|
a28b9e555f | ||
|
|
8309b80dc2 | ||
|
|
bbe26a0ac2 | ||
|
|
d98d052af7 | ||
|
|
fbba77dc1f |
31
README.md
31
README.md
@@ -10,14 +10,18 @@
|
|||||||
<a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a>
|
<a href="https://github.com/sponsors/mag37"><img src="https://img.shields.io/badge/-Sponsor-grey?style=flat-square&logo=github" alt="Github Sponsor"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3 align="center">CLI tool to automate docker image updates. <br>No <b>pre-pull</b>, selective, optional notifications and prune when done.</h3>
|
<h2 align="center">CLI tool to automate docker image updates or notifying when updates are available.</h2>
|
||||||
<h2 align="center">Now with simple notification integrations!</h2>
|
<h3 align="center">Features:</h3>
|
||||||
<h4 align="center">With features like excluding specific containers, custom container labels, auto-prune when done and more.</h4>
|
<h3 align="center">selective updates, exclude containers, custom labels, notification plugins, prune when done and more.</h3>
|
||||||
<h4 align="center">Also see the fresh Podman fork <a href="https://github.com/sudo-kraken/podcheck">sudo-kraken/podcheck</a>!</h4>
|
|
||||||
|
<h4 align="center">For Podman - see the fork <a href="https://github.com/sudo-kraken/podcheck">sudo-kraken/podcheck</a>!</h4>
|
||||||
|
|
||||||
___
|
___
|
||||||
## :bell: Changelog
|
## :bell: Changelog
|
||||||
|
|
||||||
|
- **v0.5.4.0**: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
||||||
|
- **v0.5.3.0**: Local image check changed (use imageId instead of name) and Gotify-template fixed (whale icon removed).
|
||||||
|
- **v0.5.2.1**: Rewrite of dependency downloads, jq can be installed with package manager or static binary.
|
||||||
- **v0.5.1**: DEPENDENCY WARNING: now requires **jq**. + Upstreaming changes from [sudo-kraken/podcheck](https://github.com/sudo-kraken/podcheck)
|
- **v0.5.1**: DEPENDENCY WARNING: now requires **jq**. + Upstreaming changes from [sudo-kraken/podcheck](https://github.com/sudo-kraken/podcheck)
|
||||||
- **v0.5.0**: Rewritten notify logic - all templates are adjusted and should be migrated!
|
- **v0.5.0**: Rewritten notify logic - all templates are adjusted and should be migrated!
|
||||||
- Copy the custom settings from your current template to the new version of the same template.
|
- Copy the custom settings from your current template to the new version of the same template.
|
||||||
@@ -26,9 +30,6 @@ ___
|
|||||||
- Added Discord notify template.
|
- Added Discord notify template.
|
||||||
- Verbosity changed of `regctl`.
|
- Verbosity changed of `regctl`.
|
||||||
- **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-notifications)
|
- **v0.4.9**: Added a function to enrich the notify-message with release note URLs. See [Release notes addon](https://github.com/mag37/dockcheck#date-release-notes-addon-to-notifications)
|
||||||
- **v0.4.8**: Rewrote prune logic to not prompt with options `-a|-y` or `-n`. Auto prune with `-p`.
|
|
||||||
- **v0.4.7**: Notification Template changes to gotify(new!), DSM(improved), SMTP(deprecation alternative).
|
|
||||||
- **v0.4.6**: Compatibility changes to timeout, due to busybox.
|
|
||||||
___
|
___
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ Example: dockcheck.sh -y -d 10 -e nextcloud,heimdall
|
|||||||
|
|
||||||
Options:"
|
Options:"
|
||||||
-a|y Automatic updates, without interaction.
|
-a|y Automatic updates, without interaction.
|
||||||
|
-c D Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory.
|
||||||
-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower.
|
||||||
-e X Exclude containers, separated by comma.
|
-e X Exclude containers, separated by comma.
|
||||||
-f Force stack restart after update. Caution: restarts once for every updated container within stack.
|
-f Force stack restart after update. Caution: restarts once for every updated container within stack.
|
||||||
@@ -57,7 +59,6 @@ Options:"
|
|||||||
-v Prints current version.
|
-v Prints current version.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Basic example:
|
### Basic example:
|
||||||
```
|
```
|
||||||
$ ./dockcheck.sh
|
$ ./dockcheck.sh
|
||||||
@@ -82,6 +83,8 @@ ___
|
|||||||
## :nut_and_bolt: Dependencies
|
## :nut_and_bolt: Dependencies
|
||||||
- Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck)
|
- Running docker (duh) and compose, either standalone or plugin. (see [Podman fork](https://github.com/sudo-kraken/podcheck)
|
||||||
- Bash shell or compatible shell of at least v4.3
|
- Bash shell or compatible shell of at least v4.3
|
||||||
|
- [jq](https://github.com/jqlang/jq)
|
||||||
|
- User will be prompted to install with package manager or download static binary.
|
||||||
- [regclient/regctl](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0))
|
- [regclient/regctl](https://github.com/regclient/regclient) (Licensed under [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0))
|
||||||
- User will be prompted to download `regctl` if not in `PATH` or `PWD`.
|
- User will be prompted to download `regctl` if not in `PATH` or `PWD`.
|
||||||
- regctl requires `amd64/arm64` - see [workaround](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used.
|
- regctl requires `amd64/arm64` - see [workaround](#roller_coaster-workaround-for-non-amd64--arm64) if other architecture is used.
|
||||||
@@ -135,6 +138,17 @@ nginx -> https://github.com/docker-library/official-images/blob/master/library
|
|||||||
```
|
```
|
||||||
The `urls.list` file is just an example and I'd gladly see that people contribute back when they add their preferred URLs to their lists.
|
The `urls.list` file is just an example and I'd gladly see that people contribute back when they add their preferred URLs to their lists.
|
||||||
|
|
||||||
|
## :chart_with_upwards_trend: Prometheus and node_exporter
|
||||||
|
Dockcheck can be used together with [Prometheus](https://github.com/prometheus/prometheus) and [node_exporter](https://github.com/prometheus/node_exporter) to export metrics via the file collector, scheduled with cron or likely.
|
||||||
|
This is done with the `-c` option, like this:
|
||||||
|
```
|
||||||
|
dockcheck.sh -c /path/to/exporter/directory
|
||||||
|
```
|
||||||
|
|
||||||
|
See the [README.md](./addons/prometheus/README.md) for more detailed information on how to set it up!
|
||||||
|
|
||||||
|
<sub><sup>Contributed by [tdralle](https://github.com/tdralle).</sup></sub>
|
||||||
|
|
||||||
## :bookmark: Labels
|
## :bookmark: Labels
|
||||||
Optionally add labels to compose-files. Currently these are the usable labels:
|
Optionally add labels to compose-files. Currently these are the usable labels:
|
||||||
```
|
```
|
||||||
@@ -199,4 +213,3 @@ dockcheck is created and released under the [GNU GPL v3.0](https://www.gnu.org/l
|
|||||||
___
|
___
|
||||||
|
|
||||||
### :floppy_disk: The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect.
|
### :floppy_disk: The [story](https://mag37.org/posts/project_dockcheck/) behind it. 1 year in retrospect.
|
||||||
|
|
||||||
|
|||||||
61
addons/prometheus/README.md
Normal file
61
addons/prometheus/README.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
## [Prometheus](https://github.com/prometheus/prometheus) and [node_exporter](https://github.com/prometheus/node_exporter)
|
||||||
|
Dockcheck is capable to export metrics to prometheus via the text file collector provided by the node_exporter.
|
||||||
|
In order to do so the -c flag has to be specified followed by the file path that is configured in the text file collector of the node_exporter.
|
||||||
|
A simple cron job can be configured to export these metrics on a regular interval as shown in the sample below:
|
||||||
|
|
||||||
|
```
|
||||||
|
0 1 * * * /root/dockcheck.sh -n -c /var/lib/node_exporter/textfile_collector
|
||||||
|
```
|
||||||
|
|
||||||
|
The following metrics are exported to prometheus
|
||||||
|
|
||||||
|
```
|
||||||
|
# HELP dockcheck_images_analyzed Docker images that have been analyzed
|
||||||
|
# TYPE dockcheck_images_analyzed gauge
|
||||||
|
dockcheck_images_analyzed 22
|
||||||
|
# HELP dockcheck_images_outdated Docker images that are outdated
|
||||||
|
# TYPE dockcheck_images_outdated gauge
|
||||||
|
dockcheck_images_outdated 7
|
||||||
|
# HELP dockcheck_images_latest Docker images that are outdated
|
||||||
|
# TYPE dockcheck_images_latest gauge
|
||||||
|
dockcheck_images_latest 14
|
||||||
|
# HELP dockcheck_images_error Docker images with analysis errors
|
||||||
|
# TYPE dockcheck_images_error gauge
|
||||||
|
dockcheck_images_error 1
|
||||||
|
# HELP dockcheck_images_analyze_timestamp_seconds Last dockercheck run time
|
||||||
|
# TYPE dockcheck_images_analyze_timestamp_seconds gauge
|
||||||
|
dockcheck_images_analyze_timestamp_seconds 1737924029
|
||||||
|
```
|
||||||
|
|
||||||
|
Once those metrics are exported they can be used to define alarms as shown below
|
||||||
|
|
||||||
|
```
|
||||||
|
- alert: dockcheck_images_outdated
|
||||||
|
expr: sum by(instance) (dockcheck_images_outdated) > 0
|
||||||
|
for: 15s
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
annotations:
|
||||||
|
summary: "{{ $labels.instance }} has {{ $value }} outdated docker images."
|
||||||
|
description: "{{ $labels.instance }} has {{ $value }} outdated docker images."
|
||||||
|
- alert: dockcheck_images_error
|
||||||
|
expr: sum by(instance) (dockcheck_images_error) > 0
|
||||||
|
for: 15s
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
annotations:
|
||||||
|
summary: "{{ $labels.instance }} has {{ $value }} docker images having an error."
|
||||||
|
description: "{{ $labels.instance }} has {{ $value }} docker images having an error."
|
||||||
|
- alert: dockercheck_image_last_analyze
|
||||||
|
expr: (time() - dockcheck_images_analyze_timestamp_seconds) > (3600 * 24 * 3)
|
||||||
|
for: 15s
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
annotations:
|
||||||
|
summary: "{{ $labels.instance }} has not updated the dockcheck statistics for more than 3 days."
|
||||||
|
description: "{{ $labels.instance }} has not updated the dockcheck statistics for more than 3 days."
|
||||||
|
```
|
||||||
|
|
||||||
|
There is a reference Grafana dashboard in [grafana/grafana_dashboard.json](./grafana/grafana_dashboard.json).
|
||||||
|
|
||||||
|

|
||||||
382
addons/prometheus/grafana/grafana_dashboard.json
Normal file
382
addons/prometheus/grafana/grafana_dashboard.json
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
{
|
||||||
|
"__inputs": [
|
||||||
|
{
|
||||||
|
"name": "DS_PROMETHEUS",
|
||||||
|
"label": "prometheus",
|
||||||
|
"description": "",
|
||||||
|
"type": "datasource",
|
||||||
|
"pluginId": "prometheus",
|
||||||
|
"pluginName": "Prometheus"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"__elements": {},
|
||||||
|
"__requires": [
|
||||||
|
{
|
||||||
|
"type": "grafana",
|
||||||
|
"id": "grafana",
|
||||||
|
"name": "Grafana",
|
||||||
|
"version": "11.4.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "datasource",
|
||||||
|
"id": "prometheus",
|
||||||
|
"name": "Prometheus",
|
||||||
|
"version": "1.0.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "panel",
|
||||||
|
"id": "table",
|
||||||
|
"name": "Table",
|
||||||
|
"version": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"annotations": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"builtIn": 1,
|
||||||
|
"datasource": {
|
||||||
|
"type": "grafana",
|
||||||
|
"uid": "-- Grafana --"
|
||||||
|
},
|
||||||
|
"enable": true,
|
||||||
|
"hide": true,
|
||||||
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
|
"name": "Annotations & Alerts",
|
||||||
|
"type": "dashboard"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"editable": true,
|
||||||
|
"fiscalYearStartMonth": 0,
|
||||||
|
"graphTooltip": 0,
|
||||||
|
"id": null,
|
||||||
|
"links": [],
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"color": {
|
||||||
|
"mode": "thresholds"
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"align": "auto",
|
||||||
|
"cellOptions": {
|
||||||
|
"type": "auto"
|
||||||
|
},
|
||||||
|
"inspect": false
|
||||||
|
},
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 80
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "last_analyze_timestamp"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "unit",
|
||||||
|
"value": "dateTimeAsIso"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "last_analyze_since"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "unit",
|
||||||
|
"value": "s"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "custom.cellOptions",
|
||||||
|
"value": {
|
||||||
|
"mode": "gradient",
|
||||||
|
"type": "color-background"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "thresholds",
|
||||||
|
"value": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 259200
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "images_outdated"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "custom.cellOptions",
|
||||||
|
"value": {
|
||||||
|
"mode": "gradient",
|
||||||
|
"type": "color-background"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "thresholds",
|
||||||
|
"value": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "images_error"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "custom.cellOptions",
|
||||||
|
"value": {
|
||||||
|
"mode": "gradient",
|
||||||
|
"type": "color-background"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "thresholds",
|
||||||
|
"value": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 14,
|
||||||
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 2,
|
||||||
|
"options": {
|
||||||
|
"cellHeight": "sm",
|
||||||
|
"footer": {
|
||||||
|
"countRows": false,
|
||||||
|
"fields": "",
|
||||||
|
"reducer": [
|
||||||
|
"sum"
|
||||||
|
],
|
||||||
|
"show": false
|
||||||
|
},
|
||||||
|
"frameIndex": 1,
|
||||||
|
"showHeader": true,
|
||||||
|
"sortBy": []
|
||||||
|
},
|
||||||
|
"pluginVersion": "11.4.0",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"disableTextWrap": false,
|
||||||
|
"editorMode": "code",
|
||||||
|
"exemplar": false,
|
||||||
|
"expr": "sum by(instance) (dockcheck_images_analyzed)",
|
||||||
|
"format": "table",
|
||||||
|
"fullMetaSearch": false,
|
||||||
|
"hide": false,
|
||||||
|
"includeNullMetadata": true,
|
||||||
|
"instant": true,
|
||||||
|
"interval": "",
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": false,
|
||||||
|
"refId": "dockcheck_images_analyzed",
|
||||||
|
"useBackend": false,
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
},
|
||||||
|
"disableTextWrap": false,
|
||||||
|
"editorMode": "code",
|
||||||
|
"exemplar": false,
|
||||||
|
"expr": "sum by(instance) (dockcheck_images_outdated)",
|
||||||
|
"format": "table",
|
||||||
|
"fullMetaSearch": false,
|
||||||
|
"hide": false,
|
||||||
|
"includeNullMetadata": true,
|
||||||
|
"instant": true,
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": false,
|
||||||
|
"refId": "dockcheck_images_outdated",
|
||||||
|
"useBackend": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
},
|
||||||
|
"disableTextWrap": false,
|
||||||
|
"editorMode": "code",
|
||||||
|
"exemplar": false,
|
||||||
|
"expr": "sum by(instance) (dockcheck_images_latest)",
|
||||||
|
"format": "table",
|
||||||
|
"fullMetaSearch": false,
|
||||||
|
"hide": false,
|
||||||
|
"includeNullMetadata": true,
|
||||||
|
"instant": true,
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": false,
|
||||||
|
"refId": "dockcheck_images_latest",
|
||||||
|
"useBackend": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
},
|
||||||
|
"editorMode": "code",
|
||||||
|
"exemplar": false,
|
||||||
|
"expr": "sum by(instance) (dockcheck_images_error)",
|
||||||
|
"format": "table",
|
||||||
|
"hide": false,
|
||||||
|
"instant": true,
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": false,
|
||||||
|
"refId": "dockcheck_images_error"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
},
|
||||||
|
"editorMode": "code",
|
||||||
|
"exemplar": false,
|
||||||
|
"expr": "dockcheck_images_analyze_timestamp_seconds * 1000",
|
||||||
|
"format": "table",
|
||||||
|
"hide": false,
|
||||||
|
"instant": true,
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": false,
|
||||||
|
"refId": "dockcheck_images_analyze_timestamp_seconds"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "${DS_PROMETHEUS}"
|
||||||
|
},
|
||||||
|
"editorMode": "code",
|
||||||
|
"exemplar": false,
|
||||||
|
"expr": "time() - dockcheck_images_analyze_timestamp_seconds",
|
||||||
|
"format": "table",
|
||||||
|
"hide": false,
|
||||||
|
"instant": true,
|
||||||
|
"legendFormat": "{{instance}}",
|
||||||
|
"range": false,
|
||||||
|
"refId": "dockcheck_images_last_analyze"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Dockcheck Status",
|
||||||
|
"transformations": [
|
||||||
|
{
|
||||||
|
"id": "merge",
|
||||||
|
"options": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "organize",
|
||||||
|
"options": {
|
||||||
|
"excludeByName": {
|
||||||
|
"Time": true,
|
||||||
|
"__name__": true,
|
||||||
|
"job": true
|
||||||
|
},
|
||||||
|
"includeByName": {},
|
||||||
|
"indexByName": {
|
||||||
|
"Time": 0,
|
||||||
|
"Value #dockcheck_images_analyze_timestamp_seconds": 2,
|
||||||
|
"Value #dockcheck_images_analyzed": 4,
|
||||||
|
"Value #dockcheck_images_error": 7,
|
||||||
|
"Value #dockcheck_images_last_analyze": 3,
|
||||||
|
"Value #dockcheck_images_latest": 5,
|
||||||
|
"Value #dockcheck_images_outdated": 6,
|
||||||
|
"instance": 1,
|
||||||
|
"job": 8
|
||||||
|
},
|
||||||
|
"renameByName": {
|
||||||
|
"Value #A": "analyze_timestamp",
|
||||||
|
"Value #dockcheck_images_analyze_timestamp_seconds": "last_analyze_timestamp",
|
||||||
|
"Value #dockcheck_images_analyzed": "images_analyzed",
|
||||||
|
"Value #dockcheck_images_error": "images_error",
|
||||||
|
"Value #dockcheck_images_last_analyze": "last_analyze_since",
|
||||||
|
"Value #dockcheck_images_latest": "images_latest",
|
||||||
|
"Value #dockcheck_images_outdated": "images_outdated"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"type": "table"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"schemaVersion": 40,
|
||||||
|
"tags": [],
|
||||||
|
"templating": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"time": {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
|
"timepicker": {},
|
||||||
|
"timezone": "browser",
|
||||||
|
"title": "Dockcheck Status",
|
||||||
|
"uid": "feb4pv3kv1hxca",
|
||||||
|
"version": 17,
|
||||||
|
"weekStart": ""
|
||||||
|
}
|
||||||
BIN
addons/prometheus/grafana/grafana_dashboard.png
Normal file
BIN
addons/prometheus/grafana/grafana_dashboard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
28
addons/prometheus/prometheus_collector.sh
Normal file
28
addons/prometheus/prometheus_collector.sh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
prometheus_exporter() {
|
||||||
|
checkedImages=$(($1 + $2 + $3))
|
||||||
|
checkTimestamp=$(date +%s)
|
||||||
|
|
||||||
|
promFileContent=()
|
||||||
|
promFileContent+=("# HELP dockcheck_images_analyzed Docker images that have been analyzed")
|
||||||
|
promFileContent+=("# TYPE dockcheck_images_analyzed gauge")
|
||||||
|
promFileContent+=("dockcheck_images_analyzed $checkedImages")
|
||||||
|
|
||||||
|
promFileContent+=("# HELP dockcheck_images_outdated Docker images that are outdated")
|
||||||
|
promFileContent+=("# TYPE dockcheck_images_outdated gauge")
|
||||||
|
promFileContent+=("dockcheck_images_outdated ${#GotUpdates[@]}")
|
||||||
|
|
||||||
|
promFileContent+=("# HELP dockcheck_images_latest Docker images that are outdated")
|
||||||
|
promFileContent+=("# TYPE dockcheck_images_latest gauge")
|
||||||
|
promFileContent+=("dockcheck_images_latest ${#NoUpdates[@]}")
|
||||||
|
|
||||||
|
promFileContent+=("# HELP dockcheck_images_error Docker images with analysis errors")
|
||||||
|
promFileContent+=("# TYPE dockcheck_images_error gauge")
|
||||||
|
promFileContent+=("dockcheck_images_error ${#GotErrors[@]}")
|
||||||
|
|
||||||
|
promFileContent+=("# HELP dockcheck_images_analyze_timestamp_seconds Last dockercheck run time")
|
||||||
|
promFileContent+=("# TYPE dockcheck_images_analyze_timestamp_seconds gauge")
|
||||||
|
promFileContent+=("dockcheck_images_analyze_timestamp_seconds $checkTimestamp")
|
||||||
|
|
||||||
|
printf "%s\n" "${promFileContent[@]}" > "$CollectorTextFileDirectory/dockcheck_info.prom\$\$"
|
||||||
|
mv -f "$CollectorTextFileDirectory/dockcheck_info.prom\$\$" "$CollectorTextFileDirectory/dockcheck_info.prom"
|
||||||
|
}
|
||||||
102
dockcheck.sh
102
dockcheck.sh
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
VERSION="v0.5.1"
|
VERSION="v0.5.4.0"
|
||||||
# ChangeNotes: DEPENDENCY WARNING: now requires jq. And upstreaming changes from sudo-kraken/podcheck
|
### ChangeNotes: Added support for a Prometheus+node_exporter metric collection through a file collector.
|
||||||
Github="https://github.com/mag37/dockcheck"
|
Github="https://github.com/mag37/dockcheck"
|
||||||
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
RawUrl="https://raw.githubusercontent.com/mag37/dockcheck/main/dockcheck.sh"
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ Help() {
|
|||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo "-a|y Automatic updates, without interaction."
|
echo "-a|y Automatic updates, without interaction."
|
||||||
|
echo "-c Exports metrics as prom file for the prometheus node_exporter. Provide the collector textfile directory."
|
||||||
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
|
echo "-d N Only update to new images that are N+ days old. Lists too recent with +prefix and age. 2xSlower."
|
||||||
echo "-e X Exclude containers, separated by comma."
|
echo "-e X Exclude containers, separated by comma."
|
||||||
echo "-f Force stack restart after update. Caution: restarts once for every updated container within stack."
|
echo "-f Force stack restart after update. Caution: restarts once for every updated container within stack."
|
||||||
@@ -47,9 +48,11 @@ c_reset="\033[0m"
|
|||||||
|
|
||||||
Timeout=10
|
Timeout=10
|
||||||
Stopped=""
|
Stopped=""
|
||||||
while getopts "aynpfrhlisvme:d:t:" options; do
|
while getopts "aynpfrhlisvmc:e:d:t:" options; do
|
||||||
case "${options}" in
|
case "${options}" in
|
||||||
a|y) AutoUp="yes" ;;
|
a|y) AutoUp="yes" ;;
|
||||||
|
c) CollectorTextFileDirectory="${OPTARG}"
|
||||||
|
if ! [[ -d $CollectorTextFileDirectory ]] ; then { printf "The directory (%s) does not exist.\n" "${CollectorTextFileDirectory}" ; exit 2; } fi ;;
|
||||||
n) AutoUp="no" ;;
|
n) AutoUp="no" ;;
|
||||||
r) DRunUp="yes" ;;
|
r) DRunUp="yes" ;;
|
||||||
p) AutoPrune="yes" ;;
|
p) AutoPrune="yes" ;;
|
||||||
@@ -173,27 +176,64 @@ SearchName="$1"
|
|||||||
# Create array of excludes
|
# Create array of excludes
|
||||||
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
|
||||||
|
|
||||||
# Check if required binary exists in PATH or directory
|
# Static binary downloader for dependencies
|
||||||
if [[ $(command -v regctl) ]]; then regbin="regctl" ;
|
binary_downloader() {
|
||||||
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
BinaryName="$1"
|
||||||
else
|
BinaryUrl="$2"
|
||||||
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetDep
|
|
||||||
if [[ "$GetDep" =~ [yY] ]] ; then
|
|
||||||
# Check architecture
|
|
||||||
case "$(uname --machine)" in
|
case "$(uname --machine)" in
|
||||||
x86_64|amd64) architecture="amd64" ;;
|
x86_64|amd64) architecture="amd64" ;;
|
||||||
arm64|aarch64) architecture="arm64";;
|
arm64|aarch64) architecture="arm64";;
|
||||||
*) echo "Architecture not supported, exiting." ; exit 1;;
|
*) printf "\n%bArchitecture not supported, exiting.%b\n" "$c_red" "$c_reset" ; exit 1;;
|
||||||
esac
|
esac
|
||||||
RegUrl="https://github.com/regclient/regclient/releases/latest/download/regctl-linux-$architecture"
|
GetUrl="${BinaryUrl/TEMP/"$architecture"}"
|
||||||
if [[ $(command -v curl) ]]; then curl -L $RegUrl > "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
|
if [[ $(command -v curl) ]]; then curl -L $GetUrl > "$ScriptWorkDir/$BinaryName" ;
|
||||||
elif [[ $(command -v wget) ]]; then wget $RegUrl -O "$ScriptWorkDir/regctl" ; chmod +x "$ScriptWorkDir/regctl" ; regbin="$ScriptWorkDir/regctl" ;
|
elif [[ $(command -v wget) ]]; then wget $GetUrl -O "$ScriptWorkDir/$BinaryName" ;
|
||||||
else
|
else printf "%s\n" "curl/wget not available - get $BinaryName manually from the repo link, exiting."; exit 1;
|
||||||
printf "%s\n" "curl/wget not available - get regctl manually from the repo link, quitting."
|
|
||||||
fi
|
fi
|
||||||
|
[[ -f "$ScriptWorkDir/$BinaryName" ]] && chmod +x "$ScriptWorkDir/$BinaryName"
|
||||||
|
}
|
||||||
|
|
||||||
|
distro_checker() {
|
||||||
|
if [[ -f /etc/arch-release ]] ; then PkgInstaller="pacman -S"
|
||||||
|
elif [[ -f /etc/redhat-release ]] ; then PkgInstaller="dnf install"
|
||||||
|
elif [[ -f /etc/SuSE-release ]] ; then PkgInstaller="zypper install"
|
||||||
|
elif [[ -f /etc/debian_version ]] ; then PkgInstaller="apt-get install"
|
||||||
|
else PkgInstaller="ERROR" ; printf "\n%bNo distribution could be determined%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dependency check for jq in PATH or directory
|
||||||
|
if [[ $(command -v jq) ]]; then jqbin="jq" ;
|
||||||
|
elif [[ -f "$ScriptWorkDir/jq" ]]; then jqbin="$ScriptWorkDir/jq" ;
|
||||||
else
|
else
|
||||||
printf "%s\n" "Dependency missing, quitting."
|
printf "%s\n" "Required dependency 'jq' missing, do you want to install it?"
|
||||||
exit 1
|
read -r -p "y: With packagemanager (sudo). / s: Download static binary. y/s/[n] " GetJq
|
||||||
|
GetJq=${GetJq:-no} # set default to no if nothing is given
|
||||||
|
if [[ "$GetJq" =~ [yYsS] ]] ; then
|
||||||
|
[[ "$GetJq" =~ [yY] ]] && distro_checker
|
||||||
|
if [[ -n "$PkgInstaller" && "$PkgInstaller" != "ERROR" ]] ; then
|
||||||
|
(sudo $PkgInstaller jq) ; PkgExitcode="$?"
|
||||||
|
[[ "$PkgExitcode" == 0 ]] && jqbin="jq" || printf "\n%bPackagemanager install failed%b, falling back to static binary.\n" "$c_yellow" "$c_reset"
|
||||||
|
fi
|
||||||
|
if [[ "$GetJq" =~ [nN] || "$PkgInstaller" == "ERROR" || "$PkgExitcode" != 0 ]] ; then
|
||||||
|
binary_downloader "jq" "https://github.com/jqlang/jq/releases/latest/download/jq-linux-TEMP"
|
||||||
|
[[ -f "$ScriptWorkDir/jq" ]] && jqbin="$ScriptWorkDir/jq"
|
||||||
|
fi
|
||||||
|
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# Final check if binary is correct
|
||||||
|
$jqbin --version &> /dev/null || { printf "%s\n" "jq is not working - try to remove it and re-download it, exiting."; exit 1; }
|
||||||
|
|
||||||
|
# Dependency check for regctl in PATH or directory
|
||||||
|
if [[ $(command -v regctl) ]]; then regbin="regctl" ;
|
||||||
|
elif [[ -f "$ScriptWorkDir/regctl" ]]; then regbin="$ScriptWorkDir/regctl" ;
|
||||||
|
else
|
||||||
|
read -r -p "Required dependency 'regctl' missing, do you want it downloaded? y/[n] " GetRegctl
|
||||||
|
if [[ "$GetRegctl" =~ [yY] ]] ; then
|
||||||
|
binary_downloader "regctl" "https://github.com/regclient/regclient/releases/latest/download/regctl-linux-TEMP"
|
||||||
|
[[ -f "$ScriptWorkDir/regctl" ]] && regbin="$ScriptWorkDir/regctl"
|
||||||
|
else printf "\n%bDependency missing, exiting.%b\n" "$c_red" "$c_reset" ; exit 1 ;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Final check if binary is correct
|
# Final check if binary is correct
|
||||||
@@ -210,12 +250,6 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for jq binary
|
|
||||||
if [[ ! $(command -v jq) ]] ; then
|
|
||||||
printf "%s\n" "No jq binary, please install jq and try again, exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Numbered List function
|
# Numbered List function
|
||||||
options() {
|
options() {
|
||||||
num=1
|
num=1
|
||||||
@@ -253,8 +287,9 @@ for i in $(docker ps $Stopped --filter "name=$SearchName" --format '{{.Names}}')
|
|||||||
progress_bar "$RegCheckQue" "$ContCount"
|
progress_bar "$RegCheckQue" "$ContCount"
|
||||||
# Looping every item over the list of excluded names and skipping
|
# Looping every item over the list of excluded names and skipping
|
||||||
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
|
||||||
|
ImageId=$(docker inspect "$i" --format='{{.Image}}')
|
||||||
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
|
LocalHash=$(docker image inspect "$ImageId" --format '{{.RepoDigests}}')
|
||||||
# Checking for errors while setting the variable
|
# Checking for errors while setting the variable
|
||||||
if RegHash=$(${t_out} $regbin -v error image digest --list "$RepoUrl" 2>&1) ; then
|
if RegHash=$(${t_out} $regbin -v error image digest --list "$RepoUrl" 2>&1) ; then
|
||||||
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
if [[ "$LocalHash" = *"$RegHash"* ]] ; then
|
||||||
@@ -278,6 +313,11 @@ NoUpdates=($(sort <<<"${NoUpdates[*]}"))
|
|||||||
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
|
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
|
# Run the prometheus exporter function
|
||||||
|
if [ -n "$CollectorTextFileDirectory" ] ; then
|
||||||
|
source "$ScriptWorkDir"/addons/prometheus/prometheus_collector.sh && prometheus_exporter ${#NoUpdates[@]} ${#GotUpdates[@]} ${#GotError[@]}
|
||||||
|
fi
|
||||||
|
|
||||||
# Define how many updates are available
|
# Define how many updates are available
|
||||||
UpdCount="${#GotUpdates[@]}"
|
UpdCount="${#GotUpdates[@]}"
|
||||||
|
|
||||||
@@ -315,17 +355,17 @@ if [ -n "$GotUpdates" ] ; then
|
|||||||
# Extract labels and metadata
|
# Extract labels and metadata
|
||||||
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
|
ContLabels=$(docker inspect "$i" --format '{{json .Config.Labels}}')
|
||||||
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
ContImage=$(docker inspect "$i" --format='{{.Config.Image}}')
|
||||||
ContPath=$(jq -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
|
ContPath=$($jqbin -r '."com.docker.compose.project.working_dir"' <<< "$ContLabels")
|
||||||
[ "$ContPath" == "null" ] && ContPath=""
|
[ "$ContPath" == "null" ] && ContPath=""
|
||||||
ContConfigFile=$(jq -r '."com.docker.compose.project.config_files"' <<< "$ContLabels")
|
ContConfigFile=$($jqbin -r '."com.docker.compose.project.config_files"' <<< "$ContLabels")
|
||||||
[ "$ContConfigFile" == "null" ] && ContConfigFile=""
|
[ "$ContConfigFile" == "null" ] && ContConfigFile=""
|
||||||
ContName=$(jq -r '."com.docker.compose.service"' <<< "$ContLabels")
|
ContName=$($jqbin -r '."com.docker.compose.service"' <<< "$ContLabels")
|
||||||
[ "$ContName" == "null" ] && ContName=""
|
[ "$ContName" == "null" ] && ContName=""
|
||||||
ContEnv=$(jq -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels")
|
ContEnv=$($jqbin -r '."com.docker.compose.project.environment_file"' <<< "$ContLabels")
|
||||||
[ "$ContEnv" == "null" ] && ContEnv=""
|
[ "$ContEnv" == "null" ] && ContEnv=""
|
||||||
ContUpdateLabel=$(jq -r '."mag37.dockcheck.update"' <<< "$ContLabels")
|
ContUpdateLabel=$($jqbin -r '."mag37.dockcheck.update"' <<< "$ContLabels")
|
||||||
[ "$ContUpdateLabel" == "null" ] && ContUpdateLabel=""
|
[ "$ContUpdateLabel" == "null" ] && ContUpdateLabel=""
|
||||||
ContRestartStack=$(jq -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
|
ContRestartStack=$($jqbin -r '."mag37.dockcheck.restart-stack"' <<< "$ContLabels")
|
||||||
[ "$ContRestartStack" == "null" ] && ContRestartStack=""
|
[ "$ContRestartStack" == "null" ] && ContRestartStack=""
|
||||||
|
|
||||||
# Checking if compose-values are empty - hence started with docker run
|
# Checking if compose-values are empty - hence started with docker run
|
||||||
|
|||||||
@@ -49,4 +49,6 @@ Content-Transfer-Encoding: 7bit
|
|||||||
$MessageBody
|
$MessageBody
|
||||||
From $SenderName
|
From $SenderName
|
||||||
__EOF
|
__EOF
|
||||||
|
# This ensures DSM's container manager will also see the update
|
||||||
|
/var/packages/ContainerManager/target/tool/image_upgradable_checker
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ send_notification() {
|
|||||||
|
|
||||||
# Setting the MessageTitle and MessageBody variable here.
|
# Setting the MessageTitle and MessageBody variable here.
|
||||||
MessageTitle="${FromHost} - updates available."
|
MessageTitle="${FromHost} - updates available."
|
||||||
printf -v MessageBody "🐋 Containers on $FromHost with updates available:\n$UpdToString"
|
printf -v MessageBody "Containers on $FromHost with updates available:\n$UpdToString"
|
||||||
|
|
||||||
# Modify to fit your setup:
|
# Modify to fit your setup:
|
||||||
GotifyToken="Your Gotify token here"
|
GotifyToken="Your Gotify token here"
|
||||||
@@ -24,6 +24,6 @@ send_notification() {
|
|||||||
-F "title=${MessageTitle}" \
|
-F "title=${MessageTitle}" \
|
||||||
-F "message=${MessageBody}" \
|
-F "message=${MessageBody}" \
|
||||||
-F "priority=5" \
|
-F "priority=5" \
|
||||||
-X POST "${GotifyUrl}" &> /dev/null
|
-X POST "${GotifyUrl}" 1> /dev/null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user