Linux之监控服务器内存、CPU、磁盘使用率shell脚本

Linux之监控服务器内存、CPU、磁盘使用率shell脚本,第1张

概述监控服务器内存、CPU、磁盘使用率脚本内容(包含邮件告警): #Memory totalMemory=$(free -m | awk -F '[ :]+' 'NR==2{pri

监控服务器内存、cpu、磁盘使用率脚本内容(包含邮件告警):

#MemorytotalMemory=$(free -m | awk -F '[ :]+' NR==2{print }')usedMemory=$(free -m | awk -F NR==2{print })freeMemory=$(free -m|awk  {print }'|sed -n 3p)usedPerMemory=$(awk BEGIN{printf "%.0f",('$usedMemory/'$totalMemory)*100})freePerMemory=$(awk '$freeMemory)logfile=/tmp/monitor.log#alerm dateNow_time=`date +%Y-%m%d %H:%M:%s`#diskdiskusAge=$(df -h | grep /dev/mapper/centos-root | awk -F [ %]+{print })#cpucpuusAge=$(top -b -n 1 |grep cpu|awk {print }'|cut -f 1 -d.)echo $cpuusAge# send mailfunction send_mail(){        mail -s "test alerm" test@163.com < /tmp/monitor.log}if [[ $usedPerMemory" > 90 ]] || [[ $diskusAge$cpuusAge95 ]];then                echo 报警时间:${Now_time}" > $logfile                echo cpu usage:${cpuusAge}%" >>Memory usage:${usedPerMemory}%disk usage:${diskusAge}% $logfile                send_mailfi

 

总结

以上是内存溢出为你收集整理的Linux之监控服务器内存、CPU、磁盘使用率shell脚本全部内容,希望文章能够帮你解决Linux之监控服务器内存、CPU、磁盘使用率shell脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1016368.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存