Conversation
…-cleanup Add loag avg, processes count, general cleanup
| if [ -z $1 ]; then | ||
| containersArray=$(docker ps | awk '{if(NR>1) print $NF}') | ||
| else | ||
| containers="$1" |
There was a problem hiding this comment.
looks like this is maybe a debug feature? but now $containers doesn't seem to be used anywhere, so it's kind a dead end. maybe remove?
|
|
||
| } | ||
|
|
||
| main_loop -t 1.2 $@ |
There was a problem hiding this comment.
what does the -t 1.2 and $@ do here?
There was a problem hiding this comment.
these are all the default arguments to bashsimplecurses
| @@ -0,0 +1,98 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
if you're looking to gold-plate this: https://kvz.io/bash-best-practices.html
There was a problem hiding this comment.
this is a great resource - thank you! I suspect this will be a "one and done" kinda project, but if I go back an do a refactor or for my next project, I'll keep https://bash3boilerplate.sh/ in mind!
| # "system_profiler" exists only on MacOS, if it's not here, then run linux style command for | ||
| # load avg. Otherwise use MacOS style command | ||
| if ! command -v "system_profiler" &>/dev/null; then | ||
| awk '{ print $1 " " $2 " " $3 }' </proc/loadavg |
There was a problem hiding this comment.
how does this script behave if awk is not available?
There was a problem hiding this comment.
poorly! we can be defensive here. see 281286a for such a defense!
There was a problem hiding this comment.
@ch4lox - you'd suggested using docker ps --format '{{json .}}' along with jq. I love this! However, it was gonna be a lot more work and add another item to the fix in 281286a. Given this works "out of the box" with out any extras, Imma pass on it now.
Thanks @firebus for letting me use your PR as code review so I can give @ch4lox feedback on his Signal as feedback from the other month 🙃
Ditto.