summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/ios.rb
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2017-03-24 11:31:32 +0200
committerGitHub <noreply@github.com>2017-03-24 11:31:32 +0200
commitd218bb2684fb0c619c9dc67b952dda3e0f940a1d (patch)
treed8740d07d4e22e4cb2d9e29f756f9800983d4da5 /lib/oxidized/model/ios.rb
parent4a67e27742c0ab8ed6cd8421d34c01c0de588705 (diff)
parentda074381e4b998270e0886152446de7945ba120e (diff)
Merge pull request #783 from rfdrake/master
Adding support for more "show version" commands
Diffstat (limited to 'lib/oxidized/model/ios.rb')
-rw-r--r--lib/oxidized/model/ios.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb
index 94a3ab0..d155aa6 100644
--- a/lib/oxidized/model/ios.rb
+++ b/lib/oxidized/model/ios.rb
@@ -19,6 +19,8 @@ class IOS < Oxidized::Model
cmd :all do |cfg|
#cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
#cfg.gsub! /\cH+/, '' # example how to handle pager
+ # get rid of errors for commands that don't work on some devices
+ cfg.gsub! /^ % Invalid input detected at '\^' marker\./, ''
cfg.each_line.to_a[1..-2].join
end
@@ -36,7 +38,42 @@ class IOS < Oxidized::Model
end
cmd 'show version' do |cfg|
- comment cfg.lines.first
+ comments = []
+ comments << cfg.lines.first
+ lines = cfg.lines
+ lines.each_with_index do |line,i|
+ slave = ''
+ slaveslot = ''
+
+ if line.match /^Slave in slot (\d+) is running/
+ slave = " Slave:";
+ slaveslot = ", slot #{$1}";
+ end
+
+ if line.match /(\S+(?:\sseries)?)\s+(?:\((\S+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i
+ sproc = $1
+ cpu = $2
+ mem = $3
+ cpuxtra = ''
+ comments << "Chassis type:#{slave} #{sproc}";
+ comments << "Memory:#{slave} main #{mem}";
+ # check the next two lines for more CPU info
+ if cfg.lines[i+1].match /processor board id (\S+)/i
+ comments << "Processor ID: #{$1}";
+ end
+ if cfg.lines[i+2].match /(cpu at |processor: |#{cpu} processor,)/i
+ # change implementation to impl and prepend comma
+ cpuxtra = cfg.lines[i+2].gsub(/implementation/,'impl').gsub(/^/,', ').chomp;
+ end
+ comments << "CPU:#{slave} #{cpu}#{cpuxtra}#{slaveslot}";
+ end
+
+ if line.match /^System image file is "([^\"]*)"$/
+ comments << "Image: #{$1}"
+ end
+ end
+ comments << "\n"
+ comment comments.join "\n"
end
cmd 'show inventory' do |cfg|