我是shell脚本的初学者,我正在寻找一个脚本来添加为cron作业,可以发送电子邮件或使用top命令的CPU百分比警告电子邮件ID。
此脚本基本上是为了引起用户注意服务器的峰值CPU使用率。如果有任何脚本执行此操作或更好地监视CPU使用率/内存使用情况,请指向我。
谢谢, 阿比
答案 0 :(得分:1)
根据您的mail
在您的linux风格中的位置,您可以尝试
*/10 * * * * /bin/ps -eo pcpu,pid,user,args | /bin/sort -k 1 -r | /bin/mail youremail@where.com
这将每隔10分钟向您发送从最高到最低排序的cpu使用情况。