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 ...
随机推荐
- AC日记——Card Game codeforces 808f
F - Card Game 思路: 题意: 有n张卡片,每张卡片三个值,pi,ci,li: 要求选出几张卡片使得pi之和大于等于给定值: 同时,任意两两ci之和不得为素数: 求选出的li的最小值,如果 ...
- IE添加可信任站点,启用ActiveX插件批处理
添加可信任站点IP地址为:192.168.1.108,启用ActiveX插件执行以下批处理命令: reg add "HKCU\Software\Microsoft\Windows\Curre ...
- 浙江省第十二届省赛 B - Team Formation
Description For an upcoming programming contest, Edward, the headmaster of Marjar University, is for ...
- 【转】进程、线程、 GIL全局解释器锁知识点整理
转自:https://www.cnblogs.com/alex3714/articles/5230609.html 本节内容 操作系统发展史介绍 进程.与线程区别 python GIL全局解释器锁 线 ...
- (2)Flutter vscode安装
1. vscode搜索Flutter 点击安装Flutter会自动安装Flutter和Dart 2.打开项目 在vscode File-openFolder打开之前创建的项目 成功显示 如果创建一个新 ...
- CF 115 A 【求树最大深度/DFS/并查集】
CF A. Party time limit per test3 seconds memory limit per test256 megabytes inputstandard input outp ...
- 【Splay】【块状链表】bzoj3223 Tyvj 1729 文艺平衡树
让蒟蒻见识到了常数大+滥用STL的危害. <法一>很久之前的Splay #include<cstdio> #include<algorithm> using nam ...
- 小白的Python之路 day4 不同目录间进行模块调用(绝对路径和相对路径)
一.常用模块调用函数功能解释 1.__file__ 功能:返回自身文件的相对路径 你从pycharm的执行结果可以看出,在pycharm执行atm.py文件时,是从绝对路径下去执行的,而你从cmd下去 ...
- vsftpd修改被动模式数据端口
pasv_enable=YES pasv_min_port=10000 pasv_max_port=20000 我厂只限一个端口段通讯,只能这样改下,否则永远是列出目录失败
- Problem G: 零起点学算法27——等级分制度
#include<stdio.h> int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) +a* ...