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

Constants included from Oxidized::Model::Macros

Oxidized::Model::Macros::VERBS

Instance Attribute Summary

Attributes inherited from Oxidized::Model

#input, #node

Attributes included from Oxidized::Model::DSLCommands

#procs

Instance Method Summary collapse

Methods inherited from Oxidized::Model

#cfg, #cmd, #comment, #expect, #expects, #get, inherited, #interpolate_string, #metadata, #output, #prompt, #screenscrape, #send, #significant_changes, #xmlcomment

Methods included from Oxidized::Model::DSLSetup

#cfg, #cfgs, #comment, #expect, #expects, #input_sequence, #inputs, #metadata, #prompt

Methods included from Oxidized::Model::DSLCommands

#cmd, #cmds, #post, #pre

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