linux进程监控脚本(/proc/$pid/status)

本文介绍了一个使用shell脚本监控Linux进程的方法,通过读取/proc/$pid/status文件,定期记录指定PID的进程信息,适用于包括嵌入式环境在内的各种场景。脚本提供了参数选项,可设置监控间隔时间和日志文件名。
摘要由CSDN通过智能技术生成
进程信息监控:除free top外,最靠谱的就是 /proc/$pid/status,该文件会实时记录进程的
内存占用、文件占用、信号处理等各种资源占用状况,具体内容看参照相关文档


下面的源码主要是实现了一个进程监控脚本,定时记录给定pid进程的信息,以供后期分析
为考虑可移植性即嵌入式环境的使用,脚本没有采用外部的命令

[root@linux mem_monitor]# cat process_monitor.sh 

#!/bin/sh
#process_monitor.sh monitor a process  statics by pid 


#Copyright (C) <2013> Jiancheng Li
#Written by Jiancheng Li ,August 2013.
#e-mail:jiancheng.leei@gmail.com    
     


#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.


#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; wi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值