class Dribbled::DrbdResource
Attributes
activity[RW]
config[RW]
cs[RW]
ds[RW]
finish[RW]
id[R]
in_configuration[RW]
in_kernel[RW]
name[RW]
percent[RW]
primary[RW]
ro[RW]
secondary[RW]
Public Class Methods
new(res,hostname)
click to toggle source
# File lib/dribbled/drbd.rb, line 143 def initialize(res,hostname) @id = res @name = nil @config = nil @ds = nil @cs = nil @ro = nil @activity = nil @percent = nil @finish = nil @primary = { :hostname => nil, :disk => nil, :device => nil } @secondary = { :hostname => nil, :disk => nil, :device => nil } @in_kernel = false @in_configuration = false end
Public Instance Methods
check()
click to toggle source
# File lib/dribbled/drbd.rb, line 229 def check end
in_configuration?()
click to toggle source
# File lib/dribbled/drbd.rb, line 163 def in_configuration? @in_configuration end
in_kernel?()
click to toggle source
# File lib/dribbled/drbd.rb, line 159 def in_kernel? @in_kernel end
inspect()
click to toggle source
# File lib/dribbled/drbd.rb, line 225 def inspect "#{self.class}: #{@id}[#{@name}]: #{@cs},#{@ds},#{@ro}" end
status()
click to toggle source
# File lib/dribbled/drbd.rb, line 167 def status s = :unknown o = 'unable to assert health' if self.cs == 'Unconfigured' [:ok,"#{self.id}[unconfigured]"] else if self.in_kernel? and self.in_configuration? if self.cs == 'Connected' and self.ds == 'UpToDate/UpToDate' and (self.ro == 'Primary/Secondary' or self.ro == 'Secondary/Primary') s = :ok else if ['SyncSource','SyncTarget','VerifyS','VerifyT','PausedSyncS','PausedSyncT','StandAlone'].include? self.cs s = :warning elsif not self.in_configuration? s = :warning else s = :critical end end else s = :unknown end end [s,self.to_s(:concise)] end
to_s(mode=:line)
click to toggle source
# File lib/dribbled/drbd.rb, line 194 def to_s(mode=:line) ph = @primary[:hostname].gsub(/\.[a-z0-9-]+\.[a-z0-9-]+$/,'') unless @primary[:hostname].nil? sh = @secondary[:hostname].gsub(/\.[a-z0-9-]+\.[a-z0-9-]+$/,'') unless @secondary[:hostname].nil? if @ro == 'Primary/Secondary' h1 = ph; dev1 = @primary[:device] h2 = sh; dev2 = @secondary[:device] else h1 = sh; dev1 = @secondary[:device] h2 = ph; dev2 = @primary[:device] end percent_finish = @activity.nil? ? nil : '[%3d%% %8s]' % [@percent,@finish] case mode when :line fmt_string = '%2d %6s %-13s %15s %-22s %-20s %10s %-11s %10s %-11s' percent_finish = @activity.nil? ? nil : '[%3d%% %8s]' % [@percent,@finish] when :concise fmt_string = '%s>%s:%s%s:%s:%s' percent_finish = @activity.nil? ? nil : '[%d%%,%s]' % [@percent,@finish] when :verbose fmt_string = '%s' else fmt_string = '%s' end fmt_string % [@id,@name,@cs,percent_finish,@ro,@ds,h1,dev1,h2,dev2] end