Skip to main content
  1. October/

Observium SNMP interface persistence mechanism

Observium and persistent interface Names #

The Problem #

Observium’s recomemndation here is to install the following script: โš ๏ธObservium distribution of this script

ifAlias_persist : should be installed in /usr/local/bin/ifAlias_persist:

#!/usr/bin/perl -w
#
#
# apt-get install libsnmp-extension-passpersist-perl
#
# 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
# pass_persist .1.3.6.1.2.1.31.1.1.1.18 /usr/bin/ifAlias_persist

use strict;
use SNMP::Extension::PassPersist;


# create the object
my $extsnmp = SNMP::Extension::PassPersist->new(
    backend_collect => \&update_tree,
    idle_count      => 10,      # no more than 10 idle cycles
    refresh         => 60,      # refresh every 60 sec
);

# run the program
$extsnmp->run;

sub update_tree {
    my ($self) = @_;


    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){
        my @split = split(": ", $row);
        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);
    }
#    $extsnmp->dump_oid_tree();

}

This will provide a list of interfaces in the same fashion this script does:

ip l | awk -F: ' /: / {print $2}'

This basically tells us what interfaces we’ll want to have comments in /etc/network/interfaces