| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
. ../support/simple_eval_tools.sh |
| 4 |
|
| 5 |
# snmpnetstat test only works with UDP or TCP |
| 6 |
if [ "x$SNMP_TRANSPORT_SPEC" = "x" -o "x$SNMP_TRANSPORT_SPEC" = "xudp" ]; then |
| 7 |
proto=udp |
| 8 |
HEADER "if snmpnetstat finds the running agent in udpTable" |
| 9 |
SKIPIFNOT USING_MIBII_UDPTABLE_MODULE |
| 10 |
elif [ "x$SNMP_TRANSPORT_SPEC" = "xtcp" ]; then |
| 11 |
proto=tcp |
| 12 |
HEADER "if snmpnetstat finds the running agent in tcpTable" |
| 13 |
SKIPIFNOT USING_MIBII_TCPTABLE_MODULE |
| 14 |
else |
| 15 |
HEADER "if snmpnetstat finds the running agent in udpTable/tcpTable" |
| 16 |
SKIP Not using TCP or UDP transport |
| 17 |
fi |
| 18 |
|
| 19 |
# on some systems the agent needs to be run as root to access udpTable/tcpTable |
| 20 |
# - else force skip |
| 21 |
case "x`uname -s`" in |
| 22 |
xAIX) [ "x`id -u`" != "x0" ] && SKIP Not running as root;; |
| 23 |
xHP-UX) [ "x`id -u`" != "x0" ] && SKIP Not running as root;; |
| 24 |
xIRIX*) [ "x`id -u`" != "x0" ] && SKIP Not running as root;; |
| 25 |
xNetBSD) [ "x`id -u`" != "x0" ] && SKIP Not running as root;; |
| 26 |
xOpenBSD) [ "x`id -u`" != "x0" ] && SKIP Not running as root;; |
| 27 |
xOSF1) [ "x`id -u`" != "x0" ] && SKIP Not running as root;; |
| 28 |
esac |
| 29 |
|
| 30 |
SKIPIF NETSNMP_DISABLE_SNMPV2C |
| 31 |
|
| 32 |
# make sure snmpnetstat can be executed |
| 33 |
SNMPNETSTAT="${SNMP_UPDIR}/apps/snmpnetstat/snmpnetstat" |
| 34 |
[ -x "$SNMPNETSTAT" ] || SKIP snmpnetstat not compiled |
| 35 |
|
| 36 |
snmp_version=v2c |
| 37 |
. ./Sv2cconfig |
| 38 |
|
| 39 |
# |
| 40 |
# Begin test |
| 41 |
# |
| 42 |
|
| 43 |
STARTAGENT |
| 44 |
|
| 45 |
CAPTURE "$SNMPNETSTAT -Cn -Cp $proto -$snmp_version -c testcommunity $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT" |
| 46 |
CHECKEXACT "127.0.0.1.$SNMP_SNMPD_PORT" |
| 47 |
# multiple occurrences (especially in tcpTable) are fine |
| 48 |
if [ "$snmp_last_test_result" != 0 ] ; then |
| 49 |
return_value=0 |
| 50 |
else |
| 51 |
return_value=1 |
| 52 |
fi |
| 53 |
|
| 54 |
STOPAGENT |
| 55 |
FINISHED |