Publish dropbox "files remaining" as statsd metrics
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
statsd=localhost:8125 | |
dropbox=$HOME/bin/dropbox.py | |
socat=/usr/bin/socat | |
grep=/bin/grep | |
sed=/bin/sed | |
# Example output of `drobox.py status` | |
# ``` | |
# Syncing (51,938 files remaining, 2 mins left) | |
# Downloading 51,938 files (3,069 KB/sec, 2 mins left) | |
# ``` | |
# The line below picks out the number "51938" in a crude way | |
N=$($dropbox status | $grep remaining | $sed -e 's/remaining.*//g' -e 's/[^0-9]//g') | |
# Not found? | |
[[ "x$N" == "x" ]] && exit 1 | |
# Emit metric | |
printf 'dropbox`files_remaining:%d|g\n' $N | $socat -t 0 STDIN UDP:$statsd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put that into your user's cron: