ruby-libgtop2 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/CHANGELOG.txt +30 -0
  2. data/History.txt +6 -0
  3. data/INSTALL.txt +19 -0
  4. data/Manifest.txt +53 -0
  5. data/README.txt +21 -0
  6. data/Rakefile +59 -0
  7. data/TODO +4 -0
  8. data/TUTORIAL.txt +28 -0
  9. data/examples/README +1 -0
  10. data/examples/first.rb +220 -0
  11. data/examples/mountlist.rb +30 -0
  12. data/examples/netload.rb +50 -0
  13. data/examples/procmap.rb +41 -0
  14. data/examples/second.rb +207 -0
  15. data/examples/smp.rb +76 -0
  16. data/examples/sysdeps.rb +86 -0
  17. data/ext/libgtop/MANIFEST +30 -0
  18. data/ext/libgtop/Makefile +149 -0
  19. data/ext/libgtop/extconf.rb +9 -0
  20. data/ext/libgtop/mkmf.log +27 -0
  21. data/ext/libgtop/rb_glibtop.c +61 -0
  22. data/ext/libgtop/rb_glibtop.h +15 -0
  23. data/ext/libgtop/rb_glibtop_cpu.c +69 -0
  24. data/ext/libgtop/rb_glibtop_fsusage.c +43 -0
  25. data/ext/libgtop/rb_glibtop_init.c +25 -0
  26. data/ext/libgtop/rb_glibtop_loadavg.c +42 -0
  27. data/ext/libgtop/rb_glibtop_mem.c +39 -0
  28. data/ext/libgtop/rb_glibtop_mountlist.c +53 -0
  29. data/ext/libgtop/rb_glibtop_msg_limits.c +37 -0
  30. data/ext/libgtop/rb_glibtop_netlist.c +36 -0
  31. data/ext/libgtop/rb_glibtop_netload.c +82 -0
  32. data/ext/libgtop/rb_glibtop_ppp.c +39 -0
  33. data/ext/libgtop/rb_glibtop_proc_args.c +39 -0
  34. data/ext/libgtop/rb_glibtop_proc_kernel.c +50 -0
  35. data/ext/libgtop/rb_glibtop_proc_map.c +69 -0
  36. data/ext/libgtop/rb_glibtop_proc_mem.c +37 -0
  37. data/ext/libgtop/rb_glibtop_proc_open_files.c +65 -0
  38. data/ext/libgtop/rb_glibtop_proc_segment.c +39 -0
  39. data/ext/libgtop/rb_glibtop_proc_signal.c +48 -0
  40. data/ext/libgtop/rb_glibtop_proc_state.c +46 -0
  41. data/ext/libgtop/rb_glibtop_proc_time.c +54 -0
  42. data/ext/libgtop/rb_glibtop_proc_uid.c +58 -0
  43. data/ext/libgtop/rb_glibtop_proclist.c +56 -0
  44. data/ext/libgtop/rb_glibtop_sem_limits.c +40 -0
  45. data/ext/libgtop/rb_glibtop_shm_limits.c +35 -0
  46. data/ext/libgtop/rb_glibtop_swap.c +36 -0
  47. data/ext/libgtop/rb_glibtop_sysdeps.c +78 -0
  48. data/ext/libgtop/rb_glibtop_uptime.c +36 -0
  49. data/lib/libgtop.rb +3 -0
  50. data/lib/libgtop/version.rb +9 -0
  51. data/setup.rb +1585 -0
  52. data/test/ruby-libgtop2_test.rb +11 -0
  53. data/test/test_helper.rb +4 -0
  54. metadata +98 -0
