mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #70 from f0o/master
Merge PR #70 from @f0o to add ifAlias parsing on monitored servers
This commit is contained in:
55
doc/Interface-Description-Parsing.md
Normal file
55
doc/Interface-Description-Parsing.md
Normal file
@@ -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)
|
||||
|
||||
# <a name="about">About</a>:
|
||||
|
||||
Librenms can interpret, display and group certain additional information on ports.
|
||||
For this a small `bash` script is supplied in `librenms/scripts` called `ifAlias`.
|
||||
|
||||
<a name="setup">Setup</a>:
|
||||
|
||||
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``
|
||||
|
||||
# <a name="keywords">Keywords</a>:
|
||||
|
||||
See [examples](#examples) for formats.
|
||||
|
||||
* <a name="type-keywords">Type-keywords</a>:
|
||||
* `Cust` - Customer
|
||||
* `Transit` - Transit link
|
||||
* `Peering` - Peering link
|
||||
* `Core` - Infrastructure link (non-customer)
|
||||
* `Server` - Server link (non-customer)
|
||||
* <a name="info-keywords">Info-keywords</a>:
|
||||
* `()` contains a note
|
||||
* `{}` contains *your* circuit id
|
||||
* `[]` contains the service type or speed
|
||||
|
||||
# <a name="examples">Examples</a>:
|
||||
```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
|
||||
```
|
||||
|
||||
# <a name="source">Sourcecode</a>:
|
||||
|
||||
* https://github.com/librenms/librenms/blob/master/scripts/ifAlias
|
||||
50
scripts/ifAlias
Executable file
50
scripts/ifAlias
Executable file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user