scripts/snmp/bat.sh
pauget f8f65a3212 Mise jour du comptage pour mrtg
--
Fred

darcs-hash:20031208002347-41617-45bce0836fb9173c00e0f05cd7f92f49f05fb9f5.gz
2003-12-08 01:23:47 +01:00

88 lines
2.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"
}
GETOUTVALUE() {
snmpget -m $MIBFILE $HOSTNAME $COMMUNITY interfaces.ifTable.ifEntry.ifOutOctets.$1 | awk '{print $4}'
}
GETINVALUE() {
snmpget -m $MIBFILE $HOSTNAME $COMMUNITY interfaces.ifTable.ifEntry.ifInOctets.$1 | awk '{print $4}'
}
# La même chose en snmpv3
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)
GETVALUES3 $1 backbone 81
;;
batg)
# 2 uplinks du G
echo " $(GETOUTVALUE 13) + $(GETOUTVALUE 14) " | bc
echo " $(GETINVALUE 13) + $(GETINVALUE 14) " | bc
echo ""
echo "$1"
;;
batp)
GETVALUES3 $1 multiprise 24
;;
batm)
echo " $(GETOUTVALUE 15) + $(GETOUTVALUE 16) " | bc
echo " $(GETINVALUE 15) + $(GETINVALUE 16) " | bc
echo ""
echo "$1"
;;
bath)
GETVALUES $1 17
;;
bati)
GETVALUES3 $1 multiprise 14
;;
batj)
GETVALUES $1 19
;;
*)
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