Help with Comware switches in Oxidized

Ok, so at the locations of some of our LibreNMS installs we have multiple comware model switches, HP 1910 and HP 1920. Well, I finally got oxidized working to backup the config of them using the comware_cmdline var but kind of did it a janky way and I was wondering if there was a better or more recommended way of doing it?? I’m feeding oxidized from LibreNMS.

Here is my oxidized config:


username: username
password: password
model: procurve
interval: 86400
use_syslog: false
debug: true
threads: 30
timeout: 300
retries: 3
prompt: !ruby/regexp /^([\[email protected]]+[#>]\s?)$/
rest: 0.0.0.0:8888
next_adds_job: false
vars: {}
groups:
firewalls:
vars:
ssh_port: port
models:
comware:
username: username
password: password
vars:
comware_cmdline1: “512900”
comware_cmdline2: “Jinhua1920unauthorized”
aosw:
username: username
password: password
fortios:
username: username
password: password
airos:
username: username
password: password
pid: “/root/.config/oxidized/pid”
input:
default: ssh, telnet
debug: true
ssh:
secure: false
output:
file:
directory: /root/.config/oxidized/configs
source:
default: http
debug: false
http:
secure: false
url: http://localhost/api/v0/oxidized
map:
name: hostname
model: os
group: group
headers:
X-Auth-Token: b5a1a874828c3cbc23eb954a5606e273
model_map:
cisco: ios
juniper: junos
hp: procurve
arubaos: aosw
aruba-instant: aosw
fortigate: fortios
3com: comware
unifi: airos


And here is my edited comware.rb file to make it work:


class Comware < Oxidized::Model
#HP (A-series)/H3C/3Com Comware

#sometimes the prompt might have a leading nul or trailing ASCII Bell (^G)
prompt /^\0*(<[\w.-]+>).?$/
comment '# ’

#example how to handle pager
#expect /^\s*---- More ----$/ do |data, re|
#send ’ ’
#data.sub re, ‘’
#end

cmd :all do |cfg|
# cfg.gsub! /^.*\e[42D/, ‘’ # example how to handle pager
# skip rogue ^M
cfg = cfg.delete “\r”
cfg.cut_both
end

cmd :secret do |cfg|
cfg.gsub! /^( snmp-agent community)./, '\1 ’
cfg.gsub! /^( password hash).
/, '\1 ’
cfg.gsub! /^( password cipher).*/, '\1 ’
cfg
end

cfg :telnet do
username /^(Username|login):confused:
password /^Password:/
end

cfg :telnet, :ssh do
# enable command-line mode on SMB comware switches (HP V1910, V1920)
# autodetection is hard, because the ‘summary’ command is paged, and
# the pager cannot be disabled before _cmdline-mode on.
if vars :comware_cmdline1
post_login do
# HP V1910
cmd ‘_cmdline-mode on’, /(#{@node.prompt}|Continue)/
cmd ‘y’, /(#{@node.prompt}|input password)/
cmd vars(:comware_cmdline1)
end
end
if vars :comware_cmdline2
post_login do
# HP 1920
cmd ‘_cmdline-mode on’, /(#{@node.prompt}|Continue)/
cmd ‘y’, /(#{@node.prompt}|input password)/
cmd vars(:comware_cmdline2)
end
end

post_login 'screen-length disable'
post_login 'undo terminal monitor'
pre_logout 'quit'

end

cmd ‘display version’ do |cfg|
cfg = cfg.each_line.reject { |l| l.match /uptime/i }.join
comment cfg
end

cmd ‘display device’ do |cfg|
comment cfg
end

cmd ‘display device manuinfo’ do |cfg|
cfg = cfg.each_line.reject { |l| l.match ‘FF’.hex.chr }.join
comment cfg
end

cmd ‘display current-configuration’ do |cfg|
cfg
end
end