Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Publish dropbox "files remaining" as statsd metrics
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
@HeinrichHartmann

This comment has been minimized.

Copy link
Owner Author

@HeinrichHartmann HeinrichHartmann commented Jan 29, 2018

Put that into your user's cron:

$ crontab -l
* * * * * /path/to/dropbox-statsd.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment