Module: PosixPsutil::COMMON
- Defined in:
- lib/posixpsutil/common.rb
Constant Summary collapse
- LINUX_PLATFORM =
/linux/i- NON_LINUX_PLATFORM =
/darwin|mac os|solaris|bsd|aix/i- OSX_PLAFORM =
/darwin|mac os/i- NON_OSX_PLATFORM =
/linux|solaris|bsd|aix/i- EXT =
The name of dynamic library where we put platform specific C extention into. If you want to change the name, please change ext/*/Makefile too.
File.('../../../ext', __FILE__)
- LibLinuxName =
File.join(EXT, 'linux', 'libposixpsutil.so')
- LibPosixName =
File.join(EXT, 'posix', 'libposixpsutil.so')
- LibOSXName =
File.join(EXT, 'posix', 'libposixpsutil.dylib')
- CLOCK_TICKS =
100- PAGE_SIZE =
4096- STATUS_RUNNING =
"running"- STATUS_SLEEPING =
"sleeping"- STATUS_DISK_SLEEP =
"disk-sleep"- STATUS_STOPPED =
"stopped"- STATUS_TRACING_STOP =
"tracing-stop"- STATUS_ZOMBIE =
"zombie"- STATUS_DEAD =
"dead"- STATUS_WAKE_KILL =
"wake-kill"- STATUS_WAKING =
"waking"- STATUS_IDLE =
BSD
"idle"- STATUS_LOCKED =
BSD
"locked"- STATUS_WAITING =
BSD
"waiting"
Class Method Summary collapse
-
.usage_percent(used, total, _round = nil) ⇒ Object
Calculate percentage usage of ‘used’ against ‘total’.
Class Method Details
.usage_percent(used, total, _round = nil) ⇒ Object
Calculate percentage usage of ‘used’ against ‘total’.
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/posixpsutil/common.rb', line 37 def self.usage_percent(used, total, _round=nil) begin ret = (used / total.to_f) * 100 rescue ZeroDivisionError ret = 0 end if _round return ret.round(_round) else return ret end end |