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.
- data/CHANGELOG.txt +30 -0
 - data/History.txt +6 -0
 - data/INSTALL.txt +19 -0
 - data/Manifest.txt +53 -0
 - data/README.txt +21 -0
 - data/Rakefile +59 -0
 - data/TODO +4 -0
 - data/TUTORIAL.txt +28 -0
 - data/examples/README +1 -0
 - data/examples/first.rb +220 -0
 - data/examples/mountlist.rb +30 -0
 - data/examples/netload.rb +50 -0
 - data/examples/procmap.rb +41 -0
 - data/examples/second.rb +207 -0
 - data/examples/smp.rb +76 -0
 - data/examples/sysdeps.rb +86 -0
 - data/ext/libgtop/MANIFEST +30 -0
 - data/ext/libgtop/Makefile +149 -0
 - data/ext/libgtop/extconf.rb +9 -0
 - data/ext/libgtop/mkmf.log +27 -0
 - data/ext/libgtop/rb_glibtop.c +61 -0
 - data/ext/libgtop/rb_glibtop.h +15 -0
 - data/ext/libgtop/rb_glibtop_cpu.c +69 -0
 - data/ext/libgtop/rb_glibtop_fsusage.c +43 -0
 - data/ext/libgtop/rb_glibtop_init.c +25 -0
 - data/ext/libgtop/rb_glibtop_loadavg.c +42 -0
 - data/ext/libgtop/rb_glibtop_mem.c +39 -0
 - data/ext/libgtop/rb_glibtop_mountlist.c +53 -0
 - data/ext/libgtop/rb_glibtop_msg_limits.c +37 -0
 - data/ext/libgtop/rb_glibtop_netlist.c +36 -0
 - data/ext/libgtop/rb_glibtop_netload.c +82 -0
 - data/ext/libgtop/rb_glibtop_ppp.c +39 -0
 - data/ext/libgtop/rb_glibtop_proc_args.c +39 -0
 - data/ext/libgtop/rb_glibtop_proc_kernel.c +50 -0
 - data/ext/libgtop/rb_glibtop_proc_map.c +69 -0
 - data/ext/libgtop/rb_glibtop_proc_mem.c +37 -0
 - data/ext/libgtop/rb_glibtop_proc_open_files.c +65 -0
 - data/ext/libgtop/rb_glibtop_proc_segment.c +39 -0
 - data/ext/libgtop/rb_glibtop_proc_signal.c +48 -0
 - data/ext/libgtop/rb_glibtop_proc_state.c +46 -0
 - data/ext/libgtop/rb_glibtop_proc_time.c +54 -0
 - data/ext/libgtop/rb_glibtop_proc_uid.c +58 -0
 - data/ext/libgtop/rb_glibtop_proclist.c +56 -0
 - data/ext/libgtop/rb_glibtop_sem_limits.c +40 -0
 - data/ext/libgtop/rb_glibtop_shm_limits.c +35 -0
 - data/ext/libgtop/rb_glibtop_swap.c +36 -0
 - data/ext/libgtop/rb_glibtop_sysdeps.c +78 -0
 - data/ext/libgtop/rb_glibtop_uptime.c +36 -0
 - data/lib/libgtop.rb +3 -0
 - data/lib/libgtop/version.rb +9 -0
 - data/setup.rb +1585 -0
 - data/test/ruby-libgtop2_test.rb +11 -0
 - data/test/test_helper.rb +4 -0
 - metadata +98 -0
 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            MANIFEST
         
     | 
| 
      
 2 
     | 
    
         
            +
            extconf.rb
         
     | 
| 
      
 3 
     | 
    
         
            +
            rb_glibtop.c
         
     | 
| 
      
 4 
     | 
    
         
            +
            rb_glibtop.h
         
     | 
| 
      
 5 
     | 
    
         
            +
            rb_glibtop_cpu.c
         
     | 
| 
      
 6 
     | 
    
         
            +
            rb_glibtop_fsusage.c
         
     | 
| 
      
 7 
     | 
    
         
            +
            rb_glibtop_init.c
         
     | 
| 
      
 8 
     | 
    
         
            +
            rb_glibtop_loadavg.c
         
     | 
| 
      
 9 
     | 
    
         
            +
            rb_glibtop_mem.c
         
     | 
| 
      
 10 
     | 
    
         
            +
            rb_glibtop_mountlist.c
         
     | 
| 
      
 11 
     | 
    
         
            +
            rb_glibtop_msg_limits.c
         
     | 
| 
      
 12 
     | 
    
         
            +
            rb_glibtop_netlist.c
         
     | 
| 
      
 13 
     | 
    
         
            +
            rb_glibtop_netload.c
         
     | 
| 
      
 14 
     | 
    
         
            +
            rb_glibtop_ppp.c
         
     | 
| 
      
 15 
     | 
    
         
            +
            rb_glibtop_proc_args.c
         
     | 
| 
      
 16 
     | 
    
         
            +
            rb_glibtop_proc_kernel.c
         
     | 
| 
      
 17 
     | 
    
         
            +
            rb_glibtop_proc_map.c
         
     | 
| 
      
 18 
     | 
    
         
            +
            rb_glibtop_proc_mem.c
         
     | 
| 
      
 19 
     | 
    
         
            +
            rb_glibtop_proc_open_files.c
         
     | 
| 
      
 20 
     | 
    
         
            +
            rb_glibtop_proc_segment.c
         
     | 
| 
      
 21 
     | 
    
         
            +
            rb_glibtop_proc_signal.c
         
     | 
| 
      
 22 
     | 
    
         
            +
            rb_glibtop_proc_state.c
         
     | 
| 
      
 23 
     | 
    
         
            +
            rb_glibtop_proc_time.c
         
     | 
| 
      
 24 
     | 
    
         
            +
            rb_glibtop_proc_uid.c
         
     | 
| 
      
 25 
     | 
    
         
            +
            rb_glibtop_proclist.c
         
     | 
| 
      
 26 
     | 
    
         
            +
            rb_glibtop_sem_limits.c
         
     | 
| 
      
 27 
     | 
    
         
            +
            rb_glibtop_shm_limits.c
         
     | 
| 
      
 28 
     | 
    
         
            +
            rb_glibtop_swap.c
         
     | 
| 
      
 29 
     | 
    
         
            +
            rb_glibtop_sysdeps.c
         
     | 
| 
      
 30 
     | 
    
         
            +
            rb_glibtop_uptime.c
         
     | 
| 
         @@ -0,0 +1,149 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            SHELL = /bin/sh
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #### Start of system configuration section. ####
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            srcdir = .
         
     | 
| 
      
 7 
     | 
    
         
            +
            topdir = /usr/lib/ruby/1.8/i686-linux
         
     | 
| 
      
 8 
     | 
    
         
            +
            hdrdir = $(topdir)
         
     | 
| 
      
 9 
     | 
    
         
            +
            VPATH = $(srcdir):$(topdir):$(hdrdir)
         
     | 
| 
      
 10 
     | 
    
         
            +
            prefix = $(DESTDIR)/usr
         
     | 
| 
      
 11 
     | 
    
         
            +
            exec_prefix = $(DESTDIR)/usr
         
     | 
| 
      
 12 
     | 
    
         
            +
            sitedir = $(DESTDIR)/usr/lib/ruby/site_ruby
         
     | 
| 
      
 13 
     | 
    
         
            +
            rubylibdir = $(libdir)/ruby/$(ruby_version)
         
     | 
| 
      
 14 
     | 
    
         
            +
            docdir = $(datarootdir)/doc/$(PACKAGE)
         
     | 
| 
      
 15 
     | 
    
         
            +
            dvidir = $(docdir)
         
     | 
| 
      
 16 
     | 
    
         
            +
            datarootdir = $(prefix)/share
         
     | 
| 
      
 17 
     | 
    
         
            +
            archdir = $(rubylibdir)/$(arch)
         
     | 
| 
      
 18 
     | 
    
         
            +
            sbindir = $(exec_prefix)/sbin
         
     | 
| 
      
 19 
     | 
    
         
            +
            psdir = $(docdir)
         
     | 
| 
      
 20 
     | 
    
         
            +
            localedir = $(datarootdir)/locale
         
     | 
| 
      
 21 
     | 
    
         
            +
            htmldir = $(docdir)
         
     | 
| 
      
 22 
     | 
    
         
            +
            datadir = $(DESTDIR)/usr/share
         
     | 
| 
      
 23 
     | 
    
         
            +
            includedir = $(prefix)/include
         
     | 
| 
      
 24 
     | 
    
         
            +
            infodir = $(DESTDIR)/usr/share/info
         
     | 
| 
      
 25 
     | 
    
         
            +
            sysconfdir = $(DESTDIR)/etc
         
     | 
| 
      
 26 
     | 
    
         
            +
            mandir = $(DESTDIR)/usr/share/man
         
     | 
| 
      
 27 
     | 
    
         
            +
            libdir = $(DESTDIR)/usr/lib
         
     | 
| 
      
 28 
     | 
    
         
            +
            sharedstatedir = $(prefix)/com
         
     | 
| 
      
 29 
     | 
    
         
            +
            oldincludedir = $(DESTDIR)/usr/include
         
     | 
| 
      
 30 
     | 
    
         
            +
            pdfdir = $(docdir)
         
     | 
| 
      
 31 
     | 
    
         
            +
            sitearchdir = $(sitelibdir)/$(sitearch)
         
     | 
| 
      
 32 
     | 
    
         
            +
            bindir = $(exec_prefix)/bin
         
     | 
| 
      
 33 
     | 
    
         
            +
            localstatedir = $(DESTDIR)/var/lib
         
     | 
| 
      
 34 
     | 
    
         
            +
            sitelibdir = $(sitedir)/$(ruby_version)
         
     | 
| 
      
 35 
     | 
    
         
            +
            libexecdir = $(exec_prefix)/libexec
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            CC = i686-pc-linux-gnu-gcc
         
     | 
| 
      
 38 
     | 
    
         
            +
            LIBRUBY = $(LIBRUBY_SO)
         
     | 
| 
      
 39 
     | 
    
         
            +
            LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
         
     | 
| 
      
 40 
     | 
    
         
            +
            LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -L. -l$(RUBY_SO_NAME)
         
     | 
| 
      
 41 
     | 
    
         
            +
            LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            RUBY_EXTCONF_H = 
         
     | 
| 
      
 44 
     | 
    
         
            +
            CFLAGS   =  -fPIC -march=athlon-xp -O2 -pipe  -fPIC -I/usr/include/libgtop-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   
         
     | 
| 
      
 45 
     | 
    
         
            +
            INCFLAGS = -I. -I. -I/usr/lib/ruby/1.8/i686-linux -I.
         
     | 
| 
      
 46 
     | 
    
         
            +
            CPPFLAGS = -DHAVE_GLIBTOP_H 
         
     | 
| 
      
 47 
     | 
    
         
            +
            CXXFLAGS = $(CFLAGS) 
         
     | 
| 
      
 48 
     | 
    
         
            +
            DLDFLAGS =    
         
     | 
| 
      
 49 
     | 
    
         
            +
            LDSHARED = $(CC) -shared
         
     | 
| 
      
 50 
     | 
    
         
            +
            AR = i686-pc-linux-gnu-ar
         
     | 
| 
      
 51 
     | 
    
         
            +
            EXEEXT = 
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            RUBY_INSTALL_NAME = ruby18
         
     | 
| 
      
 54 
     | 
    
         
            +
            RUBY_SO_NAME = ruby18
         
     | 
| 
      
 55 
     | 
    
         
            +
            arch = i686-linux
         
     | 
| 
      
 56 
     | 
    
         
            +
            sitearch = i686-linux
         
     | 
| 
      
 57 
     | 
    
         
            +
            ruby_version = 1.8
         
     | 
| 
      
 58 
     | 
    
         
            +
            ruby = /usr/bin/ruby18
         
     | 
| 
      
 59 
     | 
    
         
            +
            RUBY = $(ruby)
         
     | 
| 
      
 60 
     | 
    
         
            +
            RM = rm -f
         
     | 
| 
      
 61 
     | 
    
         
            +
            MAKEDIRS = mkdir -p
         
     | 
| 
      
 62 
     | 
    
         
            +
            INSTALL = /bin/install -c
         
     | 
| 
      
 63 
     | 
    
         
            +
            INSTALL_PROG = $(INSTALL) -m 0755
         
     | 
| 
      
 64 
     | 
    
         
            +
            INSTALL_DATA = $(INSTALL) -m 644
         
     | 
| 
      
 65 
     | 
    
         
            +
            COPY = cp
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            #### End of system configuration section. ####
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            preload = 
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
            libpath = $(libdir)
         
     | 
| 
      
 72 
     | 
    
         
            +
            LIBPATH =  -L'$(libdir)' -Wl,-R'$(libdir)'
         
     | 
| 
      
 73 
     | 
    
         
            +
            DEFFILE = 
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            CLEANFILES = 
         
     | 
| 
      
 76 
     | 
    
         
            +
            DISTCLEANFILES = 
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            extout = 
         
     | 
| 
      
 79 
     | 
    
         
            +
            extout_prefix = 
         
     | 
| 
      
 80 
     | 
    
         
            +
            target_prefix = 
         
     | 
| 
      
 81 
     | 
    
         
            +
            LOCAL_LIBS = 
         
     | 
| 
      
 82 
     | 
    
         
            +
            LIBS = $(LIBRUBYARG_SHARED) -lgtop-2.0  -lgtop-2.0 -lglib-2.0   -lpthread -ldl -lcrypt -lm   -lc
         
     | 
| 
      
 83 
     | 
    
         
            +
            SRCS = rb_glibtop_mountlist.c rb_glibtop_fsusage.c rb_glibtop_init.c rb_glibtop_ppp.c rb_glibtop_proc_open_files.c rb_glibtop_proclist.c rb_glibtop_proc_map.c rb_glibtop_proc_signal.c rb_glibtop_proc_mem.c rb_glibtop_proc_kernel.c rb_glibtop_proc_state.c rb_glibtop_uptime.c rb_glibtop_proc_uid.c rb_glibtop_sem_limits.c rb_glibtop_msg_limits.c rb_glibtop_shm_limits.c rb_glibtop_swap.c rb_glibtop_loadavg.c rb_glibtop_mem.c rb_glibtop_proc_args.c rb_glibtop.c rb_glibtop_proc_time.c rb_glibtop_netlist.c rb_glibtop_cpu.c rb_glibtop_proc_segment.c rb_glibtop_netload.c rb_glibtop_sysdeps.c
         
     | 
| 
      
 84 
     | 
    
         
            +
            OBJS = rb_glibtop_mountlist.o rb_glibtop_fsusage.o rb_glibtop_init.o rb_glibtop_ppp.o rb_glibtop_proc_open_files.o rb_glibtop_proclist.o rb_glibtop_proc_map.o rb_glibtop_proc_signal.o rb_glibtop_proc_mem.o rb_glibtop_proc_kernel.o rb_glibtop_proc_state.o rb_glibtop_uptime.o rb_glibtop_proc_uid.o rb_glibtop_sem_limits.o rb_glibtop_msg_limits.o rb_glibtop_shm_limits.o rb_glibtop_swap.o rb_glibtop_loadavg.o rb_glibtop_mem.o rb_glibtop_proc_args.o rb_glibtop.o rb_glibtop_proc_time.o rb_glibtop_netlist.o rb_glibtop_cpu.o rb_glibtop_proc_segment.o rb_glibtop_netload.o rb_glibtop_sysdeps.o
         
     | 
| 
      
 85 
     | 
    
         
            +
            TARGET = libgtop
         
     | 
| 
      
 86 
     | 
    
         
            +
            DLLIB = $(TARGET).so
         
     | 
| 
      
 87 
     | 
    
         
            +
            EXTSTATIC = 
         
     | 
| 
      
 88 
     | 
    
         
            +
            STATIC_LIB = 
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            RUBYCOMMONDIR = $(sitedir)$(target_prefix)
         
     | 
| 
      
 91 
     | 
    
         
            +
            RUBYLIBDIR    = $(sitelibdir)$(target_prefix)
         
     | 
| 
      
 92 
     | 
    
         
            +
            RUBYARCHDIR   = $(sitearchdir)$(target_prefix)
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            TARGET_SO     = $(DLLIB)
         
     | 
| 
      
 95 
     | 
    
         
            +
            CLEANLIBS     = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
         
     | 
| 
      
 96 
     | 
    
         
            +
            CLEANOBJS     = *.o *.a *.s[ol] *.pdb *.exp *.bak
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
            all:		$(DLLIB)
         
     | 
| 
      
 99 
     | 
    
         
            +
            static:		$(STATIC_LIB)
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            clean:
         
     | 
| 
      
 102 
     | 
    
         
            +
            		@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
            distclean:	clean
         
     | 
| 
      
 105 
     | 
    
         
            +
            		@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
         
     | 
| 
      
 106 
     | 
    
         
            +
            		@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            realclean:	distclean
         
     | 
| 
      
 109 
     | 
    
         
            +
            install: install-so install-rb
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            install-so: $(RUBYARCHDIR)
         
     | 
| 
      
 112 
     | 
    
         
            +
            install-so: $(RUBYARCHDIR)/$(DLLIB)
         
     | 
| 
      
 113 
     | 
    
         
            +
            $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
         
     | 
| 
      
 114 
     | 
    
         
            +
            	$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
         
     | 
| 
      
 115 
     | 
    
         
            +
            install-rb: pre-install-rb install-rb-default
         
     | 
| 
      
 116 
     | 
    
         
            +
            install-rb-default: pre-install-rb-default
         
     | 
| 
      
 117 
     | 
    
         
            +
            pre-install-rb: Makefile
         
     | 
| 
      
 118 
     | 
    
         
            +
            pre-install-rb-default: Makefile
         
     | 
| 
      
 119 
     | 
    
         
            +
            $(RUBYARCHDIR):
         
     | 
| 
      
 120 
     | 
    
         
            +
            	$(MAKEDIRS) $@
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            site-install: site-install-so site-install-rb
         
     | 
| 
      
 123 
     | 
    
         
            +
            site-install-so: install-so
         
     | 
| 
      
 124 
     | 
    
         
            +
            site-install-rb: install-rb
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
            .SUFFIXES: .c .m .cc .cxx .cpp .C .o
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            .cc.o:
         
     | 
| 
      
 129 
     | 
    
         
            +
            	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
            .cxx.o:
         
     | 
| 
      
 132 
     | 
    
         
            +
            	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            .cpp.o:
         
     | 
| 
      
 135 
     | 
    
         
            +
            	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
            .C.o:
         
     | 
| 
      
 138 
     | 
    
         
            +
            	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
            .c.o:
         
     | 
| 
      
 141 
     | 
    
         
            +
            	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
            $(DLLIB): $(OBJS)
         
     | 
| 
      
 144 
     | 
    
         
            +
            	@-$(RM) $@
         
     | 
| 
      
 145 
     | 
    
         
            +
            	$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LOCAL_LIBS) $(LIBS)
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
            $(OBJS): ruby.h defines.h
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            package configuration for libgtop-2.0
         
     | 
| 
      
 2 
     | 
    
         
            +
            cflags: -I/usr/include/libgtop-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  
         
     | 
| 
      
 3 
     | 
    
         
            +
            ldflags: 
         
     | 
| 
      
 4 
     | 
    
         
            +
            libs: -lgtop-2.0 -lglib-2.0  
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            have_header: checking for glibtop.h... -------------------- yes
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            "i686-pc-linux-gnu-gcc -E -I. -I/usr/lib/ruby/1.8/i686-linux -I.  -march=athlon-xp -O2 -pipe  -fPIC -I/usr/include/libgtop-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include    conftest.c -o conftest.i"
         
     | 
| 
      
 9 
     | 
    
         
            +
            checked program was:
         
     | 
| 
      
 10 
     | 
    
         
            +
            /* begin */
         
     | 
| 
      
 11 
     | 
    
         
            +
            1: #include <glibtop.h>
         
     | 
| 
      
 12 
     | 
    
         
            +
            /* end */
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            --------------------
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            have_library: checking for glibtop_init_r() in -lgtop-2.0... -------------------- yes
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            "i686-pc-linux-gnu-gcc -o conftest -I. -I/usr/lib/ruby/1.8/i686-linux -I.  -march=athlon-xp -O2 -pipe  -fPIC -I/usr/include/libgtop-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   conftest.c  -L'/usr/lib' -Wl,-R'/usr/lib'       -lgtop-2.0 -lglib-2.0   -lruby18-static -lgtop-2.0  -lgtop-2.0 -lglib-2.0   -lpthread -ldl -lcrypt -lm   -lc"
         
     | 
| 
      
 19 
     | 
    
         
            +
            checked program was:
         
     | 
| 
      
 20 
     | 
    
         
            +
            /* begin */
         
     | 
| 
      
 21 
     | 
    
         
            +
            1: /*top*/
         
     | 
| 
      
 22 
     | 
    
         
            +
            2: int main() { return 0; }
         
     | 
| 
      
 23 
     | 
    
         
            +
            3: int t() { glibtop_init_r(); return 0; }
         
     | 
| 
      
 24 
     | 
    
         
            +
            /* end */
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            --------------------
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            #include <rb_glibtop.h>
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            VALUE cLibGTop;
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            static VALUE rb_libgtop_ncpu_s(VALUE klass)
         
     | 
| 
      
 16 
     | 
    
         
            +
            {
         
     | 
| 
      
 17 
     | 
    
         
            +
                int ncpu;
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                ncpu = glibtop_global_server->ncpu ? glibtop_global_server->ncpu : 1;
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                return INT2FIX(ncpu);
         
     | 
| 
      
 22 
     | 
    
         
            +
            }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            void Init_libgtop()
         
     | 
| 
      
 26 
     | 
    
         
            +
            {
         
     | 
| 
      
 27 
     | 
    
         
            +
                cLibGTop = rb_define_class("LibGTop", rb_cObject);
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                rb_define_singleton_method(cLibGTop, "ncpu", rb_libgtop_ncpu_s, 0);
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                Init_glibtop_cpu();
         
     | 
| 
      
 32 
     | 
    
         
            +
                Init_glibtop_mem();
         
     | 
| 
      
 33 
     | 
    
         
            +
                Init_glibtop_swap();
         
     | 
| 
      
 34 
     | 
    
         
            +
                Init_glibtop_uptime();
         
     | 
| 
      
 35 
     | 
    
         
            +
                Init_glibtop_loadavg();
         
     | 
| 
      
 36 
     | 
    
         
            +
                Init_glibtop_proclist();
         
     | 
| 
      
 37 
     | 
    
         
            +
                Init_glibtop_proc_state();
         
     | 
| 
      
 38 
     | 
    
         
            +
                Init_glibtop_proc_uid();
         
     | 
| 
      
 39 
     | 
    
         
            +
                Init_glibtop_proc_map();
         
     | 
| 
      
 40 
     | 
    
         
            +
                Init_glibtop_proc_mem();
         
     | 
| 
      
 41 
     | 
    
         
            +
            #if (LIBGTOP_CHECK_VERSION(2, 9, 4))
         
     | 
| 
      
 42 
     | 
    
         
            +
                Init_glibtop_proc_open_files();
         
     | 
| 
      
 43 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 44 
     | 
    
         
            +
                Init_glibtop_proc_time();
         
     | 
| 
      
 45 
     | 
    
         
            +
                Init_glibtop_proc_signal();
         
     | 
| 
      
 46 
     | 
    
         
            +
                Init_glibtop_proc_kernel();
         
     | 
| 
      
 47 
     | 
    
         
            +
                Init_glibtop_proc_segment();
         
     | 
| 
      
 48 
     | 
    
         
            +
                Init_glibtop_proc_args();
         
     | 
| 
      
 49 
     | 
    
         
            +
            #if (LIBGTOP_CHECK_VERSION(2, 9, 0))
         
     | 
| 
      
 50 
     | 
    
         
            +
                Init_glibtop_netlist();
         
     | 
| 
      
 51 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 52 
     | 
    
         
            +
                Init_glibtop_netload();
         
     | 
| 
      
 53 
     | 
    
         
            +
                Init_glibtop_ppp();
         
     | 
| 
      
 54 
     | 
    
         
            +
                Init_glibtop_mountlist();
         
     | 
| 
      
 55 
     | 
    
         
            +
                Init_glibtop_fsusage();
         
     | 
| 
      
 56 
     | 
    
         
            +
                Init_glibtop_init();
         
     | 
| 
      
 57 
     | 
    
         
            +
                Init_glibtop_sysdeps();
         
     | 
| 
      
 58 
     | 
    
         
            +
                Init_glibtop_shm_limits();
         
     | 
| 
      
 59 
     | 
    
         
            +
                Init_glibtop_msg_limits();
         
     | 
| 
      
 60 
     | 
    
         
            +
                Init_glibtop_sem_limits();
         
     | 
| 
      
 61 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include <glibtop.h>
         
     | 
| 
      
 2 
     | 
    
         
            +
            #include <glibtop/union.h>
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            extern VALUE cLibGTop;
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            /* ports for older version */
         
     | 
| 
      
 7 
     | 
    
         
            +
            #define _LIBGTOP_CHECK_VERSION(major, minor, micro)    \
         
     | 
| 
      
 8 
     | 
    
         
            +
            (LIBGTOP_MAJOR_VERSION > (major) || \
         
     | 
| 
      
 9 
     | 
    
         
            +
            (LIBGTOP_MAJOR_VERSION == (major) && LIBGTOP_MINOR_VERSION > (minor)) || \
         
     | 
| 
      
 10 
     | 
    
         
            +
            (LIBGTOP_MAJOR_VERSION == (major) && LIBGTOP_MINOR_VERSION == (minor) && \
         
     | 
| 
      
 11 
     | 
    
         
            +
            LIBGTOP_MICRO_VERSION >= (micro)))
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            #ifndef LIBGTOP_CHECK_VERSION
         
     | 
| 
      
 14 
     | 
    
         
            +
            #define LIBGTOP_CHECK_VERSION _LIBGTOP_CHECK_VERSION
         
     | 
| 
      
 15 
     | 
    
         
            +
            #endif
         
     | 
| 
         @@ -0,0 +1,69 @@ 
     | 
|
| 
      
 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/cpu.h>
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            static VALUE rb_glibtop_cpu(VALUE self)
         
     | 
| 
      
 14 
     | 
    
         
            +
            { 
         
     | 
| 
      
 15 
     | 
    
         
            +
                glibtop_cpu buf;
         
     | 
| 
      
 16 
     | 
    
         
            +
                VALUE hash, xcpu_ary, xcpu;
         
     | 
| 
      
 17 
     | 
    
         
            +
                int ncpu, i;
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                glibtop_get_cpu(&buf);
         
     | 
| 
      
 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("total"), rb_uint2inum(buf.total));
         
     | 
| 
      
 25 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("user"), rb_uint2inum(buf.user));
         
     | 
| 
      
 26 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("nice"), rb_uint2inum(buf.nice));
         
     | 
| 
      
 27 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("sys"), rb_uint2inum(buf.sys));
         
     | 
| 
      
 28 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("idle"), rb_uint2inum(buf.idle));
         
     | 
| 
      
 29 
     | 
    
         
            +
            #if (LIBGTOP_CHECK_VERSION(2, 9, 4))
         
     | 
| 
      
 30 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("iowait"), rb_uint2inum(buf.iowait));
         
     | 
| 
      
 31 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("irq"), rb_uint2inum(buf.irq));
         
     | 
| 
      
 32 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("softirq"), rb_uint2inum(buf.softirq));
         
     | 
| 
      
 33 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 34 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("frequency"), rb_uint2inum(buf.frequency));
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                /* for SMP systems */
         
     | 
| 
      
 37 
     | 
    
         
            +
                ncpu = glibtop_global_server->ncpu ? glibtop_global_server->ncpu : 1;
         
     | 
| 
      
 38 
     | 
    
         
            +
                xcpu_ary = rb_ary_new2(ncpu);
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                for (i = 0; i < ncpu; i++) {
         
     | 
| 
      
 41 
     | 
    
         
            +
                   xcpu = rb_hash_new();
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("total"), rb_uint2inum(buf.xcpu_total[i]));
         
     | 
| 
      
 44 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("user"), rb_uint2inum(buf.xcpu_user[i]));
         
     | 
| 
      
 45 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("nice"), rb_uint2inum(buf.xcpu_nice[i]));
         
     | 
| 
      
 46 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("sys"), rb_uint2inum(buf.xcpu_sys[i]));
         
     | 
| 
      
 47 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("idle"), rb_uint2inum(buf.xcpu_idle[i]));
         
     | 
| 
      
 48 
     | 
    
         
            +
            #if (LIBGTOP_CHECK_VERSION(2, 9, 4))
         
     | 
| 
      
 49 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("iowait"), rb_uint2inum(buf.xcpu_iowait[i]));
         
     | 
| 
      
 50 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("irq"), rb_uint2inum(buf.xcpu_irq[i]));
         
     | 
| 
      
 51 
     | 
    
         
            +
                   rb_hash_aset(xcpu, rb_str_new2("softirq"), rb_uint2inum(buf.xcpu_softirq[i]));
         
     | 
| 
      
 52 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                   rb_ary_push(xcpu_ary, xcpu);
         
     | 
| 
      
 55 
     | 
    
         
            +
                }
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("xcpu"), xcpu_ary);
         
     | 
| 
      
 58 
     | 
    
         
            +
            #if (LIBGTOP_CHECK_VERSION(2, 5, 1))
         
     | 
| 
      
 59 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("xcpu_flags"), rb_uint2inum(buf.xcpu_flags));
         
     | 
| 
      
 60 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                return hash;
         
     | 
| 
      
 63 
     | 
    
         
            +
            }
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            void Init_glibtop_cpu()
         
     | 
| 
      
 67 
     | 
    
         
            +
            {
         
     | 
| 
      
 68 
     | 
    
         
            +
                rb_define_method(cLibGTop, "cpu", rb_glibtop_cpu, 0);
         
     | 
| 
      
 69 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 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/fsusage.h>
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            static VALUE rb_glibtop_fsusage(VALUE self, VALUE mount_dir)
         
     | 
| 
      
 14 
     | 
    
         
            +
            { 
         
     | 
| 
      
 15 
     | 
    
         
            +
                glibtop_fsusage buf;
         
     | 
| 
      
 16 
     | 
    
         
            +
                VALUE hash;
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                glibtop_get_fsusage(&buf, StringValuePtr(mount_dir));
         
     | 
| 
      
 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("blocks"), rb_uint2inum(buf.blocks));
         
     | 
| 
      
 24 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("bfree"), rb_uint2inum(buf.bfree));
         
     | 
| 
      
 25 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("bavail"), rb_uint2inum(buf.bavail));
         
     | 
| 
      
 26 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("files"), rb_uint2inum(buf.files));
         
     | 
| 
      
 27 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("ffree"), rb_uint2inum(buf.ffree));
         
     | 
| 
      
 28 
     | 
    
         
            +
            #if (LIBGTOP_CHECK_VERSION(2, 5, 2))
         
     | 
| 
      
 29 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("block_size"), INT2FIX(buf.block_size));
         
     | 
| 
      
 30 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 31 
     | 
    
         
            +
            #if (LIBGTOP_CHECK_VERSION(2, 7, 4))
         
     | 
| 
      
 32 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("read"), rb_uint2inum(buf.read));
         
     | 
| 
      
 33 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("write"), rb_uint2inum(buf.write));
         
     | 
| 
      
 34 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                return hash;
         
     | 
| 
      
 37 
     | 
    
         
            +
            }
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            void Init_glibtop_fsusage()
         
     | 
| 
      
 41 
     | 
    
         
            +
            {
         
     | 
| 
      
 42 
     | 
    
         
            +
                rb_define_method(cLibGTop, "fsusage", rb_glibtop_fsusage, 1);
         
     | 
| 
      
 43 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 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_init(VALUE self)
         
     | 
| 
      
 13 
     | 
    
         
            +
            { 
         
     | 
| 
      
 14 
     | 
    
         
            +
                glibtop_union data;
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                glibtop_init();
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 19 
     | 
    
         
            +
            }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            void Init_glibtop_init()
         
     | 
| 
      
 23 
     | 
    
         
            +
            {
         
     | 
| 
      
 24 
     | 
    
         
            +
                rb_define_method(cLibGTop, "init", rb_glibtop_init, 0);
         
     | 
| 
      
 25 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,42 @@ 
     | 
|
| 
      
 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/loadavg.h>
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            static VALUE rb_glibtop_loadavg(VALUE self)
         
     | 
| 
      
 14 
     | 
    
         
            +
            { 
         
     | 
| 
      
 15 
     | 
    
         
            +
                glibtop_loadavg buf;
         
     | 
| 
      
 16 
     | 
    
         
            +
                VALUE hash, loadavg;
         
     | 
| 
      
 17 
     | 
    
         
            +
                int i;
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                glibtop_get_loadavg(&buf);
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                hash = rb_hash_new();
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("flags"), rb_uint2inum(buf.flags));
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                loadavg = rb_ary_new2(3);
         
     | 
| 
      
 26 
     | 
    
         
            +
                for (i = 0; i < 3; i++){
         
     | 
| 
      
 27 
     | 
    
         
            +
                    rb_ary_push(loadavg, rb_float_new(buf.loadavg[i]));
         
     | 
| 
      
 28 
     | 
    
         
            +
                }
         
     | 
| 
      
 29 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("loadavg"), loadavg);
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("nr_running"), rb_uint2inum(buf.nr_running));
         
     | 
| 
      
 32 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("nr_tasks"), rb_uint2inum(buf.nr_tasks));
         
     | 
| 
      
 33 
     | 
    
         
            +
                rb_hash_aset(hash, rb_str_new2("last_pid"), rb_uint2inum(buf.last_pid));
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                return hash;
         
     | 
| 
      
 36 
     | 
    
         
            +
            }
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            void Init_glibtop_loadavg()
         
     | 
| 
      
 40 
     | 
    
         
            +
            {
         
     | 
| 
      
 41 
     | 
    
         
            +
                rb_define_method(cLibGTop, "loadavg", rb_glibtop_loadavg, 0);
         
     | 
| 
      
 42 
     | 
    
         
            +
            }
         
     |