scripts/snmp/bat.sh
pauget 0cbad2ad36 Le H en giga sur le backbone.
darcs-hash:20040514140442-41617-a423042f1e57313f6d7b6cddbf55a81ada468b53.gz
2004-05-14 16:04:42 +02:00

82 lines
2 KiB
Bash
Executable file

#!/bin/sh
############################################################################
# Script de requette snmp pour le monitoring des ports des switchs #
# #
# Nicolas Stransky, juin 2k1 #
# Mise à jour pour switchs HP en snmpv3, Fred décembre 2003 #
############################################################################
. /root/snmp-community-names
#HOSTNAME=microrep
#COMMUNITY=$OLD_BACKBONE_COMMUNITY
USERNAME=$BACKBONE_USER
#MIBFILE=/usr/scripts/snmp/Des5200.mib
#test -f $MIBFILE || exit 0
#GETVALUES() {
# snmpget -m $MIBFILE $HOSTNAME $COMMUNITY interfaces.ifTable.ifEntry.ifOutOctets.$2 | awk '{print $4}'
# snmpget -m $MIBFILE $HOSTNAME $COMMUNITY interfaces.ifTable.ifEntry.ifInOctets.$2 | awk '{print $4}'
# echo ""
# echo "$1"
#}
GETOUTVALUE3() {
snmpget -v 3 $1 -u $USERNAME interfaces.ifTable.ifEntry.ifOutOctets.$2 | awk '{print $4}'
}
GETINVALUE3() {
snmpget -v 3 $1 -u $USERNAME interfaces.ifTable.ifEntry.ifInOctets.$2 | awk '{print $4}'
}
GETVALUES3() {
snmpget -v 3 $2 -u $USERNAME interfaces.ifTable.ifEntry.ifOutOctets.$3 | awk '{print $4}'
snmpget -v 3 $2 -u $USERNAME interfaces.ifTable.ifEntry.ifInOctets.$3 | awk '{print $4}'
echo ""
echo "$1"
}
case "$1" in
bata)
GETVALUES3 $1 backbone 79
;;
batb)
GETVALUES3 $1 backbone 80
;;
batc)
echo " $(GETOUTVALUE3 backbone 81) + $(GETOUTVALUE3 backbone 82) " | bc
echo " $(GETINVALUE3 backbone 81) + $(GETINVALUE3 backbone 82) " | bc
echo ""
echo "$1"
;;
batg)
GETVALUES3 $1 backbone 28
;;
batp)
GETVALUES3 $1 multiprise 14
;;
batm)
GETVALUES3 $1 backbone 27
;;
bath)
GETVALUES3 $1 backbone 30
;;
bati)
GETVALUES3 $1 backbone 29
;;
batj)
GETVALUES3 $1 multiprise 13
;;
*)
echo "Monitoring des switchs par snmp. Voir /etc/mrtg.cfg"
echo "Usage : /usr/scripts/snmp/bat.sh bata|batb|batc|batg|bath|bati|batj|batm|batp">&2
exit 1
;;
esac
exit 0