shell脚本监控调度器/proc进程是否运行(嵌套循环)
/proc/<pid>/schedstat $cat /proc//schedstat First: time spent on the cpu, task->se.sum_exec_runtime,这个值与上面的se.sum_exec_runtime一样只是上面的除于1,,
Second:time spent waiting on a runqueue,这个值与上面的se.wait_sum一样
Third: of times run on this cpu, task->sched_info.pcount,这个值跟上面的se->nr_switches一样 se.sum_exec_runtime: 2843625.998498 //累计运行的物理时间时间
se.wait_sum : 15.615407 //累计在就绪队列里的等待时间
#!/bin/bash while [ ] #监控进程一直做死循环操作 do
for process_pid in $(ps aux|grep 1ea171ed |awk '{print $2}'|grep -v ) #循环查找含"1ea171ed"的进程号 do
echo $process_pid pre_schedstat=`cat /proc/$process_pid/schedstat |awk '{print $1}'` #取 进程的 schedstat 相关数值
echo $pre_schedstat sleep
last_schedstat=`cat /proc/$process_pid/schedstat |awk '{print $1}'` #取 30秒后进程的 schedstat 相关数值
echo $last_schedstat if [ $pre_schedstat -eq $last_schedstat ];then # 如果前后数值保持不变,则做kill - 处理
kill - $process_pid
echo " success kill dead process $process_pid "
fi done
sleep done
shell脚本监控调度器/proc进程是否运行(嵌套循环)的更多相关文章
- 使用Shell脚本对Linux系统和进程资源进行监控
ShellLinux脚本 摘要:Shell语言对于接触Linux的人来说都比较熟悉,它是系统的用户界面,提供了用户与内核进行交互操作的一种接口.本文我们以Bash做为实例总结了使用Shell对系统和进 ...
- 使用 shell 脚本对 Linux 系统和进程资源进行监控
Shell 简介 Shell 语言对于接触 LINUX 的人来说都比较熟悉,它是系统的用户界面,提供了用户与内核进行交互操作的一种接口.它接收用户输入的命令并把它送入内核去执行.实际上 Shell 是 ...
- 用shell脚本监控进程是否存在 不存在则启动的实例
用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货: #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ]th ...
- linux shell脚本监控进程是否存在
用shell脚本监控进程是否存在 不存在则启动的实例,先上代码干货: #!/bin/shps -fe|grep processString |grep -v grepif [ $? -ne 0 ...
- shell脚本监控Linux系统性能指标
2016-11-04 22:41 原作者不详 分类: Linux(7) 在服务器运维过程中,经常需要对服务器的各种资源进行监控, 例如:CPU的负载监控,磁盘的使用率监控,进程数目监控等等,以在系统出 ...
- Linux简单Shell脚本监控MySQL、Apache Web和磁盘空间
Linux简单Shell脚本监控MySQL.Apache Web和磁盘空间 1. 目的或任务 当MySQL数据库.Apache Web服务器停止运行时,重新启动运行,并发送邮件通知: 当服务器磁盘的空 ...
- shell脚本监控网站状态
shell脚本监控网站状态 #!/bin/sh date=`date +"%Y%m%d-%H%M"` title="status" contentFail=&q ...
- Shell脚本监控Linux某个后台进程,当进程死掉后重新启动服务,以httpd为例
Shell脚本如下: vim monitor.sh #!/bin/bash while true # 无限循环 flag=`ps -aux |grep "httpd" |grep ...
- shell脚本监控MySQL服务是否正常
监控MySQL服务是否正常,通常的思路为:检查3306端口是否启动,ps查看mysqld进程是否启动,命令行登录mysql执行语句返回结果,php或jsp程序检测(需要开发人员开发程序)等等: 方法1 ...
随机推荐
- IActionResult
- HDU 1066 Last non-zero Digit in N!(数论,大数,wait)
The expression N!, read as "N factorial," denotes the product of the first N positive inte ...
- volatile 和 Interlocked
class Volatile_Test3 { ; public static void Test() { count = ; Task[] tasks = ]; ; i < tasks.Leng ...
- Web应用程序指纹识别工具BlindElephant
Web应用程序指纹识别工具BlindElephant BlindElephant是一款Web应用程序指纹识别工具.该工具可以读取目标网站的特定静态文件,计算其对应的哈希值,然后和预先计算出的哈希值 ...
- error和exception的区别
------解决方法--------------------------------------------------------了解异常与错误的区别,并且知道当你截获一个异常时,应该怎么办. ...
- [xsy1294]sub
给出一棵$N$个节点的无根树,节点$i$有权值$v_i$.现在有$M$次操作,操作有如下两种: $1\ x\ y$ 将节点$x$的权值$v_x$修改为$y$ $2$ 选择一个联通块(也可以不选择),使 ...
- [Contest20180325]序列
Hogura有一个序列$a$,她希望你帮她维护下面的这些操作. $1\ l\ r\ x$对$l\leq i\leq r$的$a_i$执行$a_i=a_i+x$ $2\ l\ r\ x$对$l\leq ...
- 线程协作-Semaphore并发限制
Semaphore(信号量)是用来控制同时访问特定资源的线程数量,它通过协调各个线程,以保证合理的使用公共资源.
- linux-统计文件中相同行的数量
cat sorttest | sort | uniq -c sorttest文件内容如下
- Eclipse快速补全快捷键Ctrl+1修改为Android Studio的Alt+Enter
步骤: Window ->Preferences->key-> type filter text 下输入quick fix(这个是快速补全的快捷键)改为Alt+Enter 下面的wh ...