Linux系统CPU、内存、硬盘、网络、LNMP服务整体监控邮件报警
功能介绍:
1.系统方面:
(1)CPU检查报警
(2)内存检查,自动释放
(3)硬盘检查报警
(4)网络检查
2.服务方面:
(1)NGINX检查报警
(2)PHP检查报警
(3)MySQL检查报警
代码如下:
#!/bin/bash IP=`ifconfig|awk'NR==2{print $2}'|awk-F: '{print $2}'` #一.检查系统情况 #1.CPU检查 echo"##########CPU state show##########" echo"_____________________________________________________________________________________________" top-n 1|grepCpu us=`top-n 1|grepCpu|awk'{print $2}'|awk-F"%"'{print $1}'` us100=`echo"$us*100"|bc|awk-F"."'{print $1}'` #echo us*100 = $us100 sy=`top-n 1|grepCpu|awk'{print $3}'|awk-F"%"'{print $1}'` sy100=`echo"$sy*100"|bc|awk-F"."'{print $1}'` #echo sy*100 = $sy100 cpu_number=`echo"$us100 $sy100"|bc` #echo us*100 sy*100 = $cpu_number if[ $cpu_number -gt "7000"];then echo"$IP CPU is hight"| mail -s "warn!server: $IP CPU is hight"15210942688@163.com else echo-e " |
---|