#!/usr/bin/sudo bash
# by renato gallo
board_temp=`sensors|grep temp|awk '{print $2}'`
crit_temp=`sensors|grep temp|awk '{print $5}'`
free_disk=`df -h|grep rootfs|awk '{print $4}'`
cpu_idle=`vmstat |tail -n1|awk '{print $15}'`
free_ram_mb=`free -m|grep Mem|awk '{print $4}'`
total_disk=`df -h|grep rootfs|sed 's/[aA-zZ]//g'|awk '{print $1}'`
half_disk=`echo $total_disk/2|bc`
temp_math=`echo "$crit_temp - $board_temp"|sed -e 's/[A-Z]//g' -e 's/�//g' -e 's/)//g' -e 's/+//g'`
temp_alarm=`echo $temp_math|bc|awk -F. '{print $1}'`
disk_alarm=`echo $free_disk|sed 's/[A-Z]//g'`
if [ $cpu_idle -gt 5 ];
then
cpu_status=ok
else
cpu_status="less than 5% and is not ok"
fi
if [ $temp_alarm != 0 ];
then
temp_status=ok
else
temp_status="not ok"
fi
if [ $disk_alarm -lt 10 ];
then
disk_status="not ok"
elseif [ $disk_alarm -eq $half_disk ]
disk_status="a warning because you reach half disk space"
else
disk_status=ok
fi
if [ $free_ram_mb -gt 1 ];
then
memory_status=ok
else
memory_status="not ok"
fi
echo "My name is Jarvis, and I am your management system.
Board temperature is $board_temp on a critical limit of $crit_temp which is $temp_status.
You still have $free_disk available on disk which is $disk_status
Cpu idle is $cpu_idle % which is $cpu_status and you have $free_ram_mb Megabytes of free RAM memory which is $memory_status"|espeak