Class: Unifiap

Inherits:
Oxidized::Model show all
Defined in:
lib/oxidized/model/unifiap.rb

Constant Summary

Constants inherited from Oxidized::Model

Oxidized::Model::METADATA_DEFAULT

Instance Attribute Summary

Attributes inherited from Oxidized::Model

#input, #node

Instance Method Summary collapse

Methods inherited from Oxidized::Model

cfg, #cfg, cfgs, clean, cmd, #cmd, cmds, comment, #comment, #expect, expect, expects, #expects, #get, inherited, #interpolate_string, metadata, #metadata, #output, post, pre, prompt, #prompt, #screenscrape, #send, #xmlcomment

Methods included from Oxidized::Config::Vars

#vars

Instance Method Details

#ntpskew(cfg) ⇒ Object

NTPskew: Return the skew in micro seconds from the ntpclient output



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/oxidized/model/unifiap.rb', line 127

def ntpskew(cfg)
  index = skew = nil

  cfg.each_line do |line|
    # Look for the header just before the stats line, and find which number is skew
    if line.match(/^\s*[a-z]+\s+[a-z]+\s+[a-z]+\s+[a-z]+/i)
      words = line.split
      index = words.map(&:downcase).index("skew")
    end
    # Now look for the single stats line and grab the skew
    if !index.nil? && line.match(/^\s*[\d.]+\s+[\d.]+\s+[\d.]+\s+[\d.]+/)
      numbers = line.split
      skew = numbers[index]
    end
  end
  skew
end