Created
October 5, 2022 20:08
-
-
Save Medeirox/42efb93de6fe630ecab7e7307175c841 to your computer and use it in GitHub Desktop.
Fetches from the grafana docker logs the days a user has logged in
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
#!/bin/bash | |
# This file checks the docker logs for a container named "grafana" and | |
# checks how many days a user has logged in | |
[ -z "$1" ] && echo "inform user" && exit 0 | |
docker logs grafana 2> /dev/null | grep $1 > /tmp/user-log | |
cat /tmp/user-log | egrep -o '[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}' | sort | uniq | |
count=$(cat /tmp/user-log | egrep -o '[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}' | uniq | wc -l) | |
echo " | |
Days used: "$count" | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment