Skip to content

Instantly share code, notes, and snippets.

@Medeirox
Created October 5, 2022 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Medeirox/42efb93de6fe630ecab7e7307175c841 to your computer and use it in GitHub Desktop.
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
#!/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