Pushover

From The World according to Vissie
Jump to navigation Jump to search

Check disk space and Pushover a notification if I'm running out of space:

vim: /etc/cron.daily/diskspace.sh
#!/bin/bash
##
## Send data to an android device using Tasker's Auto Remote

torrentid=$1
torrentname=$2
torrentpath=$3

App_Key='aXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
User_Key='uXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Web_Adress='https://api.pushover.net/1/messages'

# set alert level 90% is default
ALERT=90
# Exclude list of unwanted monitoring, if several partions then use "|" to separate the partitions.
# An example: EXCLUDE_LIST="/dev/hdd1|/dev/hdc5"
#EXCLUDE_LIST="/auto/ripper"
#
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#
function main_prog() {
while read output;
do
#echo $output
  usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1)
  partition=$(echo $output | awk '{print $2}')
  if [ $usep -ge $ALERT ] ; then
     echo "Running out of space \"$partition ($usep%)\" on server $(hostname), $(date)" | \
        #mail -s "Alert: Almost out of disk space $usep%" $ADMIN
        curl -s -F "token=$App_Key" -F "user=$User_Key" -F "message=Running out of space \"$partition ($usep%)\" on server $(hostname), $(date) " $Web_Adress
  fi
done
}
if [ "$EXCLUDE_LIST" != "" ] ; then
   df -H | grep -vE "^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}" | awk '{print $5 " " $6}' | main_prog
else
  df -H | grep -vE "^Filesystem|tmpfs|cdrom" | awk '{print $5 " " $6}' | main_prog
fi