Method: LinuxStat::OS.uptime
- Defined in:
- lib/linux_stat/os.rb
.uptime ⇒ Object
Reads /proc/uptime and returns the system uptime:
LinuxStat::OS.uptime
=> {:hour=>16, :minute=>10, :second=>11, :jiffy=>20}
Using uptime is 10x slower than using uptime_i
If the stat isn’t available, an empty hash is returned.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/linux_stat/os.rb', line 150 def uptime _uptime = LinuxStat::ProcFS.uptime_f return {} unless _uptime uptime_i = _uptime.to_i h = uptime_i / 3600 m = uptime_i % 3600 / 60 s = uptime_i.%(60) j = _uptime.-(uptime_i) * 100 { hour: h, minute: m, second: s, jiffy: j.to_i } end |