I want to get the information for currently running processes, ex: memory usage, cpu usage etc..and I need to get this information repeatedly, after every fixed interval of time. Which would be a better option:
- To use a kernel module Or it can be done in user space ?
If in kernel module then:
- Is thr a Signal that can be catched that tells me if thr is a change in the schedular's current running processes ?
- Or else should I keep polling the schedular every fixed interval of time ?
Thx for ur help in advance.
-gc
Perhaps you should learn a
Perhaps you should learn a little about Linux before getting into kernel module programming.
Oh and to answer your question: Yes, it can be done in user space. How the fuck do you think top does it?
Oh you've never heard about top, have you? Haven't heard of ps either?
Alright Linux Kernel
Alright Linux Kernel Guru...
I guess u got my question wrong, I want to know which is a better design approach. I have seen the code for procps and have also tried out getting process information from kernel module.
So, plz don't reply if u think ur the only Mr.Knowall fucker...
-gc
Your question "Or it can be
Your question "Or it can be done in user space ?" implies that you do not know whether it can be done in userspace.
running processes
you can use commands like ps -aux to know what are the running process and their id's.
ramana,
cell:(+91)9848955782.
running processes
Hi,
In my opinion, you could use userspace to get those informations.
There is some programs that already does it. Try to use them like a model.
( top, htop, ps )
Good Luck!
Regards,
Douglas Landgraf
Thanks
Thanks for you reply Douglas.
This is exactly what I am planning to do.
-gc
/sys and /proc information available as well
On top of the other mentioned commands, another option will be the /proc and /sys interfaces. Eg, looking at Ingo Molnar's script for CPU scheduling debugging below:
[ -e /proc/sched_debug ] || echo "not a CFS kernel? continuing anyway."
[ "`id | grep root`" = "" ] && echo "please run this as root!"
FILE=cfs-debug-info-`date +%Y.%m.%d-%H.%M.%S`
echo "sched info dump (of tasks, modules, hw, dmesg, config, fs):"
echo "-- /proc/sched_debug: --" > $FILE
cat /proc/sched_debug >> $FILE 2>/dev/null
echo "-- /proc/*/task/*/sched: --" >> $FILE
cat /proc/*/task/*/sched >> $FILE 2>/dev/null
echo "-- /proc/sys/kernel/sched: --" >> $FILE
for N in /proc/sys/kernel/sched*; do
echo $N: >> $FILE 2>/dev/null
cat $N >> $FILE 2>/dev/null
done
echo "-- modules: --" >> $FILE
/sbin/lsmod >> $FILE 2>/dev/null
echo "-- hw: --" >> $FILE
/sbin/lspci >> $FILE 2>/dev/null
echo "-- interrupts: --" >> $FILE
cat /proc/interrupts >> $FILE 2>/dev/null
echo "-- cpuinfo: --" >> $FILE
cat /proc/cpuinfo >> $FILE 2>/dev/null
echo "-- cpufreq: --" >> $FILE
cat /sys/devices/system/cpu/cpu*/cpufreq/* \
>> $FILE 2>/dev/null
echo "-- meminfo: --" >> $FILE
cat /proc/meminfo >> $FILE 2>/dev/null
echo "-- buddyinfo: --" >> $FILE
cat /proc/buddyinfo >> $FILE 2>/dev/null
echo "-- vmstat: --" >> $FILE
cat /proc/vmstat >> $FILE 2>/dev/null
echo "-- zoneinfo: --" >> $FILE
cat /proc/zoneinfo >> $FILE 2>/dev/null
echo "-- slabinfo: --" >> $FILE
cat /proc/slabinfo >> $FILE 2>/dev/null
echo "-- dmesg: --" >> $FILE
dmesg -s 10000000 >> $FILE 2>/dev/null
echo "-- /proc/timer_list: --" >> $FILE
cat /proc/timer_list >> $FILE 2>/dev/null
echo "-- /proc/timer_info: --" >> $FILE
cat /proc/timer_info >> $FILE 2>/dev/null
echo "-- /proc/config.gz: --" >> $FILE
zcat /proc/config.gz >> $FILE 2>/dev/null
echo "-- filesystems: --" >> $FILE
mount >> $FILE 2>/dev/null
echo "-- uptime: --" >> $FILE
uptime >> $FILE 2>/dev/null
echo "-- uname: --" >> $FILE
uname -a >> $FILE 2>/dev/null
echo "gathering statistics for 15 seconds ..."
echo "-- top: --" >> $FILE
top -c -b -d 1 -n 5 >> $FILE 2>/dev/null
echo "-- vmstat: --" >> $FILE
vmstat -n 1 5 >> $FILE 2>/dev/null
for ((i=0; i<5; i++)); do
echo "-- sched_debug #$i: --" >> $FILE
date >> $FILE
cat /proc/sched_debug >> $FILE 2>/dev/null
sleep 1
done
ls -l $FILE