Cpu usage

From Buzztard

Jump to: navigation, search

Like its done in buzz we would like to show to amount of CPU usage.

[edit] proc filesystem

get general cpuinfo:

cat /proc/cpuinfo

get cpu (not)usage of a process:

#!/bin/sh

root_pid=$1

while true; do
  clear
  for pid in `ls /proc/$root_pid/task/`; do
    cat /proc/$pid/status | grep "Sleep";
  done
  sleep 1s
done

[edit] getrusage

get CPU & memory consumtion among some more things.

int getrusage(int who, struct rusage *usage);

Problem #1 is that we also need total application run-time and #2 that it is not easy to calculate a current CPU usage.

[edit] Links

Personal tools
collaboration

SourceForge Logo

GStreamer Logo

Linux Sound Logo

MediaWiki

Valgrind

GNU Library Public Licence

GNU Free Documentation License 1.2