@@ -0,0 +1,37 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #include <glibtop/procuid.h>
11
+
12
+
13
+ static VALUE rb_glibtop_proc_mem(VALUE self, VALUE pid)
14
+ {
15
+ glibtop_proc_mem buf;
16
+ VALUE hash;
17
+
18
+ glibtop_get_proc_mem(&buf, NUM2LONG(pid));
19
+
20
+ hash = rb_hash_new();
21
+
22
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
23
+ rb_hash_aset(hash, rb_str_new2("size"), rb_uint2inum(buf.size));
24
+ rb_hash_aset(hash, rb_str_new2("vsize"), rb_uint2inum(buf.vsize));
25
+ rb_hash_aset(hash, rb_str_new2("resident"), rb_uint2inum(buf.resident));
26
+ rb_hash_aset(hash, rb_str_new2("share"), rb_uint2inum(buf.share));
27
+ rb_hash_aset(hash, rb_str_new2("rss"), rb_uint2inum(buf.rss));
28
+ rb_hash_aset(hash, rb_str_new2("rss_rlim"), rb_uint2inum(buf.rss_rlim));
29
+
30
+ return hash;
31
+ }
32
+
33
+
34
+ void Init_glibtop_proc_mem()
35
+ {
36
+ rb_define_method(cLibGTop, "proc_mem", rb_glibtop_proc_mem, 1);
37
+ }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #if (LIBGTOP_CHECK_VERSION(2, 9, 4))
11
+ #include <glibtop/procopenfiles.h>
12
+
13
+ static VALUE rb_glibtop_proc_open_files(VALUE self, VALUE pid)
14
+ {
15
+ glibtop_proc_open_files buf;
16
+ glibtop_open_files_entry* files;
17
+ VALUE hash, entry_hash, array, socket;
18
+ int i;
19
+
20
+ files = glibtop_get_proc_open_files(&buf, NUM2LONG(pid));
21
+
22
+ hash = rb_hash_new();
23
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
24
+ rb_hash_aset(hash, rb_str_new2("number"), rb_uint2inum(buf.number));
25
+ rb_hash_aset(hash, rb_str_new2("total"), rb_uint2inum(buf.total));
26
+ rb_hash_aset(hash, rb_str_new2("size"), rb_uint2inum(buf.size));
27
+
28
+ array = rb_ary_new();
29
+ rb_hash_aset(hash, rb_str_new2("entry"), array);
30
+
31
+ for ( i = 0; i < buf.number; ++i) {
32
+ entry_hash = rb_hash_new();
33
+ rb_hash_aset(entry_hash, rb_str_new2("fd"), INT2FIX(files[i].fd));
34
+ rb_hash_aset(entry_hash, rb_str_new2("type"), INT2FIX(files[i].type));
35
+ switch (files[i].type) {
36
+ case GLIBTOP_FILE_TYPE_FILE:
37
+ rb_hash_aset(entry_hash, rb_str_new2("file"), rb_str_new2(files[i].info.file.name));
38
+ break;
39
+ case GLIBTOP_FILE_TYPE_PIPE:
40
+ rb_hash_aset(entry_hash, rb_str_new2("pipe"), rb_str_new2("pipe"));
41
+ break;
42
+ case GLIBTOP_FILE_TYPE_INETSOCKET:
43
+ socket = rb_ary_new();
44
+ rb_ary_push(socket, rb_str_new2(files[i].info.sock.dest_host));
45
+ rb_ary_push(socket, INT2FIX(files[i].info.sock.dest_port));
46
+ rb_hash_aset(entry_hash, rb_str_new2("socket"), socket);
47
+ break;
48
+ case GLIBTOP_FILE_TYPE_LOCALSOCKET:
49
+ rb_hash_aset(entry_hash, rb_str_new2("localsocket"), rb_str_new2(files[i].info.localsock.name));
50
+ break;
51
+ }
52
+ rb_ary_push(array, entry_hash);
53
+ }
54
+
55
+ g_free(files);
56
+
57
+ return hash;
58
+ }
59
+
60
+
61
+ void Init_glibtop_proc_open_files()
62
+ {
63
+ rb_define_method(cLibGTop, "proc_open_files", rb_glibtop_proc_open_files, 1);
64
+ }
65
+ #endif
@@ -0,0 +1,39 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #include <glibtop/procsegment.h>
11
+
12
+
13
+ static VALUE rb_glibtop_proc_segment(VALUE self, VALUE pid)
14
+ {
15
+ glibtop_proc_segment buf;
16
+ VALUE hash;
17
+
18
+ glibtop_get_proc_segment(&buf, NUM2LONG(pid));
19
+
20
+ hash = rb_hash_new();
21
+
22
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
23
+ rb_hash_aset(hash, rb_str_new2("text_rss"), rb_uint2inum(buf.text_rss));
24
+ rb_hash_aset(hash, rb_str_new2("shlib_rss"), rb_uint2inum(buf.shlib_rss));
25
+ rb_hash_aset(hash, rb_str_new2("data_rss"), rb_uint2inum(buf.data_rss));
26
+ rb_hash_aset(hash, rb_str_new2("stack_rss"), rb_uint2inum(buf.stack_rss));
27
+ rb_hash_aset(hash, rb_str_new2("dirty_size"), rb_uint2inum(buf.dirty_size));
28
+ rb_hash_aset(hash, rb_str_new2("start_code"), rb_uint2inum(buf.start_code));
29
+ rb_hash_aset(hash, rb_str_new2("end_code"), rb_uint2inum(buf.end_code));
30
+ rb_hash_aset(hash, rb_str_new2("start_stack"), rb_uint2inum(buf.start_stack));
31
+
32
+ return hash;
33
+ }
34
+
35
+
36
+ void Init_glibtop_proc_segment()
37
+ {
38
+ rb_define_method(cLibGTop, "proc_segment", rb_glibtop_proc_segment, 1);
39
+ }
@@ -0,0 +1,48 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #include <glibtop/procsignal.h>
11
+
12
+ #define signal_mask_2_ruby_array(array, signal_mask) \
13
+ array = rb_ary_new2(2); \
14
+ for (i = 0; i < 2; i++){ \
15
+ rb_ary_push(array, rb_uint2inum(signal_mask[i])); \
16
+ }
17
+
18
+
19
+ static VALUE rb_glibtop_proc_signal(VALUE self, VALUE pid)
20
+ {
21
+ glibtop_proc_signal buf;
22
+ VALUE hash, signal, blocked, sigignore, sigcatch;
23
+ int i;
24
+
25
+ glibtop_get_proc_signal(&buf, NUM2LONG(pid));
26
+
27
+ hash = rb_hash_new();
28
+
29
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
30
+
31
+ signal_mask_2_ruby_array(signal, buf.signal);
32
+ signal_mask_2_ruby_array(blocked, buf.blocked);
33
+ signal_mask_2_ruby_array(sigignore, buf.sigignore);
34
+ signal_mask_2_ruby_array(sigcatch, buf.sigcatch);
35
+
36
+ rb_hash_aset(hash, rb_str_new2("signal"), signal);
37
+ rb_hash_aset(hash, rb_str_new2("blocked"), blocked);
38
+ rb_hash_aset(hash, rb_str_new2("sigignore"), sigignore);
39
+ rb_hash_aset(hash, rb_str_new2("sigcatch"), sigcatch);
40
+
41
+ return hash;
42
+ }
43
+
44
+
45
+ void Init_glibtop_proc_signal()
46
+ {
47
+ rb_define_method(cLibGTop, "proc_signal", rb_glibtop_proc_signal, 1);
48
+ }
@@ -0,0 +1,46 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #include <glibtop/procstate.h>
11
+
12
+
13
+ static VALUE rb_glibtop_proc_state(VALUE self, VALUE pid)
14
+ {
15
+ glibtop_proc_state buf;
16
+ char state[2];
17
+ VALUE hash;
18
+
19
+ glibtop_get_proc_state(&buf, NUM2LONG(pid));
20
+
21
+ state[0] = buf.state;
22
+ state[1] = '\0';
23
+
24
+ hash = rb_hash_new();
25
+
26
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
27
+ rb_hash_aset(hash, rb_str_new2("cmd"), rb_str_new2(buf.cmd));
28
+ rb_hash_aset(hash, rb_str_new2("state"), rb_str_new2(state));
29
+ rb_hash_aset(hash, rb_str_new2("uid"), INT2NUM(buf.uid));
30
+ rb_hash_aset(hash, rb_str_new2("gid"), INT2NUM(buf.gid));
31
+ #if (LIBGTOP_CHECK_VERSION(2, 5, 1))
32
+ rb_hash_aset(hash, rb_str_new2("ruid"), INT2NUM(buf.ruid));
33
+ rb_hash_aset(hash, rb_str_new2("rgid"), INT2NUM(buf.rgid));
34
+ rb_hash_aset(hash, rb_str_new2("has_cpu"), INT2NUM(buf.has_cpu));
35
+ rb_hash_aset(hash, rb_str_new2("processor"), INT2NUM(buf.processor));
36
+ rb_hash_aset(hash, rb_str_new2("last_processor"), INT2NUM(buf.last_processor));
37
+ #endif
38
+
39
+ return hash;
40
+ }
41
+
42
+
43
+ void Init_glibtop_proc_state()
44
+ {
45
+ rb_define_method(cLibGTop, "proc_state", rb_glibtop_proc_state, 1);
46
+ }
@@ -0,0 +1,54 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #include <glibtop/proctime.h>
11
+
12
+
13
+ static VALUE rb_glibtop_proc_time(VALUE self, VALUE pid)
14
+ {
15
+ glibtop_proc_time buf;
16
+ VALUE hash, xcpu_list, xcpu;
17
+ int ncpu, i;
18
+
19
+ glibtop_get_proc_time(&buf, NUM2LONG(pid));
20
+
21
+ hash = rb_hash_new();
22
+
23
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
24
+ rb_hash_aset(hash, rb_str_new2("start_time"), rb_uint2inum(buf.start_time));
25
+ rb_hash_aset(hash, rb_str_new2("rtime"), rb_uint2inum(buf.rtime));
26
+ rb_hash_aset(hash, rb_str_new2("utime"), rb_uint2inum(buf.utime));
27
+ rb_hash_aset(hash, rb_str_new2("stime"), rb_uint2inum(buf.stime));
28
+ rb_hash_aset(hash, rb_str_new2("cutime"), rb_uint2inum(buf.cutime));
29
+ rb_hash_aset(hash, rb_str_new2("cstime"), rb_uint2inum(buf.cstime));
30
+ rb_hash_aset(hash, rb_str_new2("timeout"), rb_uint2inum(buf.timeout));
31
+ rb_hash_aset(hash, rb_str_new2("it_real_value"), rb_uint2inum(buf.it_real_value));
32
+ rb_hash_aset(hash, rb_str_new2("frequency"), rb_uint2inum(buf.frequency));
33
+
34
+ ncpu = glibtop_global_server->ncpu ? glibtop_global_server->ncpu : 1;
35
+ xcpu_list = rb_ary_new2(ncpu);
36
+
37
+ for (i = 0; i < ncpu; i++) {
38
+ xcpu = rb_hash_new();
39
+
40
+ rb_hash_aset(xcpu, rb_str_new2("utime"), rb_uint2inum(buf.xcpu_utime[i]));
41
+ rb_hash_aset(xcpu, rb_str_new2("stime"), rb_uint2inum(buf.xcpu_stime[i]));
42
+
43
+ rb_ary_push(xcpu_list, xcpu);
44
+ }
45
+ rb_hash_aset(hash, rb_str_new2("xcpu"), xcpu_list);
46
+
47
+ return hash;
48
+ }
49
+
50
+
51
+ void Init_glibtop_proc_time()
52
+ {
53
+ rb_define_method(cLibGTop, "proc_time", rb_glibtop_proc_time, 1);
54
+ }
@@ -0,0 +1,58 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #include <glibtop/procuid.h>
11
+
12
+
13
+ static VALUE rb_glibtop_proc_uid(VALUE self, VALUE pid)
14
+ {
15
+ glibtop_proc_uid buf;
16
+ VALUE hash, groups;
17
+ int i;
18
+
19
+ glibtop_get_proc_uid(&buf, NUM2LONG(pid));
20
+
21
+ hash = rb_hash_new();
22
+
23
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
24
+ rb_hash_aset(hash, rb_str_new2("uid"), INT2NUM(buf.uid));
25
+ rb_hash_aset(hash, rb_str_new2("euid"), INT2NUM(buf.euid));
26
+ rb_hash_aset(hash, rb_str_new2("gid"), INT2NUM(buf.gid));
27
+ rb_hash_aset(hash, rb_str_new2("egid"), INT2NUM(buf.egid));
28
+ #if (LIBGTOP_CHECK_VERSION(2, 5, 1))
29
+ rb_hash_aset(hash, rb_str_new2("suid"), INT2NUM(buf.suid));
30
+ rb_hash_aset(hash, rb_str_new2("sgid"), INT2NUM(buf.sgid));
31
+ rb_hash_aset(hash, rb_str_new2("fsuid"), INT2NUM(buf.fsuid));
32
+ rb_hash_aset(hash, rb_str_new2("fsgid"), INT2NUM(buf.fsgid));
33
+ #endif
34
+ rb_hash_aset(hash, rb_str_new2("pid"), INT2NUM(buf.pid));
35
+ rb_hash_aset(hash, rb_str_new2("ppid"), INT2NUM(buf.ppid));
36
+ rb_hash_aset(hash, rb_str_new2("pgrp"), INT2NUM(buf.pgrp));
37
+ rb_hash_aset(hash, rb_str_new2("session"), INT2NUM(buf.session));
38
+ rb_hash_aset(hash, rb_str_new2("tty"), INT2NUM(buf.tty));
39
+ rb_hash_aset(hash, rb_str_new2("tpgid"), INT2NUM(buf.tpgid));
40
+ rb_hash_aset(hash, rb_str_new2("priority"), INT2NUM(buf.priority));
41
+ rb_hash_aset(hash, rb_str_new2("nice"), INT2NUM(buf.nice));
42
+
43
+ #if (LIBGTOP_CHECK_VERSION(2, 5, 1))
44
+ groups = rb_ary_new2(buf.ngroups);
45
+ for (i = 0; i < GLIBTOP_MAX_GROUPS && i < buf.ngroups; i++){
46
+ rb_ary_push(groups, INT2NUM(buf.groups[i]));
47
+ }
48
+ rb_hash_aset(hash, rb_str_new2("groups"), groups);
49
+ #endif
50
+
51
+ return hash;
52
+ }
53
+
54
+
55
+ void Init_glibtop_proc_uid()
56
+ {
57
+ rb_define_method(cLibGTop, "proc_uid", rb_glibtop_proc_uid, 1);
58
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+ #include <glibtop/proclist.h>
11
+
12
+
13
+ static VALUE rb_glibtop_proclist(VALUE self, VALUE which, VALUE arg)
14
+ {
15
+ glibtop_proclist buf;
16
+ unsigned int* pids_buf;
17
+ VALUE hash, pids;
18
+ int i;
19
+
20
+ pids_buf = glibtop_get_proclist(&buf, NUM2INT(which), NUM2INT(arg));
21
+
22
+ hash = rb_hash_new();
23
+
24
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
25
+ rb_hash_aset(hash, rb_str_new2("number"), rb_uint2inum(buf.number));
26
+ rb_hash_aset(hash, rb_str_new2("size"), rb_uint2inum(buf.size));
27
+ rb_hash_aset(hash, rb_str_new2("total"), rb_uint2inum(buf.total));
28
+
29
+ pids = rb_ary_new2(buf.number);
30
+ for (i = 0; i < buf.number; i++){
31
+ rb_ary_push(pids, rb_uint2inum(pids_buf[i]));
32
+ }
33
+ rb_hash_aset(hash, rb_str_new2("pids"), pids);
34
+
35
+ g_free(pids_buf);
36
+
37
+ return hash;
38
+ }
39
+
40
+
41
+ void Init_glibtop_proclist()
42
+ {
43
+ rb_define_const(cLibGTop, "KERN_PROC_ALL", INT2FIX(GLIBTOP_KERN_PROC_ALL));
44
+ rb_define_const(cLibGTop, "KERN_PROC_PID", INT2FIX(GLIBTOP_KERN_PROC_PID));
45
+ rb_define_const(cLibGTop, "KERN_PROC_PGRP", INT2FIX(GLIBTOP_KERN_PROC_PGRP));
46
+ rb_define_const(cLibGTop, "KERN_PROC_SESSION", INT2FIX(GLIBTOP_KERN_PROC_SESSION));
47
+ rb_define_const(cLibGTop, "KERN_PROC_TTY", INT2FIX(GLIBTOP_KERN_PROC_TTY));
48
+ rb_define_const(cLibGTop, "KERN_PROC_UID", INT2FIX(GLIBTOP_KERN_PROC_UID));
49
+ rb_define_const(cLibGTop, "KERN_PROC_RUID", INT2FIX(GLIBTOP_KERN_PROC_RUID));
50
+ rb_define_const(cLibGTop, "KERN_PROC_MASK", INT2FIX(GLIBTOP_KERN_PROC_MASK));
51
+ rb_define_const(cLibGTop, "EXCLUDE_IDLE", INT2FIX(GLIBTOP_EXCLUDE_IDLE));
52
+ rb_define_const(cLibGTop, "EXCLUDE_SYSTEM", INT2FIX(GLIBTOP_EXCLUDE_SYSTEM));
53
+ rb_define_const(cLibGTop, "EXCLUDE_NOTTY", INT2FIX(GLIBTOP_EXCLUDE_NOTTY));
54
+
55
+ rb_define_method(cLibGTop, "proclist", rb_glibtop_proclist, 2);
56
+ }
@@ -0,0 +1,40 @@
1
+ /*
2
+ * GLibTop is a wrapper library of a libgtop-2.x
3
+ *
4
+ * @author DATE Ken <itacchi@gmail.com>
5
+ * @see http://rubyforge.org/projects/ruby-libgtop2/
6
+ */
7
+
8
+ #include <ruby.h>
9
+ #include <rb_glibtop.h>
10
+
11
+
12
+ static VALUE rb_glibtop_sem_limits(VALUE self)
13
+ {
14
+ glibtop_sem_limits buf;
15
+ VALUE hash;
16
+
17
+ glibtop_get_sem_limits(&buf);
18
+
19
+ hash = rb_hash_new();
20
+
21
+ rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
22
+ rb_hash_aset(hash, rb_str_new2("semmap"), rb_uint2inum(buf.semmap));
23
+ rb_hash_aset(hash, rb_str_new2("semmni"), rb_uint2inum(buf.semmni));
24
+ rb_hash_aset(hash, rb_str_new2("semmns"), rb_uint2inum(buf.semmns));
25
+ rb_hash_aset(hash, rb_str_new2("semmnu"), rb_uint2inum(buf.semmnu));
26
+ rb_hash_aset(hash, rb_str_new2("semmsl"), rb_uint2inum(buf.semmsl));
27
+ rb_hash_aset(hash, rb_str_new2("semopm"), rb_uint2inum(buf.semopm));
28
+ rb_hash_aset(hash, rb_str_new2("semume"), rb_uint2inum(buf.semume));
29
+ rb_hash_aset(hash, rb_str_new2("semusz"), rb_uint2inum(buf.semusz));
30
+ rb_hash_aset(hash, rb_str_new2("semvmx"), rb_uint2inum(buf.semvmx));
31
+ rb_hash_aset(hash, rb_str_new2("semaem"), rb_uint2inum(buf.semaem));
32
+
33
+ return hash;
34
+ }
35
+
36
+
37
+ void Init_glibtop_sem_limits()
38
+ {
39
+ rb_define_method(cLibGTop, "sem_limits", rb_glibtop_sem_limits, 0);
40
+ }