Linux中,某个进程消耗的CPU,
需要查看proc/{pid}/stat
该数据结构体如下:
typedef struct statstruct_proc {
int pid; /** The process id. **/
char exName [_POSIX_PATH_MAX]; /** The filename of the executable **/
char state; /** 1 **/ /** R is running, S is sleeping,
D is sleeping in an uninterruptible wait,
Z is zombie, T is traced or stopped **/
unsigned euid, /** effective user id **/
egid; /** effective group id */
int ppid; /** The pid of the parent. **/
int pgrp; /** The pgrp of the process. **/
int session; /** The session id of the process. **/
int tty; /** The tty the process uses **/
int tpgid; /** (too long) **/
unsigned int flags; /** The flags of the process. **/
unsigned int minflt; /** The number of minor faults **/
unsigned int cminflt; /** The number of minor faults with childs **/
unsigned int majflt; /** The number of major faults **/
unsigned int cmajflt; /** The number of major faults with childs **/
int utime; /** user mode jiffies **/
int stime; /** kernel mode jiffies **/
int cutime; /** user mode jiffies with childs **/
int cstime; /** kernel mode jiffies with childs **/
int counter; /** process's next timeslice **/
int priority; /** the standard nice value, plus fifteen **/
unsigned int timeout; /** The time in jiffies of the next timeout **/
unsigned int itrealvalue; /** The time before the next SIGALRM is sent to the process **/
int starttime; /** 20 **/ /** Time the process started after system boot **/
unsigned int vsize; /** Virtual memory size **/
unsigned int rss; /** Resident Set Size **/
unsigned int rlim; /** Current limit in bytes on the rss **/
unsigned int startcode; /** The address above which program text can run **/
unsigned int endcode; /** The address below which program text can run **/
unsigned int startstack; /** The address of the start of the stack **/
unsigned int kstkesp; /** The current value of ESP **/
unsigned int kstkeip; /** The current value of EIP **/
int signal; /** The bitmap of pending signals **/
int blocked; /** 30 **/ /** The bitmap of blocked signals **/
int sigignore; /** The bitmap of ignored signals **/
int sigcatch; /** The bitmap of catched signals **/
unsigned int wchan; /** 33 **/ /** (too long) **/
int sched, /** scheduler **/
sched_priority; /** scheduler priority **/
} procinfo;
分享到:
相关推荐
本文介绍了通过Linux系统的内核观察/proc/pid/statm,文中解释了输出内容的参数,通过内核代码,我们可以更加清楚的了解proc的机制。
// CPU占用率计算原理:// 1、读取/proc/pid/stat文件,其中记录了从开机到现在,本进程所占用的CPU时间(单位jiffies)// 2、然后再读取/proc/stat文件,其中记录了从开机到现在,系统所占用的CPU时间(单位jiffies...
读取/proc/cmdline 文件中的标志位信息。。
一个应用程序,可以通过读取/proc/net/xt_qtaguid/stats来分析应用程序的流量
linux平台下,读取/proc/cpuinfo获取CPU信息demo
Emmagee是将选中应用的PID传入,读取/proc/PID/stat文件信息及可获取该PID对应程序的CPU信息。 2、监控应用消耗流量 系统中有存放整体流量和针对当程序的流量统计,/proc/net/dev和/proc/uid_stat/UID下存放tcp_...
根据proc目录下的stat计算cpu的使用和内存使用情况
有用的Linux命令方便学习 部分展示 系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件...cat /proc/mounts 显示已加载的文件系统
1.3 IDE接口信息 /proc/ide 1.4 网络统计信息 /proc/net 1.5 SCSI接口信息 /proc/scsi 1.6 并行端口信息 /proc/parport 1.7 TTY端口信息 /proc/tty 2 调整内核参数 2.1 /proc/sys/fs - 文件系统数据 2.2 /proc/sys/...
linux下c/c++ 实现cpu使用率查询,内存使用率查询,当个程序使用查询 主要应用/proc/stat /proc/meminfo /proc/pid/stat /proc/pid/status 等文件中的内容进行计算
/usr/bin/env Python import os def load_stat(): loadavg = {} f = open(“/proc/loadavg”) con = f.read().split() f.close() loadavg[‘lavg_1’]=con[0] loadavg[‘lavg_5’]=con[1] loadavg[‘lavg_15’]=con...
经典的proc/proc++程序设计(英文版)
spring@linux-njgq:~> cat /proc/cpuinfo processor : 0 vendor_id : AuthenticAMD cpu family : 18 model : 1 model name : AMD A6-3400M APU with Radeon(tm) HD Graphics stepping : 0 cpu MHz : 1397.500 cache ...
PROC简介 3. 宿主变量与指示变量 4. 嵌入SQL语句
cat /proc/cpuinfo //显示CPU info的信息 cat /proc/interrupts // 显示中断 cat /proc/meminfo //校验内存使用 cat /proc/swaps //显示哪些swap被使用 cat /proc/version //显示内核的版本 cat /proc/...
Oracle 推出了一个在 C/C++ 代码中直接嵌入 SQL 的方法, 然后通过 Oracle 提供的预编译程序, 编译成SQLLIB的调用, 这就是 Pro*C/C++
echo 1 > /proc/sys/vm/drop_caches 3.清理后内存使用情况 free -m 4.完成! 查看内存条数命令: dmidecode | grep -A16 Memory Device$ # sync # echo 1 > /proc/sys/vm/drop_caches echo 2 > /proc/sys/vm/...
大师写的Interrupts and Exceptions
Android获取系统cpu信息,内存,版本,电量等信息 1、CPU频率,CPU信息:/proc/cpuinfo和/proc/stat 通过读取文件/proc/cpuinfo系统CPU的类型等多种信息。读取/proc/stat 所有CPU活动的信息来计算CPU使用率 下面我们...
cat /proc/cpuinfo 显示CPU info的信息 cat /proc/interrupts 显示中断 cat /proc/meminfo 校验内存使用 cat /proc/swaps 显示哪些swap被使用 cat /proc/version 显示内核的版本 cat /proc/net/dev 显示网络...