Module: LinuxStat::Sysinfo
- Defined in:
- ext/sysinfo/sysinfo.c
Class Method Summary collapse
- .bufferram ⇒ Object
- .freehigh ⇒ Object
- .freeram ⇒ Object
- .freeswap ⇒ Object
- .loads ⇒ Object
- .sharedram ⇒ Object
- .totalhigh ⇒ Object
- .totalram ⇒ Object
- .totalswap ⇒ Object
- .uptime ⇒ Object
Class Method Details
.bufferram ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'ext/sysinfo/sysinfo.c', line 45
VALUE bufferram(VALUE obj) {
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.bufferram) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.freehigh ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'ext/sysinfo/sysinfo.c', line 82
VALUE freehigh(VALUE obj) {
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.freehigh) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.freeram ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'ext/sysinfo/sysinfo.c', line 27
VALUE freeram(VALUE obj) {
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.freeram) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.freeswap ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'ext/sysinfo/sysinfo.c', line 64
VALUE freeswap(VALUE obj) {
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.freeswap) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.loads ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'ext/sysinfo/sysinfo.c', line 99
VALUE loads(VALUE obj) {
short status = sysinfo(&info) ;
if(status < 0) return rb_ary_new() ;
long double load = 1.f / (1 << SI_LOAD_SHIFT) ;
float l_1 = info.loads[0] * load ;
float l_5 = info.loads[1] * load ;
float l_15 = info.loads[2] * load ;
return rb_ary_new_from_args(3,
rb_float_new(l_1),
rb_float_new(l_5),
rb_float_new(l_15)
) ;
}
|
.sharedram ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'ext/sysinfo/sysinfo.c', line 36
VALUE sharedram(VALUE obj) {
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.sharedram) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.totalhigh ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'ext/sysinfo/sysinfo.c', line 73
VALUE totalhigh(VALUE obj) {
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.totalhigh) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.totalram ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'ext/sysinfo/sysinfo.c', line 17
VALUE totalram(VALUE obj) {
static struct sysinfo info ;
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.totalram) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.totalswap ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'ext/sysinfo/sysinfo.c', line 54
VALUE totalswap(VALUE obj) {
static struct sysinfo info ;
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
VALUE _rb_v = ULL2NUM((unsigned long long) info.totalswap) ;
VALUE _rb_mem_unit = ULL2NUM((unsigned long long) info.mem_unit) ;
return rb_funcallv_public(_rb_v, rb_intern("*"), 1, &_rb_mem_unit) ;
}
|
.uptime ⇒ Object
91 92 93 94 95 96 97 |
# File 'ext/sysinfo/sysinfo.c', line 91
VALUE uptime(VALUE obj) {
short status = sysinfo(&info) ;
if (status < 0) return Qnil ;
uint64_t v = info.uptime ;
return ULL2NUM((unsigned long long) v) ;
}
|