时间:2021-05-22
复制代码 代码如下:
#!/bin/bash
# March-13-2006
# CPUuse trigger script by Noel
#
# bash code to watch a running program's CPU usage.
# if it's above a set value, it will auto send an email.
# You will need to set a Cron job to run this script every xx minutes
#
# Set some needed things:
#
processToWatch="convert" # in my case I need to watch convert
emailAddress="root@host" # this is my main emailaddress
triggerValue=90 # if the CPU use is above 90% send an email. DO NOT USE a DOT or COMMA!
tempFileName=tmp-cpu # some name of the temp file for the ps, grep data
ps auxww | grep "$processToWatch" | grep -v grep > /tmp/$tempFileName
export LINE
(
read LINE
while [ -n "$LINE" ]
do
set $LINE
read LINE
if [ $(echo "$3" | sed -e 's/\.[0-9]*//g') -gt $triggerValue ]; then
mail -s "CPU message alert for: $processToWatch" $emailAddress <<-END
This is to inform you that the following process: $processToWatch with PID (Process ID) $2 is now using more than your preset $triggerValue value.
Process: $processToWatch is using: $3 of CPU power!
The command used is: $11
END
fi
done
)< /tmp/$tempFileName
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
如果win10专业版程序占用cpu资源较多,系统容易出现运行缓慢,卡慢等故障问题。近期,有小伙伴反馈说自己电脑运行速度总是很慢,检查后发现是服务主机太占cpu,
说明:获取的数据是操作系统整体的资源占用情况,不是当前java进程占用的资源1.获取系统CPU占用情况:importjava.lang.management.M
线上Java应用,在业务高峰期的时候经常出现CPU跑高,需要查看实时的线程占用cpu情况,下面是一个很好用的脚本,可以快速导出每个线程的占用CPU情况,结合js
很多人都遇到过笔记本电脑操作系统突然变慢的情况,CPU资源突然被100%占用是原因之一。以下给大家说几个常见高度占用CPU资源的情况及解决办法:关于CPU100
Shell脚本Shell脚本(shellscript),是一种为shell编写的脚本程序。业界所说的shell通常都是指shell脚本,但读者朋友要知道,she