From f38b1938ad6b98b60af711e1dd9c72293adf3456 Mon Sep 17 00:00:00 2001 From: f0o Date: Sat, 18 Jan 2014 14:53:15 +0100 Subject: [PATCH 1/2] Seemingly bug-free and free (as in freedom) version of Observium's ifAlias snmp extension. --- scripts/ifAlias | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 scripts/ifAlias diff --git a/scripts/ifAlias b/scripts/ifAlias new file mode 100755 index 000000000..da3d278a4 --- /dev/null +++ b/scripts/ifAlias @@ -0,0 +1,50 @@ +#!/bin/bash +# (c) 2013, f0o@devilcode.org +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +BASE='.1.3.6.1.2.1.31.1.1.1.18' +ID=$(cut -d . -f 13 <<< $2) +cache=$(ip l) + +if [ -z "$ID" ]; then + ID=0 +fi + +if [ "$1" = "-n" ]; then + IFS=" +" + for dev in $(grep mtu <<<"$cache" | cut -d : -f 1|sort -n); do + if [ "$LAST" == "$ID" ]; then + ID=$dev + BRK=1 + break + else + LAST=$dev + fi + done + if [ -z "$BRK" ]; then + exit 0 + fi +fi + +IFACE=$(grep "^${ID}: " <<<"$cache" | sed 's/[:@]\s/ /g'| cut -d " " -f 2) + +echo ${BASE}.${ID} +if [ "X${IFACE}" = "X" ]; then + echo noSuchName +else + echo "string" + echo $(grep "^# $IFACE:" /etc/network/interfaces | sed "s/^# $IFACE: //") +fi +exit 0 \ No newline at end of file From d1c7f00bed5c3ebbec2a11046e996f6615291146 Mon Sep 17 00:00:00 2001 From: f0o Date: Sun, 19 Jan 2014 13:52:34 +0100 Subject: [PATCH 2/2] Added wiki page. as discussed in #70 --- doc/Interface-Description-Parsing.md | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 doc/Interface-Description-Parsing.md diff --git a/doc/Interface-Description-Parsing.md b/doc/Interface-Description-Parsing.md new file mode 100644 index 000000000..290541388 --- /dev/null +++ b/doc/Interface-Description-Parsing.md @@ -0,0 +1,55 @@ +Table of Content: +- [About](#about) + - [Setup](#setup) +- [Keywords](#keywords) + - [Type-keywords](#type-keywords) + - [Info-keywords](#info-keywords) +- [Examples](#examples) +- [Sourcecode](#source) + +# About: + +Librenms can interpret, display and group certain additional information on ports. +For this a small `bash` script is supplied in `librenms/scripts` called `ifAlias`. + +Setup: + +This requires a little bit of setup on the monitored Server (Not the server running librenms!): + +* Add `ifAlias` from `/path/to/librenms/scripts/` or download it from [here](#source) to the Server and make + it executeable `chmod +x /path/to/ifAlias` +* Add to `snmpd.conf` something like: + ``pass .1.3.6.1.2.1.31.1.1.1.18 /path/to/ifAlias`` +* Restart your `net-snmpd` + +There are no changes to be made or additions to insteall for the polling librenms. + +Now you can set up your [keywords](#keywords) in your `/etc/network/interfaces` +``//Add more distributions than just Debian based`` + +# Keywords: + +See [examples](#examples) for formats. + +* Type-keywords: + * `Cust` - Customer + * `Transit` - Transit link + * `Peering` - Peering link + * `Core` - Infrastructure link (non-customer) + * `Server` - Server link (non-customer) +* Info-keywords: + * `()` contains a note + * `{}` contains *your* circuit id + * `[]` contains the service type or speed + +# Examples: +```text +# eth3: Cust: Example Customer [10Mbit] (T1 Telco Y CCID129031) {EXAMP0001}` +# eth0: Transit: Example Provider (AS65000)` +# eth1: Core: core.router01 FastEthernet0/0 (Telco X CCID023141)` +# eth2: Peering: Peering Exchange +``` + +# Sourcecode: + +* https://github.com/librenms/librenms/blob/master/scripts/ifAlias \ No newline at end of file