munin-contrib/plugins/snmp/snmp___bri_se_

64 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#
# Munin plugin snmp__bri_se_
#
# Version: 0.2, released on 30/02/2009, tested on Debian GNU/Linux 4.0 (etch)
# using Cisco 5350 gateways.
#
# This plugin reports the number of BRI channels currently in use on SE/foo
# using SNMP community bar.
#
# Requirements: bash, snmpget, rev, cut, which
#
# Copyright (c) 2009 by Kees Meijs <kees@kumina.nl> for Kumina bv.
#
# This work is licensed under the Creative Commons Attribution-Share Alike 3.0
# Unported license. In short: you are free to share and to make derivatives of
# this work under the conditions that you appropriately attribute it, and that
# you only distribute it under the same, similar or a compatible license. Any
# of the above conditions can be waived if you get permission from the copyright
# holder.
# HOW TO?
#
# Symlink snmp___bri_se_ to /etc/munin/plugins/snmp_HOSTNAME_COMMUNITY_bri_se_SEOFGATEWAY
# For example: snmp_1.2.3.4_public_bri_se_3 to check community "public" on host "1.2.3.4"
# using SE #3.
# More strict checking
set -e
# Check for snmpget
SNMPGET=$(which snmpget)
# Catch command line arguments
JOB=$1
# Set variables
HOSTNAME=$(echo $0 | rev | cut -d '_' -f 5 | rev)
COMMUNITY=$(echo $0 | rev | cut -d '_' -f 4 | rev)
SE=$(echo $0 | rev | cut -d '_' -f 1 | rev)
# Configure Munin
case "$1" in
"config")
echo "host_name $HOSTNAME"
echo "graph_title BRI usage on SE-$SE"
echo "graph_vlabel Number of used BRI channels"
echo "graph_scale no"
echo "graph_category network"
for CHANNEL in $(seq 0 7); do
echo "chan_$CHANNEL.label SE-$SE/$CHANNEL used channels"
done
exit 0;;
esac
# Return fetched SNMP values
for CHANNEL in $(seq 0 7); do
echo -n "chan_$CHANNEL.value "
$SNMPGET -v 1 -c $COMMUNITY $HOSTNAME 1.3.6.1.4.1.9.10.19.1.1.9.1.3.$SE.$CHANNEL | rev | cut -d ' ' -f 1 | rev
done
# Exit cleanly
exit 0