openvz 1.2 → 1.4
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/lib/openvz.rb +1 -1
- data/lib/openvz/container.rb +14 -0
- data/lib/openvz/inventory.rb +4 -0
- data/lib/openvz/log.rb +0 -1
- data/openvz.gemspec +1 -1
- metadata +3 -3
data/lib/openvz.rb
CHANGED
data/lib/openvz/container.rb
CHANGED
@@ -28,6 +28,7 @@ module OpenVZ
|
|
28
28
|
class Container
|
29
29
|
|
30
30
|
attr_accessor :config
|
31
|
+
attr_reader :ctid
|
31
32
|
|
32
33
|
class StatemachineError < StandardError;end
|
33
34
|
class Config < ::OpenVZ::ConfigHash ; end
|
@@ -222,6 +223,19 @@ module OpenVZ
|
|
222
223
|
end
|
223
224
|
|
224
225
|
|
226
|
+
# Return the current uptime in seconds.
|
227
|
+
# Return zero if the container is not running.
|
228
|
+
#
|
229
|
+
# @example
|
230
|
+
# puts container.uptime()
|
231
|
+
# 1188829
|
232
|
+
def uptime
|
233
|
+
return 0 unless status.include? "running"
|
234
|
+
raw = command "cat /proc/uptime"
|
235
|
+
Log.debug("Container (#{@ctid}) uptime requested: #{raw}")
|
236
|
+
raw.split(/\W/).first.to_i
|
237
|
+
end
|
238
|
+
|
225
239
|
|
226
240
|
####
|
227
241
|
#### Helper methods
|
data/lib/openvz/inventory.rb
CHANGED
data/lib/openvz/log.rb
CHANGED
@@ -35,7 +35,6 @@ module OpenVZ
|
|
35
35
|
|
36
36
|
# logs message at level
|
37
37
|
def log(level, msg)
|
38
|
-
puts "#{@known_levels.index(level)} <= #{@known_levels.index(@active_level)}"
|
39
38
|
if @known_levels.index(level) <= @known_levels.index(@active_level)
|
40
39
|
t = Time.new.strftime("%H:%M:%S")
|
41
40
|
STDERR.puts "#{t}: #{level}: #{from}: #{msg}"
|
data/openvz.gemspec
CHANGED
metadata
CHANGED