Oxidized備份華為防火牆配置Last Status紅色,備份失敗,查看oxidized日志(默認是~/.config/oxidized/logs/oxidized.log)能看到報錯日志:
WARN -- : 10.10.0.14 raised Oxidized::PromptUndetect with msg " ************************************************************************* * Copyright (C) 2014-2018 Huawei Technologies Co., Ltd. * * All rights reserved. * * Without the owner's prior written consent, * * no decompiling or reverse-engineering shall be allowed. * ************************************************************************* Info: The max number of VTY users is 10, and the number of current VTY users on line is 1. HRP_M<USG6650E> not matching configured prompt (?-mix:^(<[\w.-]+>)$)"
出問題的原因是huawei防火牆運行在HRP模式下時,提示符前會加上HRP_M或者HRP_S字樣,和獨立運行情況下的尖括號或者方括號提示符不一樣。
解決辦法
不同設備的特征是在model里定義的,這里直接修改華為的model解決問題。
華為防火牆的系統成為VRP,由於oxidized是通過ruby gem安裝的,model文件在gem的安裝文件夾下。
在配置文件里要使用小寫的vrp,如果大寫備份也會失敗,日志報錯為 VRP not found for node xx.xx.xx.xx
使用命令 gem envi 可以顯示gem安裝的程序的安裝路徑,這里可能會顯示:
- GEM PATHS: - /usr/local/lib/ruby/gems/2.7.0 - /root/.gem/ruby/2.7.0
那么進入model的安裝路徑 cd /usr/local/lib/ruby/gems/2.7.0/gems/oxidized-`oxidized -v`/lib/oxidized/model
編輯文件vrp.rb,把 prompt /^(<[\w.-]+>)$/ 改成 prompt /^(HRP_[MS])?(<[\w.-]+>)$/
(HRP_[MS])? 這部分正則可以兼容含有或不含有HRP的前綴。重啟oxidized服務后生效。