Last active
July 12, 2019 22:31
-
-
Save MikaelSmith/d85452ffb58e48bdbd908567caa203e8 to your computer and use it in GitHub Desktop.
Wash / BitBar Examples
This file contains hidden or 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
#!/usr/bin/env wash | |
# Count all and all running EC2 instances | |
running=`find aws -action exec -meta .State.Name running 2>/dev/null | wc -l | xargs` | |
total=`find aws -action exec -meta .State.Name -exists 2>/dev/null | wc -l | xargs` | |
echo EC2 $running / $total | |
# Count S3 buckets | |
buckets=`find aws -maxdepth 4 -path '*/resources/s3/*' 2>/dev/null | wc -l | xargs` | |
echo S3 $buckets | |
# Count docker containers (docker plugin currently only lists running containers) | |
count=`ls docker/containers | wc -l | xargs` | |
echo Docker $count |
This file contains hidden or 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
#!/usr/bin/env wash | |
# Still a work in progress: find all instances that have expired, based on the 'lifetime' tag. | |
# Get the name, lifetime, and creation time of instances a specified 'lifetime'. | |
find . -meta .Tags[?].Key lifetime | xargs -n1 -I {} bash -c "echo {}; meta {} | jq -r '(.Tags[] | select(.Key == \"lifetime\") | .Value), .CreationTime'" |
This file contains hidden or 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
#!/usr/bin/env wash | |
# Filter container logs for warnings in the last 24 hours | |
count=`cat kubernetes/gke_shared-k8s_us-west1-a_shared-k8s-prod/dujour-prod/pods/dujour-6fb5b6f55c-* \ | |
| agrind "* | parse '* WARN ' as timestamp | where timestamp > '$(TZ=UTC date -v -1d '+%Y-%m-%d %H:%M')' | count" \ | |
| /usr/bin/tail -n1` | |
echo Warn -24h $count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://getbitbar.com
Put scripts in ~/Documents/bitbar and run BitBar (or refresh from another bitbar menu).