Last active
May 20, 2019 21:26
-
-
Save epcim/e488af8be69b616eab3088a14a937e14 to your computer and use it in GitHub Desktop.
salt states trends jq yq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install: | |
# wget https://gist.githubusercontent.com/epcim/e488af8be69b616eab3088a14a937e14/raw/salt-trends.sh -O salt-trends.sh; chmod +x *.sh | |
# salt state execution results: (use with/without test=true, -b2, etc..) | |
# apt install -y jq colordiff | |
salt \* state.apply --out=json --static test=true -b15 | jq -r 'to_entries | map({ key:.key, value: { total: [.value[]]|length , | |
succeed: [select(.value>={})|.value[]|select(.result? == true )]|length, | |
failed: [select(.value>={})|.value[]|select(.result? == false)]|length, | |
null: [select(.value>={})|.value[]|select(.result? == null)]|length, | |
changes: [select(.value>={})|.value[]|select(.changes?|length > 0)]|length } }) | from_entries ' |\ | |
tee trend_$(date "+%Y-%m-%d-%s").json | |
tee trend_$(date "+%Y-%m-%d-%s")_${1}.json | |
ls trend*.json| sort |tail -n2 |xargs -n2 diff -y | colordiff | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To display failing state use: