Le lundi 16 juillet 2007 à 11:08,
"DI BACCO ANTONIO - technolabs" <[EMAIL PROTECTED]> écrivait :
> Is it possible to add a new trap sink dinamically (and programmatically,
> not via configuration files) from within an AgentX subagent?
This is a question I asked here a little while ago, the answer was to
look to snmpNotifyTable and snmpTargetAddressTable in the SNMPv2 MIB.
So I did, and the result is this ugly script that may at least help to
understand what has to be done to add a notification.
#!/bin/sh
# Dynamically adds a notification target to a snmpd enabled host
if [ "-h" == "$1" -o "" == "$1" ] ; then
echo "Usage :"
echo "$0 <hostname> <label> <ipaddr> <community>"
echo " Add on snmpd host <hostname> a trap receiver labeled <label>,"
echo " that sends traps to IP <ipaddr>"
echo "$0 -r <hostname> <label> <community>"
echo " Removes trap receiver labeled <label> on host <hostname>"
exit 0
fi
if [ "-r" == "$1" ] ; then
HOST=$2
NAME=$3
COMMUNITY=$4
snmpset -c $COMMUNITY -v 2c $HOST snmpNotifyRowStatus.\'$NAME\' i destroy
snmpset -c $COMMUNITY -v 2c $HOST snmpTargetAddrRowStatus.\'$NAME\' i
destroy
snmpset -c $COMMUNITY -v 2c $HOST snmpTargetParamsRowStatus.\'$NAME\' i
destroy
exit 0
fi
HOST=$1
NAME=$2
SINK=$3
COMMUNITY=$4
snmpset -v2c -c $COMMUNITY $HOST \
snmpTargetParamsRowStatus.\'$NAME\' i createAndWait
snmpset -v2c -c $COMMUNITY $HOST \
snmpTargetParamsMPModel.\'$NAME\' i 0 \
snmpTargetParamsSecurityModel.\'$NAME\' i 1 \
snmpTargetParamsSecurityName.\'$NAME\' s "public" \
snmpTargetParamsSecurityLevel.\'$NAME\' i 1 \
snmpTargetParamsRowStatus.\'$NAME\' i active
snmpset -v2c -c $COMMUNITY $HOST \
snmpTargetAddrRowStatus.\'$NAME\' i createAndWait
snmpset -v2c -c $COMMUNITY $HOST \
snmpTargetAddrTDomain.\'$NAME\' o snmpUDPDomain \
snmpTargetAddrTAddress.\'$NAME\' d $SINK.0.162 \
snmpTargetAddrTimeout.\'$NAME\' i 0 \
snmpTargetAddrRetryCount.\'$NAME\' i 0 \
snmpTargetAddrTagList.\'$NAME\' s $NAME \
snmpTargetAddrParams.\'$NAME\' s $NAME \
snmpTargetAddrRowStatus.\'$NAME\' i active
snmpset -v2c -c $COMMUNITY $HOST \
snmpNotifyRowStatus.\'$NAME\' i createAndWait
snmpset -v2c -c $COMMUNITY $HOST \
snmpNotifyTag.\'$NAME\' s $NAME \
snmpNotifyType.\'$NAME\' i trap \
snmpNotifyRowStatus.\'$NAME\' i active
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users