Hi all:
So recently I had an issue where my ATV2 totally ran out of space. So much so that I couldn't even use the rm function, I actually had to use the truncate function first. So I decided to create a script to monitor my disk usage. Here is what I have so far:
I've set mine to write the alert to syslog since I have my syslog sent to a remote monitoring server, but one could also configure it to send an email. I just realized that cron doesn't seem to be installed on the ATV2 which is a slight set back to my plans of having this script run nightly. Has anyone got cron running on an ATV2 or have any other ideas for scheduling this to run?
So recently I had an issue where my ATV2 totally ran out of space. So much so that I couldn't even use the rm function, I actually had to use the truncate function first. So I decided to create a script to monitor my disk usage. Here is what I have so far:
Code:
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 70 ] && [ "$partition" = "/dev/disk0s1s2" ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
logger "Alert: $partition Almost out of disk space $usep%"
fi
done
I've set mine to write the alert to syslog since I have my syslog sent to a remote monitoring server, but one could also configure it to send an email. I just realized that cron doesn't seem to be installed on the ATV2 which is a slight set back to my plans of having this script run nightly. Has anyone got cron running on an ATV2 or have any other ideas for scheduling this to run?