Comments (6)
Ah, christ. That's embarassing. I forgot that the main script handled regctl automatically.
dc_brief outputs exactly as I desire with your suggested edits. Thanks for putting up with me fellas.
from dockcheck.
I'm not entirely sure what your wished output should look like. But in the extras
directory there's a file called dc_brief.sh
, with some modifications that might give you the result you need?
I'll gladly try to help you out.
Maybe this is a start? Wont show progress, just the list of containers with updates available when done.
#!/usr/bin/env bash
### If not in PATH, set full path. Else just "regctl"
regbin="regctl"
### options to allow exclude:
while getopts "e:" options; do
case "${options}" in
e) Exclude=${OPTARG} ;;
*) exit 0 ;;
esac
done
shift "$((OPTIND-1))"
### Create array of excludes
IFS=',' read -r -a Excludes <<< "$Exclude" ; unset IFS
SearchName="$1"
for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') ; do
for e in "${Excludes[@]}" ; do [[ "$i" == "$e" ]] && continue 2 ; done
RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}')
LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}')
### Checking for errors while setting the variable:
if RegHash=$($regbin image digest --list "$RepoUrl" 2>/dev/null) ; then
if [[ "$LocalHash" = *"$RegHash"* ]] ; then NoUpdates+=("$i"); else GotUpdates+=("$i"); fi
else
GotErrors+=("$i")
fi
done
### Sort arrays alphabetically
IFS=$'\n'
NoUpdates=($(sort <<<"${NoUpdates[*]}"))
GotUpdates=($(sort <<<"${GotUpdates[*]}"))
GotErrors=($(sort <<<"${GotErrors[*]}"))
unset IFS
if [[ -n ${GotUpdates[*]} ]] ; then
printf "%s\n" "${GotUpdates[@]}"
fi
Or you could write them to a file if you'd like, just replace the last bit printf "%s\n" "${GotUpdates[@]}"
with printf "%s\n" "${GotUpdates[@]}" > FileName.txt
from dockcheck.
Couldn't he use notify_generic.sh and tweak it to print exactly what he wants in an easy to grep form?
from dockcheck.
In truth, I didn't notice the Extras folder entirely :V
I'm not extremely well versed in Linux still, so apologies for the vagueness of my request. I use Telegraf to collect metrics which it then pushes to my Grafana dashboard. It has an option to run scripts and send their output as metrics, and I'd only need the amount of containers with updates available for what I want to display. So an ideal output would literally just be the number of containers with updates available, and nothing else at all, for easier parsing.
DC_Brief seems like it'd be the easiest option for this, but it doesn't seem to work on my system. Just outputs the containers that cannot update due to errors, and nothing after that. I tried your provided script as well, but that didn't output anything at all.
Renaming notify_generic to just notify.sh doesn't seem to apply it properly for me either, it never prints anything more than Dockcheck does.
from dockcheck.
Renaming notify_generic to just notify.sh doesn't seem to apply it properly for me either, it never prints anything more than Dockcheck does.
Don't forget the -i to turn on information notification. If you have no outdated containers the notification doesn't get called at all.
sudo dockcheck.sh -n -s -i
Generic notification addon:
The following 1 docker containers on TestHost need to be updated:
pihole-nightly
I tweaked the print statement to include the number of outdated containers as follows. If you improve the notify_generic.sh file the dev may merge your changes.
printf "\nThe following ${#Updates[@]} docker containers on %s need to be updated:\n%s\n" "$FromHost" "$UpdToString"
from dockcheck.
DC_Brief seems like it'd be the easiest option for this, but it doesn't seem to work on my system. Just outputs the containers that cannot update due to errors, and nothing after that. I tried your provided script as well, but that didn't output anything at all.
Well that sounds like it's probably due to not editing the regbin="regctl"
line. Which has to correspond to the regctl-binary - either by full path, alias or that the binary is in placed $PATH
So for example if you've pasted the text above to a script called dcb.sh
and placed the regctl binary in the same path, just edit the script to say regbin=./regctl
or preferably full path /path/to/file/regctl
.
Renaming notify_generic to just notify.sh doesn't seem to apply it properly for me either, it never prints anything more than Dockcheck does.
Odd - even when you run the script with the flags -ni
as @yoyoma2 suggested?
Also if I understand you correctly you'd just like the number of containers as a plain number as the result?
Like
./dcb.sh
5
If you use the notify.sh you would still get the output of the script, so that's not very clean. But could be done with just pasting this code in a new file called notify.sh
and running the regular script with -ni
flags
send_notification() {
Updates=("$@")
UpdCount="${#Updates[@]}"
printf "\n%s\n" "$UpdCount"
But to just get the number as an output, I'd use what I pasted above (a modification of the dc_brief.sh
) and just add a #
-sign to the array printed.
So on the 2nd to last row it would be: printf "%s\n" "${#GotUpdates[@]}"
(after you've sorted the regbin-bit).
from dockcheck.
Related Issues (20)
- [FEATURE REQUEST] email notification (patch included) HOT 3
- Only update container if the new container is X days old HOT 6
- [FEATURE REQUEST] monochrome mode HOT 6
- [Feature Request] Update docker-compose stacks and/or Respect docker-compose "depends_on" HOT 11
- Raspberry Pi - Cannot install regctl HOT 3
- [chore] forgot to add the v0.3.2 branch :) HOT 1
- [Feature] Integration for pushbullet support - script attached HOT 3
- Add capability to authenticate with docker account when pulling images HOT 5
- [FEATURE REQUEST] save preference regarding updates (git/curl) HOT 1
- [FEATURE REQUEST] Add option do define/use multiple .env-files HOT 10
- Progress bar fails with -s option HOT 3
- [FEATURE REQUEST] Automatically download latest in use notification add-on HOT 3
- [Feature] Add -v flag for version number printing of dockcheck HOT 1
- [FEATURE REQUEST] Add Link to GitHub repo HOT 3
- Show current/available image version HOT 4
- [FEATURE REQUEST] Telegram notification HOT 3
- Readme: add install instructions HOT 5
- [Feature Request] - Web Interface Productivity Improvements / Updates Suggestions HOT 2
- Idea: package the repo into an container HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockcheck.