我有一個Perl腳本來監視任何啓用了SNMP的服務。Perl:SNMP - 通配符OID
它的工作方式是我有一個包含多個服務的配置文件,每個服務都有一個要收集的指標列表。
實施例:
[switch]
switch_stuff1 = 1.3.6.1.2.1.7.1.0
switch_stuff2 = 1.3.6.1.2.1.7.4.0
switch_stuff3 = 1.3.6.1.2.1.6.2.0
switch_stuff4 = 1.3.6.1.2.1.6.3.0
switch_stuff5 = 1.3.6.1.2.1.6.5.0
[router]
router_stuff1 = 1.3.6.1.2.1.6.8.0
router_stuff2 = 1.3.6.1.2.1.6.8.0
router_stuff3 = 1.3.6.1.2.1.6.9.0
[database]
db_stuff1 = 1.3.6.1.2.1.6.4.0
db_stuff2 = 1.3.6.1.2.1.6.5.0
該腳本將通過配置文件循環,獲得該信息對於所有的度量和輸出寫入到CSV文件。
現在,我需要幫助。
我被要求實現允許在SNMP路徑中使用通配符來收集的邏輯。所以,我的配置文件現在需要這個樣子:
[switch]
switch_stuff1 = 1.5.1.6.*
switch_stuff2 = 1.45.*.12
所以當收集會發生,它會以某種方式循環是這樣的:
switch_stuff1
1.5.1.6.0 – found, continue
1.5.1.6.1 – found, continue
1.5.1.6.2 – not found, stop
switch_stuff2
1.45.0.12 – found, continue
1.45.1.12 – found, continue
1.45.2.12 – found, continue
1.45.3.12 – not found, stop
我目前使用Net :: SNMP庫:
http://metacpan.org/pod/Net::SNMP
請問這是可能的嗎?我想通過get_entries或get_table方法模擬一個「snmpwalk」,但我不太確定這是否可行。
如果任何人都可以幫忙或至少指出我在正確的方向,這將不勝感激。
謝謝。