Created
September 10, 2012 01:27
-
-
Save parndt/3688311 to your computer and use it in GitHub Desktop.
Put Orcon Usage information in your OS X Terminal upon login
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
# Put this in your ~/.bash_profile down the bottom or somewhere | |
echo "Current usage: $(cat ~/.orcon_usage)" |
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
# Install this into your crontab | |
# crontab -e | |
# Runs every 2 hours (*/2 is every alternate hour) | |
0 */2 * * * /bin/bash -c '. $HOME/.bashrc && ~/bin/update_orcon' |
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 | |
# Returns current Orcon usage information | |
# Put in ~/bin/update_orcon | |
# Bonus points for improving the quickly hacked together grep/sed combo. | |
curl --silent http://www.orcon.net.nz/modules/usagemeter/view/usage.php | grep "Total Usage" -A 1 | grep "<dd>" | sed 's/<dd>//' | sed 's/<\/dd>//' | sed 's/\ *//g' | sed 's/ //' > ~/.orcon_usage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment