Compare commits

..

No commits in common. "master" and "v2.0.4" have entirely different histories.

9 changed files with 81 additions and 186 deletions

View File

@ -1,41 +1,23 @@
# System Information Gatherer And Reporter. # System Information Gatherer And Reporter.
Fork of hyperic/sigar with some fixes. Support only ruby binding. Part of [Eye gem](https://github.com/kostya/eye). Fork of hyperic/sigar with some fixes. Support only ruby binding.
## Fixed: ## Fixed:
### [2.0.11] 10-09-2024 [2.0.0]
* Fixing build issue on newer linux and also issues with newer Ruby [#16](https://github.com/kostya/sigar/pull/16)([commit](https://github.com/kostya/sigar/pull/16/commits/8b887b2380c4aadea82402904d9c1131bbb9c521))
### [2.0.10] 31-10-2021
* Fix compilation on MacOS 11.3.1 [#11](https://github.com/kostya/sigar/issues/11)([commit](https://github.com/kostya/sigar/commit/49a9aeeff54e97ac6f41d464c30ff6c8adf4bcf4))
### [2.0.9] 28-06-2021
* Fix compilation on FreeBSD 13 [#10](https://github.com/kostya/sigar/issues/10)([commit](https://github.com/kostya/sigar/commit/b78b558fb756a75dc7d6cbf704423be3c7098ae5))
### [2.0.8] 02-10-2020
* Fix compilation on MacOS [#8](https://github.com/kostya/sigar/issues/8)([commit](https://github.com/kostya/sigar/pull/9/commits/ad39547629fa328e115f7d7bc3c7c358247d1961))
### [2.0.6] 18-01-2019
* Fix compilation on FreeBSD 12 [#6](https://github.com/kostya/sigar/issues/6)([commit](https://github.com/kostya/sigar/commit/2bb67fa1bf6f6f0ddc2626cf028bcc0e4a8cb377))
### [2.0.5] 02-12-2018
* Fix compilation with musl libc [#4](https://github.com/kostya/sigar/pull/4)([commit](https://github.com/kostya/sigar/pull/4/commits/cd07923dd2ed34aca353dfd182f2f85c13853fd9))
### [2.0.4] 10-06-2018
* fix compilation with glibc 2.26, major/minor functions [#2](https://github.com/kostya/sigar/issues/2)([commit](https://github.com/kostya/sigar/commit/a2c67588d0f686e0007dadcaf0e4bbb35c0e1e83))
### [2.0.2] 30-05-2018
* Remove obsolete rpc usage (fix compilation fail with glibc 2.27) [#213](https://github.com/kostya/eye/issues/213)([commit](https://github.com/kostya/sigar/commit/a971b9e8e1443fdf236c5ffa199c1994c05fcd4b))
### [2.0.1] 10-04-2018
* FreeBSD: don't use v_cache_min/max [#68](https://github.com/hyperic/sigar/pull/68)([commit](https://github.com/kostya/sigar/commit/800076db97bcacb1ba90805d740b4f9a5a1d3cca))
### [2.0.0] 22-01-2018
* sigfaulted logger, [#28](https://github.com/hyperic/sigar/pull/28)([commit](https://github.com/kostya/sigar/commit/c2a1af)) * sigfaulted logger, [#28](https://github.com/hyperic/sigar/pull/28)([commit](https://github.com/kostya/sigar/commit/c2a1af))
* bug undefined symbol: sigar_skip_token, [#60](https://github.com/hyperic/sigar/pull/60)([commit](https://github.com/kostya/sigar/commit/dfe8fe)) * bug undefined symbol: sigar_skip_token, [#60](https://github.com/hyperic/sigar/pull/60)([commit](https://github.com/kostya/sigar/commit/dfe8fe))
* bug detection boot_time on linux (now it works like gnu ps, and fix some issues with process start_time) ([commit](https://github.com/kostya/sigar/commit/660259)) * bug detection boot_time on linux (now it works like gnu ps, and fix some issues with process start_time) ([commit](https://github.com/kostya/sigar/commit/660259))
[2.0.1]
* FreeBSD: don't use v_cache_min/max [#68](https://github.com/hyperic/sigar/pull/68)([commit](https://github.com/kostya/sigar/commit/800076db97bcacb1ba90805d740b4f9a5a1d3cca))
[2.0.2]
* Remove obsolete rpc usage (fix compilation fail with glibc 2.27) ([commit](https://github.com/kostya/sigar/commit/a971b9e8e1443fdf236c5ffa199c1994c05fcd4b))
[2.0.4]
* fix compilation with glibc 2.26, major/minor functions ([commit](https://github.com/kostya/sigar/commit/a2c67588d0f686e0007dadcaf0e4bbb35c0e1e83))
## Installation: ## Installation:

View File

@ -27,6 +27,7 @@ spec = Gem::Specification.new do |s|
s.email = props['project.email'] s.email = props['project.email']
s.homepage = props['project.homepage'] s.homepage = props['project.homepage']
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.has_rdoc = false
s.extensions = 'bindings/ruby/extconf.rb' s.extensions = 'bindings/ruby/extconf.rb'
s.files = s.files =
%w(LICENSE NOTICE README.md Rakefile version.properties) + %w(LICENSE NOTICE README.md Rakefile version.properties) +
@ -51,15 +52,15 @@ end
desc 'Build sigar extension' desc 'Build sigar extension'
task :build do task :build do
in_ext() in_ext()
unless File.exist? "Makefile" unless File.exists? "Makefile"
unless system("ruby extconf.rb") unless system("ruby extconf.rb")
STDERR.puts "Failed to configure" STDERR.puts "Failed to configure"
next break
end end
end end
unless system(MAKE) unless system(MAKE)
STDERR.puts 'Failed to ' + MAKE STDERR.puts 'Failed to ' + MAKE
next break
end end
end end
@ -75,13 +76,13 @@ end
desc 'Clean sigar extension' desc 'Clean sigar extension'
task :clean do task :clean do
in_ext() in_ext()
system(MAKE + ' clean') if File.exist? "Makefile" system(MAKE + ' clean') if File.exists? "Makefile"
end end
desc 'Dist Clean sigar extension' desc 'Dist Clean sigar extension'
task :distclean do task :distclean do
in_ext() in_ext()
system(MAKE + ' distclean') if File.exist? "Makefile" system(MAKE + ' distclean') if File.exists? "Makefile"
end end
desc 'Run sigar examples (test)' desc 'Run sigar examples (test)'

View File

@ -24,7 +24,6 @@
#endif #endif
#include <errno.h> #include <errno.h>
#include <ctype.h>
#include "sigar.h" #include "sigar.h"
#include "sigar_fileinfo.h" #include "sigar_fileinfo.h"
#include "sigar_format.h" #include "sigar_format.h"

View File

@ -4,7 +4,7 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "kostya-sigar" s.name = "kostya-sigar"
s.version = "2.0.11" s.version = "2.0.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"] s.require_paths = ["lib"]

View File

@ -123,69 +123,6 @@
#endif #endif
#if defined(SIGAR_FREEBSD5) #if defined(SIGAR_FREEBSD5)
#if __FreeBSD_version >= 1200028
#define VMMETER_TYPE uint64_t
#else
#define VMMETER_TYPE u_int
#endif
struct __vmmeter {
VMMETER_TYPE v_vm_faults;
VMMETER_TYPE v_io_faults;
VMMETER_TYPE v_cow_faults;
VMMETER_TYPE v_cow_optim;
VMMETER_TYPE v_zfod;
VMMETER_TYPE v_ozfod;
VMMETER_TYPE v_swapin;
VMMETER_TYPE v_swapout;
VMMETER_TYPE v_swappgsin;
VMMETER_TYPE v_swappgsout;
VMMETER_TYPE v_vnodein;
VMMETER_TYPE v_vnodeout;
VMMETER_TYPE v_vnodepgsin;
VMMETER_TYPE v_vnodepgsout;
VMMETER_TYPE v_intrans;
VMMETER_TYPE v_reactivated;
VMMETER_TYPE v_pdwakeups;
VMMETER_TYPE v_pdpages;
VMMETER_TYPE v_pdshortfalls;
VMMETER_TYPE v_dfree;
VMMETER_TYPE v_pfree;
VMMETER_TYPE v_tfree;
VMMETER_TYPE v_forks;
VMMETER_TYPE v_vforks;
VMMETER_TYPE v_rforks;
VMMETER_TYPE v_kthreads;
VMMETER_TYPE v_forkpages;
VMMETER_TYPE v_vforkpages;
VMMETER_TYPE v_rforkpages;
VMMETER_TYPE v_kthreadpages;
VMMETER_TYPE v_swtch;
VMMETER_TYPE v_syscall;
VMMETER_TYPE v_trap;
VMMETER_TYPE v_intr;
VMMETER_TYPE v_soft;
u_int v_page_size;
u_int v_page_count;
u_int v_free_reserved;
u_int v_free_target;
u_int v_free_min;
u_int v_free_count;
u_int v_wire_count;
u_int v_active_count;
u_int v_inactive_target;
u_int v_inactive_count;
u_int v_laundry_count;
u_int v_pageout_free_min;
u_int v_interrupt_free_min;
u_int v_free_severe;
#if (__FreeBSD_version < 1200016)
u_int v_cache_count;
#endif
#if (__FreeBSD_version < 1100079)
u_int v_cache_min;
u_int v_cache_max;
#endif
};
#define KI_FD ki_fd #define KI_FD ki_fd
#define KI_PID ki_pid #define KI_PID ki_pid
@ -405,21 +342,24 @@ static int sigar_vmstat(sigar_t *sigar, vm_statistics_data_t *vmstat)
} }
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
static int sigar_vmstat(sigar_t *sigar, struct __vmmeter *vmstat) static int sigar_vmstat(sigar_t *sigar, struct vmmeter *vmstat)
{ {
size_t size; int status;
size_t size = sizeof(unsigned int);
status = kread(sigar, vmstat, sizeof(*vmstat),
sigar->koffsets[KOFFSET_VMMETER]);
if (status == SIGAR_OK) {
return SIGAR_OK;
}
SIGAR_ZERO(vmstat); SIGAR_ZERO(vmstat);
/* derived from src/usr.bin/vmstat/vmstat.c */ /* derived from src/usr.bin/vmstat/vmstat.c */
/* only collect the ones we actually use */ /* only collect the ones we actually use */
#define GET_VM_STATS(cat, name, used) do { \ #define GET_VM_STATS(cat, name, used) \
if (used) { \ if (used) sysctlbyname("vm.stats." #cat "." #name, &vmstat->name, &size, NULL, 0)
size = sizeof(vmstat->name); \
sysctlbyname("vm.stats." #cat "." #name, &vmstat->name, \
&size, NULL, 0); \
} \
} while (0)
/* sys */ /* sys */
GET_VM_STATS(sys, v_swtch, 0); GET_VM_STATS(sys, v_swtch, 0);
@ -459,12 +399,10 @@ static int sigar_vmstat(sigar_t *sigar, struct __vmmeter *vmstat)
GET_VM_STATS(vm, v_active_count, 0); GET_VM_STATS(vm, v_active_count, 0);
GET_VM_STATS(vm, v_inactive_target, 0); GET_VM_STATS(vm, v_inactive_target, 0);
GET_VM_STATS(vm, v_inactive_count, 1); GET_VM_STATS(vm, v_inactive_count, 1);
#if (__FreeBSD_version < 1200016 )
GET_VM_STATS(vm, v_cache_count, 1); GET_VM_STATS(vm, v_cache_count, 1);
#endif #if (__FreeBSD_version < 1100079)
#if (__FreeBSD_version < 1100079 ) GET_VM_STATS(vm, v_cache_min, 0);
GET_VM_STATS(vm, v_cache_min, 0); GET_VM_STATS(vm, v_cache_max, 0);
GET_VM_STATS(vm, v_cache_max, 0);
#endif #endif
GET_VM_STATS(vm, v_pageout_free_min, 0); GET_VM_STATS(vm, v_pageout_free_min, 0);
GET_VM_STATS(vm, v_interrupt_free_min, 0); GET_VM_STATS(vm, v_interrupt_free_min, 0);
@ -504,7 +442,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
unsigned long mem_total; unsigned long mem_total;
#endif #endif
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
struct __vmmeter vmstat; struct vmmeter vmstat;
#elif defined(__OpenBSD__) || defined(__NetBSD__) #elif defined(__OpenBSD__) || defined(__NetBSD__)
struct uvmexp vmstat; struct uvmexp vmstat;
#endif #endif
@ -543,11 +481,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
kern *= sigar->pagesize; kern *= sigar->pagesize;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
if ((status = sigar_vmstat(sigar, &vmstat)) == SIGAR_OK) { if ((status = sigar_vmstat(sigar, &vmstat)) == SIGAR_OK) {
#if (__FreeBSD_version < 1200016 )
kern = vmstat.v_cache_count + vmstat.v_inactive_count; kern = vmstat.v_cache_count + vmstat.v_inactive_count;
#else
kern = vmstat.v_inactive_count;
#endif
kern *= sigar->pagesize; kern *= sigar->pagesize;
mem->free = vmstat.v_free_count; mem->free = vmstat.v_free_count;
mem->free *= sigar->pagesize; mem->free *= sigar->pagesize;
@ -757,7 +691,7 @@ int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
swap->page_out = vmstat.pageouts; swap->page_out = vmstat.pageouts;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
struct kvm_swap kswap[1]; struct kvm_swap kswap[1];
struct __vmmeter vmstat; struct vmmeter vmstat;
if (getswapinfo_sysctl(kswap, 1) != SIGAR_OK) { if (getswapinfo_sysctl(kswap, 1) != SIGAR_OK) {
if (!sigar->kmem) { if (!sigar->kmem) {
@ -1965,7 +1899,7 @@ int sigar_proc_fd_get(sigar_t *sigar, sigar_pid_t pid,
free(ofiles); free(ofiles);
#else #else
/* seems the same as the above */ /* seems the same as the above */
procfd->total = filed.fd_nfiles; procfd->total = filed.fd_lastfile;
#endif #endif
return SIGAR_OK; return SIGAR_OK;
@ -3123,13 +3057,8 @@ static int net_connection_get(sigar_net_connection_walker_t *walker, int proto)
int type, istcp = 0; int type, istcp = 0;
char *buf; char *buf;
const char *mibvar; const char *mibvar;
#if defined(__FreeBSD__) && (__FreeBSD_version >= 1200026)
struct xtcpcb *tp = NULL;
struct xinpcb *inp;
#else
struct tcpcb *tp = NULL; struct tcpcb *tp = NULL;
struct inpcb *inp; struct inpcb *inp;
#endif
struct xinpgen *xig, *oxig; struct xinpgen *xig, *oxig;
struct xsocket *so; struct xsocket *so;
size_t len; size_t len;
@ -3167,15 +3096,6 @@ static int net_connection_get(sigar_net_connection_walker_t *walker, int proto)
xig->xig_len > sizeof(struct xinpgen); xig->xig_len > sizeof(struct xinpgen);
xig = (struct xinpgen *)((char *)xig + xig->xig_len)) xig = (struct xinpgen *)((char *)xig + xig->xig_len))
{ {
#if defined(__FreeBSD__) && (__FreeBSD_version >= 1200026)
if (istcp) {
tp = (struct xtcpcb *)xig;
inp = &tp->xt_inp;
} else {
inp = (struct xinpcb *)xig;
}
so = &inp->xi_socket;
#else
if (istcp) { if (istcp) {
struct xtcpcb *cb = (struct xtcpcb *)xig; struct xtcpcb *cb = (struct xtcpcb *)xig;
tp = &cb->xt_tp; tp = &cb->xt_tp;
@ -3187,7 +3107,6 @@ static int net_connection_get(sigar_net_connection_walker_t *walker, int proto)
inp = &cb->xi_inp; inp = &cb->xi_inp;
so = &cb->xi_socket; so = &cb->xi_socket;
} }
#endif
if (so->xso_protocol != proto) { if (so->xso_protocol != proto) {
continue; continue;
@ -3310,20 +3229,20 @@ sigar_tcp_get(sigar_t *sigar,
return SIGAR_OK; return SIGAR_OK;
} }
// #ifndef SIGAR_FREEBSD5_NFSSTAT #ifndef SIGAR_FREEBSD5_NFSSTAT
// static int get_nfsstats(struct nfsstats *stats) static int get_nfsstats(struct nfsstats *stats)
// { {
// size_t len = sizeof(*stats); size_t len = sizeof(*stats);
// int mib[] = { CTL_VFS, 2, NFS_NFSSTATS }; int mib[] = { CTL_VFS, 2, NFS_NFSSTATS };
// if (sysctl(mib, NMIB(mib), stats, &len, NULL, 0) < 0) { if (sysctl(mib, NMIB(mib), stats, &len, NULL, 0) < 0) {
// return errno; return errno;
// } }
// else { else {
// return SIGAR_OK; return SIGAR_OK;
// } }
// } }
// #endif #endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
typedef uint64_t rpc_cnt_t; typedef uint64_t rpc_cnt_t;
@ -3372,25 +3291,25 @@ int sigar_nfs_server_v2_get(sigar_t *sigar,
int sigar_nfs_client_v3_get(sigar_t *sigar, int sigar_nfs_client_v3_get(sigar_t *sigar,
sigar_nfs_client_v3_t *nfs) sigar_nfs_client_v3_t *nfs)
{ {
// #ifdef SIGAR_FREEBSD5_NFSSTAT #ifdef SIGAR_FREEBSD5_NFSSTAT
// struct nfsstats stats; struct nfsstats stats;
// size_t size = sizeof(stats); size_t size = sizeof(stats);
// if (sysctlbyname("vfs.nfs.nfsstats", &stats, &size, NULL, 0) == -1) { if (sysctlbyname("vfs.nfs.nfsstats", &stats, &size, NULL, 0) == -1) {
// return errno; return errno;
// } }
// map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.rpccnt[0]); map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.rpccnt[0]);
// #else #else
// int status; int status;
// struct nfsstats stats; struct nfsstats stats;
// if ((status = get_nfsstats(&stats)) != SIGAR_OK) { if ((status = get_nfsstats(&stats)) != SIGAR_OK) {
// return status; return status;
// } }
// map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.rpccnt[0]); map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.rpccnt[0]);
// #endif #endif
return SIGAR_OK; return SIGAR_OK;
} }
@ -3398,25 +3317,25 @@ int sigar_nfs_client_v3_get(sigar_t *sigar,
int sigar_nfs_server_v3_get(sigar_t *sigar, int sigar_nfs_server_v3_get(sigar_t *sigar,
sigar_nfs_server_v3_t *nfs) sigar_nfs_server_v3_t *nfs)
{ {
// #ifdef SIGAR_FREEBSD5_NFSSTAT #ifdef SIGAR_FREEBSD5_NFSSTAT
// struct nfsrvstats stats; struct nfsrvstats stats;
// size_t size = sizeof(stats); size_t size = sizeof(stats);
// if (sysctlbyname("vfs.nfsrv.nfsrvstats", &stats, &size, NULL, 0) == -1) { if (sysctlbyname("vfs.nfsrv.nfsrvstats", &stats, &size, NULL, 0) == -1) {
// return errno; return errno;
// } }
// map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.srvrpccnt[0]); map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.srvrpccnt[0]);
// #else #else
// int status; int status;
// struct nfsstats stats; struct nfsstats stats;
// if ((status = get_nfsstats(&stats)) != SIGAR_OK) { if ((status = get_nfsstats(&stats)) != SIGAR_OK) {
// return status; return status;
// } }
// map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.srvrpccnt[0]); map_nfs_stats((sigar_nfs_v3_t *)nfs, &stats.srvrpccnt[0]);
// #endif #endif
return SIGAR_OK; return SIGAR_OK;
} }

View File

@ -24,7 +24,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/times.h> #include <sys/times.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/sysmacros.h>
#include "sigar.h" #include "sigar.h"
#include "sigar_private.h" #include "sigar_private.h"
@ -51,10 +50,6 @@
#define PROC_PARTITIONS PROC_FS_ROOT "partitions" #define PROC_PARTITIONS PROC_FS_ROOT "partitions"
#define PROC_DISKSTATS PROC_FS_ROOT "diskstats" #define PROC_DISKSTATS PROC_FS_ROOT "diskstats"
#ifndef HZ
#define HZ 100
#endif
/* /*
* /proc/self/stat fields: * /proc/self/stat fields:
* 1 - pid * 1 - pid

View File

@ -70,7 +70,7 @@ struct sigar_t {
}; };
#define HAVE_STRERROR_R #define HAVE_STRERROR_R
#if !defined(__USE_XOPEN2K) && defined(__GLIBC__) #ifndef __USE_XOPEN2K
/* use gnu version of strerror_r */ /* use gnu version of strerror_r */
#define HAVE_STRERROR_R_GLIBC #define HAVE_STRERROR_R_GLIBC
#endif #endif

View File

@ -30,7 +30,6 @@
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
SIGAR_INLINE char *sigar_uitoa(char *buf, unsigned int n, int *len) SIGAR_INLINE char *sigar_uitoa(char *buf, unsigned int n, int *len)
{ {

View File

@ -1,7 +1,7 @@
copyright.year=2004-2011 copyright.year=2004-2011
version.major=2 version.major=2
version.minor=0 version.minor=0
version.maint=11 version.maint=4
version.build=0 version.build=0
project.name=kostya-sigar project.name=kostya-sigar
project.author=Doug MacEachern project.author=Doug MacEachern