Files
scripts/Linux Monitor Interface via SNMP/mon_if.sh
2024-10-14 00:08:40 +02:00

32 lines
856 B
Bash

#!/bin/bash
if [ "$#" -lt "3" ]
then
echo ""
echo "Interfaces auflisten"
echo "mon_if.sh <IP> <community> list"
echo ""
echo "Graphen starten"
echo "mon_if.sh <IP> <community> <Intervall in Sekunden> <Anzeigedauer in Minuten> <Interface Name>"
echo ""
echo ""
exit 1
fi
if [ "$3" == "list" ]
then
echo "$1 Interfaces:"
echo ""
snmpwalk -c$2 -v2c $1 1.3.6.1.2.1.2.2.1.2 | grep -oP "STRING: \K.*"
echo ""
echo ""
exit
fi
IFID=`snmpwalk -c$2 -v2c $1 1.3.6.1.2.1.2.2.1.2 | grep $5 | grep -oP "\.\K\d*"`
./snmprtg --quiet --title "$1 Input $5 ($IFID)" --peer $1 --community $2 --interval $3 --window $4 --oid 1.3.6.1.2.1.2.2.1.10.$IFID --log 1 2>&1 >/dev/null &
./snmprtg --quiet --title "$1 Output $5 ($IFID)" --peer $1 --community $2 --interval $3 --window $4 --oid 1.3.6.1.2.1.2.2.1.16.$IFID --log 1 2>&1 >/dev/null &
echo ""
echo ""
exit