#!/bin/bash
free=$(free -h | grep "Mem" | awk '{print $4}' | cut -d "." -f 1)
if [ -n "$free" ];then
if [ $free -le 3 ];then
echo "free height $free" | mailx -s "内存过高警告" tuobalongshen@126.com
fi
fi
disk=$(df -h | grep "sda1" | awk '{print $5}' | cut -d "%" -f 1)
if [ -n "$disk" ];then
if [ $disk -ge 80 ];then
echo "disk height $disk" | mailx -s "磁盘使用率警告" tuobalongshen@126.com
fi
fi
cpu=$(top -n 1 | grep "Cpu" | awk 'BEGIN{FS=","}{print $4}' | cut -d "." -f 1)
if [ -n "$cpu"];then
if [ $cpu -le 30 ];then
echo "cpu height $cpu" | mailx -s "CPU使用率警告" tuobalongshen@126.com
fi
fi