/proc/stat 와 /proc/meminfo 파일을 생성하는 소스 어디있는지 아시는분 있으세요
다름이 아니구..cpu 와 메모리 사용률에 대한 정보를 알고 싶은데요.
두가지 정보가 어떻게 생성되고 측정되어지는지..궁금해서요..
소스나...제가 궁금한것에 대한 커멘트를 줄수 있으신 분있으시면
말씀좀 해주세요..
그럼 수고하세요.
free란 넘이 둘다 사용한군요 이 녀석이 들어 있는 소스는,
procps인데 이 패키지의 소스를 찾아보세요 rpmfind.net인가에서 보면 될껍니다.
그리고 해당 파일이 어디패키지에 속해있는지 보고 싶으면
$ whereis free free /usr/bin/free /usr/man/man1/free.1.gz /usr/man/man1/free.1 $ rpm -qf /usr/bin/free procps-2.0.6-5
이런식으로 하시면 되겠죠..
#strace free execve("/usr/bin/free", ["free"], [/* 33 vars */]) = 0 brk(0) = 0x804a6c4 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40014000 open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory) open("/lib/i686/mmx/libproc.so.2.0.7", O_RDONLY) = -1 ENOENT (No such file or directory) stat("/lib/i686/mmx", 0xbffff2e4) = -1 ENOENT (No such file or directory) open("/lib/i686/libproc.so.2.0.7", O_RDONLY) = -1 ENOENT (No such file or directory) stat("/lib/i686", 0xbffff2e4) = -1 ENOENT (No such file or directory) open("/lib/mmx/libproc.so.2.0.7", O_RDONLY) = -1 ENOENT (No such file or directory) stat("/lib/mmx", 0xbffff2e4) = -1 ENOENT (No such file or directory) open("/lib/libproc.so.2.0.7", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0555, st_size=44418, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000$\0 \000"..., 4096) = 4096 old_mmap(NULL, 47208, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40015000 mprotect(0x4001d000, 14440, PROT_NONE) = 0 old_mmap(0x4001d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x7000) = 0x4001d000 old_mmap(0x4001f000, 6248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, - 1, 0) = 0x4001f000 close(3) = 0 open("/lib/libc.so.6", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0755, st_size=4101836, ...}) = 0 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\210 \212"..., 4096) = 4096 old_mmap(NULL, 1001532, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40021000 mprotect(0x4010e000, 30780, PROT_NONE) = 0 old_mmap(0x4010e000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xec000) = 0x4010e000 old_mmap(0x40112000, 14396, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, - 1, 0) = 0x40112000 close(3) = 0 mprotect(0x40021000, 970752, PROT_READ|PROT_WRITE) = 0 mprotect(0x40021000, 970752, PROT_READ|PROT_EXEC) = 0 personality(PER_LINUX) = 0 getpid() = 6815 uname({sys="Linux", node="hyuna.zeroin.co.kr", ...}) = 0 open("/proc/uptime", O_RDONLY) = 3 lseek(3, 0, SEEK_SET) = 0 read(3, "2535551.84 2518266.52\n", 1023) = 22 open("/proc/stat", O_RDONLY) = 4 lseek(4, 0, SEEK_SET) = 0 read(4, "cpu 1450238 47 315222 251789677"..., 1023) = 740 lseek(3, 0, SEEK_SET) = 0 read(3, "2535551.84 2518266.52\n", 1023) = 22 open("/proc/meminfo", O_RDONLY) = 5 lseek(5, 0, SEEK_SET) = 0 read(5, " total used free"..., 1023) = 522 fstat64(0x1, 0xbffff044) = 0 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40116000 ioctl(1, TCGETS, {B9600 opost isig icanon echo ...}) = 0 write(1, " total used "..., 74) = 74 write(1, "Mem 385112 380532 "..., 74) = 74 write(1, "-/+ buffers/cache 247492 "..., 41) = 41 write(1, "Swap 634528 1312 "..., 41) = 41 munmap(0x40116000, 4096) = 0 _exit(0) = ?
추가.. 헛. 댓글을 잘못 달았군요 /proc는 커널이 만드는 겁니다. /usr/src/linux/fs/proc/proc_misc.c 를 보세요 제 커널 버전이 2.4.18인데 버젼이 다르면 위치가 다를수도 있겠네요
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
Re: procps 패키지를 보세요
free란 넘이 둘다 사용한군요
이 녀석이 들어 있는 소스는,
procps인데 이 패키지의 소스를 찾아보세요
rpmfind.net인가에서 보면 될껍니다.
그리고 해당 파일이 어디패키지에 속해있는지 보고 싶으면
$ whereis free
free /usr/bin/free /usr/man/man1/free.1.gz /usr/man/man1/free.1
$ rpm -qf /usr/bin/free
procps-2.0.6-5
이런식으로 하시면 되겠죠..
#strace free
execve("/usr/bin/free", ["free"], [/* 33 vars */]) = 0
brk(0) = 0x804a6c4
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40014000
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/lib/i686/mmx/libproc.so.2.0.7", O_RDONLY) = -1 ENOENT (No
such file or directory)
stat("/lib/i686/mmx", 0xbffff2e4) = -1 ENOENT (No such file or
directory)
open("/lib/i686/libproc.so.2.0.7", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat("/lib/i686", 0xbffff2e4) = -1 ENOENT (No such file or
directory)
open("/lib/mmx/libproc.so.2.0.7", O_RDONLY) = -1 ENOENT (No such
file or directory)
stat("/lib/mmx", 0xbffff2e4) = -1 ENOENT (No such file or
directory)
open("/lib/libproc.so.2.0.7", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0555, st_size=44418, ...}) = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000$\0
\000"..., 4096) = 4096
old_mmap(NULL, 47208, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40015000
mprotect(0x4001d000, 14440, PROT_NONE) = 0
old_mmap(0x4001d000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0x7000) =
0x4001d000
old_mmap(0x4001f000, 6248, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -
1, 0) = 0x4001f000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=4101836, ...}) = 0
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\210
\212"..., 4096) = 4096
old_mmap(NULL, 1001532, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) =
0x40021000
mprotect(0x4010e000, 30780, PROT_NONE) = 0
old_mmap(0x4010e000, 16384, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED, 3, 0xec000) =
0x4010e000
old_mmap(0x40112000, 14396, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -
1, 0) = 0x40112000
close(3) = 0
mprotect(0x40021000, 970752, PROT_READ|PROT_WRITE) = 0
mprotect(0x40021000, 970752, PROT_READ|PROT_EXEC) = 0
personality(PER_LINUX) = 0
getpid() = 6815
uname({sys="Linux", node="hyuna.zeroin.co.kr", ...}) = 0
open("/proc/uptime", O_RDONLY) = 3
lseek(3, 0, SEEK_SET) = 0
read(3, "2535551.84 2518266.52\n", 1023) = 22
open("/proc/stat", O_RDONLY) = 4
lseek(4, 0, SEEK_SET) = 0
read(4, "cpu 1450238 47 315222 251789677"..., 1023) = 740
lseek(3, 0, SEEK_SET) = 0
read(3, "2535551.84 2518266.52\n", 1023) = 22
open("/proc/meminfo", O_RDONLY) = 5
lseek(5, 0, SEEK_SET) = 0
read(5, " total used free"..., 1023) = 522
fstat64(0x1, 0xbffff044) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40116000
ioctl(1, TCGETS, {B9600 opost isig icanon echo ...}) = 0
write(1, " total used "..., 74) = 74
write(1, "Mem 385112 380532 "..., 74) = 74
write(1, "-/+ buffers/cache 247492 "..., 41) = 41
write(1, "Swap 634528 1312 "..., 41) = 41
munmap(0x40116000, 4096) = 0
_exit(0) = ?
추가.. 헛. 댓글을 잘못 달았군요
/proc는 커널이 만드는 겁니다.
/usr/src/linux/fs/proc/proc_misc.c 를 보세요
제 커널 버전이 2.4.18인데 버젼이 다르면
위치가 다를수도 있겠네요
댓글 달기