Blame testing/fulltests/default/T113agentxtrap_simple

Packit Service b38f0b
#!/bin/sh
Packit Service b38f0b
Packit Service b38f0b
. ../support/simple_eval_tools.sh
Packit Service b38f0b
Packit Service b38f0b
HEADER AgentX trap sending support
Packit Service b38f0b
Packit Service b38f0b
SKIPIFNOT USING_AGENTX_MASTER_MODULE
Packit Service b38f0b
SKIPIFNOT USING_AGENTX_SUBAGENT_MODULE
Packit Service b38f0b
SKIPIFNOT USING_EXAMPLES_EXAMPLE_MODULE
Packit Service b38f0b
SKIPIFNOT NETSNMP_SECMOD_USM
Packit Service b38f0b
Packit Service b38f0b
#
Packit Service b38f0b
# Begin test
Packit Service b38f0b
#
Packit Service b38f0b
Packit Service b38f0b
# start the trap demon
Packit Service b38f0b
CONFIGTRAPD authcommunity log public
Packit Service b38f0b
STARTTRAPD
Packit Service b38f0b
Packit Service b38f0b
# standard V3 configuration for initial user
Packit Service b38f0b
. ./Sv3config
Packit Service b38f0b
# configure the trap receiver.
Packit Service b38f0b
CONFIGAGENT trapsink ${SNMP_TRANSPORT_SPEC}:${SNMP_TEST_DEST}${SNMP_SNMPTRAPD_PORT} public
Packit Service b38f0b
Packit Service b38f0b
# Start the agent without initializing the example mib.
Packit Service b38f0b
if [ "x$SNMP_TRANSPORT_SPEC" = "xunix" ];then
Packit Service b38f0b
ORIG_AGENT_FLAGS="$AGENT_FLAGS -x $SNMP_TMPDIR/agentx_socket"
Packit Service b38f0b
else
Packit Service b38f0b
ORIG_AGENT_FLAGS="$AGENT_FLAGS -x tcp:${SNMP_TEST_DEST}${SNMP_AGENTX_PORT}"
Packit Service b38f0b
fi
Packit Service b38f0b
AGENT_FLAGS="$ORIG_AGENT_FLAGS -I -example"
Packit Service b38f0b
STARTAGENT
Packit Service b38f0b
Packit Service b38f0b
# test to see that the current agent doesn't support the example mib
Packit Service b38f0b
CAPTURE "snmpget -On -t 3 $SNMP_FLAGS $AUTHTESTARGS $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.4.1.2021.254.1.0"
Packit Service b38f0b
Packit Service b38f0b
CHECK "No Such Object"
Packit Service b38f0b
Packit Service b38f0b
if test "$snmp_last_test_result" = 1; then
Packit Service b38f0b
  # test the AgentX subagent by first running it...
Packit Service b38f0b
Packit Service b38f0b
  SNMP_SNMPD_PID_FILE_ORIG=$SNMP_SNMPD_PID_FILE
Packit Service b38f0b
  SNMP_SNMPD_LOG_FILE_ORIG=$SNMP_SNMPD_LOG_FILE
Packit Service b38f0b
  SNMP_SNMPD_PID_FILE=$SNMP_SNMPD_PID_FILE.num2
Packit Service b38f0b
  SNMP_SNMPD_LOG_FILE=$SNMP_SNMPD_LOG_FILE.num2
Packit Service b38f0b
  AGENT_FLAGS="$ORIG_AGENT_FLAGS -X -I example -Dadd"
Packit Service b38f0b
  SNMP_CONFIG_FILE="$SNMP_TMPDIR/bogus.conf"
Packit Service b38f0b
Packit Service b38f0b
  STARTAGENT
Packit Service b38f0b
Packit Service b38f0b
  # test to see that the agent now supports the example mib
Packit Service b38f0b
  CAPTURE "snmpget -On $SNMP_FLAGS -t 5 $AUTHTESTARGS $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.4.1.2021.254.1.0"
Packit Service b38f0b
Packit Service b38f0b
  CHECK "life the universe and everything"
Packit Service b38f0b
Packit Service b38f0b
  if test "$snmp_last_test_result" = 1; then
Packit Service b38f0b
Packit Service b38f0b
    # test to see that the agent now sends a trap from the exmaple mib
Packit Service b38f0b
    CAPTURE "snmpset -On -r 0 -t 3 $SNMP_FLAGS $AUTHTESTARGS $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.4.1.2021.254.8.0 i 1"
Packit Service b38f0b
    DELAY
Packit Service b38f0b
    CHECKTRAPD "life the universe and everything"
Packit Service b38f0b
Packit Service b38f0b
  fi
Packit Service b38f0b
Packit Service b38f0b
  # stop the subagent
Packit Service b38f0b
  STOPAGENT
Packit Service b38f0b
Packit Service b38f0b
  SNMP_SNMPD_PID_FILE=$SNMP_SNMPD_PID_FILE_ORIG
Packit Service b38f0b
  SNMP_SNMPD_LOG_FILE=$SNMP_SNMPD_LOG_FILE_ORIG
Packit Service b38f0b
fi
Packit Service b38f0b
Packit Service b38f0b
# stop the master agent
Packit Service b38f0b
STOPAGENT
Packit Service b38f0b
Packit Service b38f0b
# stop the trap demon
Packit Service b38f0b
STOPTRAPD
Packit Service b38f0b
Packit Service b38f0b
# all done (whew)
Packit Service b38f0b
FINISHED