solaris 기반의 kstat 라이브러리 사용방법 -_-;

익명 사용자의 이미지

bsg님의 답변이 힌트가 되어
google을 무지막지 하게 뒤진 끝에 몇가지 샘플코드를 얻었습니다.
샘플코드, kstat관련 헤더파일, man page 모두 참조한 결과

cpu usage, loadavg, network in/out bound packets

이렇게 세가지의 정보를 커널에서 직접 가져올 수가 있었습니다.

그런데, 아직도 풀리지 않는 수수께끼..-_-;

1. network 의 특정 디바이스 (예를 들어 hme0 )의 트레픽을
packet이 아닌 byte 단위로 가져올 수 있는 방법이 있습니까?
(packets * MTU 를 생각하고 있지만 이건 프로그램이 아닌듯 -_-; )

2. mount된 disk의 디렉토리와, 디스크 사용량, 남은 양도
kstat를 이용해서 가져올 수 있습니까?
가능 하다면 어떤 kstat의 어떤 name 혹은 class를 참조해야 합니까?
(아무리 봐두 다른 것이 있는듯..-_-; )

3. swap 정보와 memory 정보는 kstat를 이용해서 가져올려면
어떤 kstat의 어떤 name 혹은 class를 참조해야 합니까?

으아..
이거 별로 어려운건 아닌듯 한데,
커널이 유지하는 정보의 종류가 디게 많아서 어떤게 어떤건지..도무지..
메뉴얼도 없고, man page도 없고, 참고 도서는 커녕
skel코드 하나 얻기도 하늘에 별따기고..-_-;
죄다 돌려서 볼려구 해두,
값의 의미를 도무지 알수가 없고,
음냐.. 벌써 2주째 밤샘 삽질 중 -_-;

도와주세여~

익명 사용자의 이미지

디스크마운트정보 man statvfs

혹 이 머꼬?
License Error Cannot connect to the license server (zizi)..
for product(SPARCompiler C).
(License server may not have been started)
Cannot connect to license server (-15,12146) Connection refused
cc acomp failed for process.c

익명 사용자의 이미지

시스템 전체의 마운트된 디렉토리 정보와, 용량정보, 사용량 정보를
볼 수 있는 것이 아니라,
full path로 넘겨진 하나의 파일에 대한 정보를 보는 것인 듯한데..
아닌가요?
man page를 보니. -_-;

익명 사용자의 이미지

인터페이스는 kstat_data_lookup(kstat_t *ksp, char *name); 함수에서
name 부분을 "rbytes", "obytes" 를 주시면 됩니다. r => input, o =>
output
mount 된 정보는 함수 조합만으로도 가능합니다. getmntany() 함수등등을
조합해서요..
swap 은 swapctl()함수를 사용하면 가능합니다.

익명 사용자의 이미지

밤 꼴 딱새면서 google이랑 뉴스그룹을 이잡듯이 뒤져도
안되는게, 여기서 질문하면 되네요. -_-;
실마리를 배웠으니 또 삽질하러 가야죠 ^^
감사

익명 사용자의 이미지

df -[kebg] 해서 비교해보소서... 조금씩에 차이가 계상을 어떻게 해야 조정이 되는지 몰르겄지만요.

정녕코 이것의 정체를 알 수 없단 말인가요?
License Error Cannot connect to the license server (zizi)..
for product(SPARCompiler C).
(License server may not have been started)
Cannot connect to license server (-15,12146) Connection refused
cc acomp failed for statvfs.c

#include
#include
#include
#include
int
main ()
{
FILE *fp;
struct vfstab mytab;
struct statvfs buf;

fp = fopen ("/etc/vfstab", "r");

while (!getvfsent (fp, &mytab))
{
printf (" %-10s\t", (mytab.vfs_mountp != NULL) ? mytab.vfs_mountp "-");
printf ("(%-20s)\t",(mytab.vfs_special != NULL) ? mytab.vfs_special "-");

statvfs (mytab.vfs_mountp, &buf);
printf ("block_size %ld (fundamental)%ld\n", buf.f_bsize, buf.f_frsize);
printf ("total_block(fundamental_block_size) %ld\t total_inode%ld\n", buf.f_blocks, uf.f_files);
printf ("blocks_free %ld (non-super-user)%ld\t ", buf.f_bfree, buf.f_bavail);
printf ("inodes_free %ld (non-super-user)%ld\n", buf.f_ffree, buf.f_favail);

printf ("filesysid is %ld\t %s fstype\t", buf.f_fsid, buf.f_basetype);
printf ("flag 0x%08X\t filenamemax %ld\n\n", buf.f_flag, buf.f_namemax);
};
return 0;
}

이대현 wrote..
시스템 전체의 마운트된 디렉토리 정보와, 용량정보, 사용량 정보를
볼 수 있는 것이 아니라,
full path로 넘겨진 하나의 파일에 대한 정보를 보는 것인 듯한데..
아닌가요?
man page를 보니. -_-;

익명 사용자의 이미지

감사합니다~
친절하게 소스까지..-_-;

질문에 답변 하나씩 볼때마다 제가 얼마나 허접인지 절감을...크흑..

뒤늦게 프로그램을 시작해서
삽질에 삽질을 거듭하는 중인데
이런 친절한 답변하나에 제가 힘을 팍팍~ 얻습니다~ ^^

답변을 다는 그날 까지..-.-a

익명 사용자의 이미지

License Error Cannot connect to the license server (zizi)..
for product(SPARCompiler C).
(License server may not have been started)
Cannot connect to license server (-15,12146) Connection refused
cc acomp failed for statvfs.c

lmgrd가 죽은듯하네요.
이것은 선의 라이센스관리 daemon입니다.
개를 restart시키세요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <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].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <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].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <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].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <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].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.