Created
January 15, 2012 06:16
-
-
Save PhirePhly/1614687 to your computer and use it in GitHub Desktop.
A simple example of how to use cron and bash to generate prowl notifications
This file contains hidden or 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/sh | |
# Kenneth Finnegan, 2012 | |
# kennethfinnegan.blogspot.com | |
# Posts growl notifications to iOS device using prowl & curl | |
# | |
# To have run by cron at 8:30 daily, add the following to your crontab | |
# 30 8 * * * /mnt/storage/scripts/morningreport.sh | |
# 2012 01 14: Initial revision | |
# Fill in with your own API key here | |
APIKEY=2541XXXX4d77 | |
# Make up a cache filename in /tmp/ based on our PID | |
CACHE=/tmp/$$.cache.txt | |
# Where to find statistics about lighttpd web server | |
LOGDIR=/mnt/storage/logs | |
ACC_YESTERDAY=$LOGDIR/lighttpd.access.log.yesterday | |
ACC_TOTAL=$LOGDIR/lighttpd.access.log.total | |
# Generate all text and dump into temp file CACHE | |
tail -n 1 $ACC_TOTAL | \ | |
awk '{print "Web traffic: " $3 " hits from " $2 " IPs "}' > $CACHE | |
df / | tail -n 1 | awk '{print "Root fs usage: " $5 " "}' >> $CACHE | |
df /mnt/storage/ | tail -n 1 | \ | |
awk '{print "SD card fs usage: " $5 " "}' >> $CACHE | |
# Post notification to Prowl using curl | |
curl https://api.prowlapp.com/publicapi/add \ | |
-F apikey=$APIKEY \ | |
-F application=Chumby \ | |
-F event="Morning Report" \ | |
-F description="`cat $CACHE`" | |
rm $CACHE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment