Commit version 24.12.13800
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# WARNING. Use better variant of persist ifAlias script from this dir.
|
||||
# - python, need install:
|
||||
# sudo pip install snmp_passpersist
|
||||
# - add to snmpd.conf
|
||||
# pass_persist .1.3.6.1.2.1.31.1.1.1.18 /usr/local/bin/ifAlias.py
|
||||
|
||||
# SNMP::Extension::PassPersist is required.
|
||||
# This is in the package libsnmp-extension-passpersist-perl on Debian and Ubuntu
|
||||
# Usage : Copy the script to /usr/bin/ifAlias_persist and add to /etc/snmp/snmpd.conf
|
||||
@ -22,14 +28,24 @@ $extsnmp->run;
|
||||
sub update_tree {
|
||||
my ($self) = @_;
|
||||
|
||||
|
||||
if (-f "/etc/frr/frr.conf") {
|
||||
my $mode = "frr";
|
||||
} else {
|
||||
my $mode = "debian";
|
||||
}
|
||||
my $Base = ".1.3.6.1.2.1.31.1.1.1.18";
|
||||
my @iface_list = `ip l | grep mtu`;
|
||||
my $type = "string";
|
||||
|
||||
foreach my $row (@iface_list){
|
||||
foreach my $row (@iface_list) {
|
||||
my @split = split(": ", $row);
|
||||
my $desc = `grep "^# $split[1]:" /etc/network/interfaces|sed s/^\\#\\ $split[1]:\\ //`;
|
||||
if ($mode == "frr") {
|
||||
# see: https://jira.observium.org/browse/OBS-4036
|
||||
# my $desc = `grep -A 1 "^interface $split[1]" /etc/frr/frr.conf | tail -1 |sed "s/^\\ description\\ //"`;
|
||||
my $desc = `awk "/^interface $split[1]/,/^exit/" /etc/frr/frr.conf | awk "/^ description /" | sed "s/^\\ description\\ //"`;
|
||||
} else {
|
||||
my $desc = `grep "^# $split[1]:" /etc/network/interfaces | sed s/^\\#\\ $split[1]:\\ //`;
|
||||
}
|
||||
chomp($desc);
|
||||
my ($key, $value) = ("$Base.$split[0]",$desc);
|
||||
$self->add_oid_entry($key,$type,$value);
|
||||
@ -37,6 +53,3 @@ sub update_tree {
|
||||
# $extsnmp->dump_oid_tree();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user