SNMP tests: Don't start snmpd, check if the system have snmpd started otherwise present instructions for how to configure and start it.
This commit is contained in:
parent
c9eae77d61
commit
ee06652e86
3 changed files with 30 additions and 47 deletions
21
test/lib.sh
21
test/lib.sh
|
|
@ -206,6 +206,27 @@ if [ ! -z ${YANG_STANDARD_DIR} ]; then
|
||||||
: ${IETFRFC=$YANG_STANDARD_DIR/ietf/RFC}
|
: ${IETFRFC=$YANG_STANDARD_DIR/ietf/RFC}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
: ${SNMPCHECK:=true}
|
||||||
|
|
||||||
|
if $SNMPCHECK; then
|
||||||
|
if [ "${WITH_NETSNMP}" == "yes" ]; then
|
||||||
|
if [ ! -f /var/run/snmpd.pid ]; then
|
||||||
|
echo -e "\e[31m\nenable-netsnmp set but snmpd not running, start with:"
|
||||||
|
echo "systemctl start snmpd"
|
||||||
|
echo ""
|
||||||
|
echo "snmpd must be configured to use a Unix socket for agent communication"
|
||||||
|
echo "and have a rwcommunity configured, make sure the following lines are"
|
||||||
|
echo "added to /etc/snmp/snmpd.conf:"
|
||||||
|
echo ""
|
||||||
|
echo " rwcommunity public localhost"
|
||||||
|
echo " agentXSocket unix:/var/run/snmp.sock"
|
||||||
|
echo " agentxperms 777 777"
|
||||||
|
echo -e "\e[0m"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check sanity between --with-restconf setting and if nginx is started by systemd or not
|
# Check sanity between --with-restconf setting and if nginx is started by systemd or not
|
||||||
# This check is optional because some installs, such as vagrant make a non-systemd/direct
|
# This check is optional because some installs, such as vagrant make a non-systemd/direct
|
||||||
# start
|
# start
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ if [ ${WITH_NETSNMP} != "yes" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
snmpd=$(type -p snmpd)
|
snmpd=$(type -p snmpd)
|
||||||
snmpget="$(type -p snmpget) -On -c public -v2c localhost:1161 "
|
snmpget="$(type -p snmpget) -On -c public -v2c localhost "
|
||||||
snmpset="$(type -p snmpset) -On -c public -v2c localhost:1161 "
|
snmpset="$(type -p snmpset) -On -c public -v2c localhost "
|
||||||
|
|
||||||
cfg=$dir/conf_startup.xml
|
cfg=$dir/conf_startup.xml
|
||||||
fyang=$dir/clixon-example.yang
|
fyang=$dir/clixon-example.yang
|
||||||
|
|
||||||
# AgentX unix socket
|
# AgentX unix socket
|
||||||
SOCK=/tmp/clixon_snmp.sock
|
SOCK=/var/run/snmp.sock
|
||||||
|
|
||||||
cat <<EOF > $cfg
|
cat <<EOF > $cfg
|
||||||
<clixon-config xmlns="http://clicon.org/config">
|
<clixon-config xmlns="http://clicon.org/config">
|
||||||
|
|
@ -46,24 +46,6 @@ module clixon-example{
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
function testinit(){
|
function testinit(){
|
||||||
# Kill old snmp daemon and start a new ones
|
|
||||||
new "kill old snmp daemons"
|
|
||||||
sudo killall snmpd
|
|
||||||
|
|
||||||
new "Starting $snmpd -C --rwcommunity=public --master=agentx --agentXSocket=unix:/tmp/clixon_snmp.sock udp:127.0.0.1:1161"
|
|
||||||
|
|
||||||
# Dirty workaround for snmpd in Alpine
|
|
||||||
if [ -f /.dockerenv ]; then
|
|
||||||
$snmpd -C --rwcommunity=public --master=agentx --agentXSocket=unix:$SOCK udp:127.0.0.1:1161
|
|
||||||
else
|
|
||||||
$snmpd --rwcommunity=public --master=agentx --agentXSocket=unix:$SOCK udp:127.0.0.1:1161
|
|
||||||
fi
|
|
||||||
|
|
||||||
pgrep snmpd
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
err "Failed to start snmpd"
|
|
||||||
fi
|
|
||||||
|
|
||||||
new "test params: -f $cfg"
|
new "test params: -f $cfg"
|
||||||
# Kill old backend and start a new one
|
# Kill old backend and start a new one
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
|
|
@ -89,8 +71,7 @@ function testinit(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function testexit(){
|
function testexit(){
|
||||||
sudo killall snmpd
|
sudo killall clixon_snmp
|
||||||
stop_snmp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new "SNMP tests"
|
new "SNMP tests"
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,15 @@ if [ ${WITH_NETSNMP} != "yes" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
snmpd=$(type -p snmpd)
|
snmpd=$(type -p snmpd)
|
||||||
snmpget="$(type -p snmpget) -On -c public -v2c localhost:1161 "
|
snmpget="$(type -p snmpget) -On -c public -v2c localhost:161 "
|
||||||
snmpset="$(type -p snmpset) -On -c public -v2c localhost:1161 "
|
snmpset="$(type -p snmpset) -On -c public -v2c localhost:161 "
|
||||||
snmptable="$(type -p snmptable) -c public -v2c localhost:1161 "
|
snmptable="$(type -p snmptable) -c public -v2c localhost:161 "
|
||||||
|
|
||||||
cfg=$dir/conf_startup.xml
|
cfg=$dir/conf_startup.xml
|
||||||
fyang=$dir/clixon-example.yang
|
fyang=$dir/clixon-example.yang
|
||||||
|
|
||||||
# AgentX unix socket
|
# AgentX unix socket
|
||||||
SOCK=/tmp/clixon_snmp.sock
|
SOCK=/var/run/snmp.sock
|
||||||
|
|
||||||
# OID
|
# OID
|
||||||
# .netSnmpExampleTables.netSnmpIETFWGTable
|
# .netSnmpExampleTables.netSnmpIETFWGTable
|
||||||
|
|
@ -56,24 +56,6 @@ module clixon-example{
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
function testinit(){
|
function testinit(){
|
||||||
# Kill old snmp daemon and start a new ones
|
|
||||||
new "kill old snmp daemons"
|
|
||||||
sudo killall snmpd
|
|
||||||
|
|
||||||
new "Starting $snmpd --rwcommunity=public --master=agentx --agentXSocket=unix:/tmp/clixon_snmp.sock udp:127.0.0.1:1161"
|
|
||||||
|
|
||||||
# Dirty workaround for snmpd in Alpine
|
|
||||||
if [ -f /.dockerenv ]; then
|
|
||||||
$snmpd -C --rwcommunity=public --master=agentx --agentXSocket=unix:$SOCK udp:127.0.0.1:1161
|
|
||||||
else
|
|
||||||
$snmpd --rwcommunity=public --master=agentx --agentXSocket=unix:$SOCK udp:127.0.0.1:1161
|
|
||||||
fi
|
|
||||||
|
|
||||||
pgrep snmpd
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
err "Failed to start snmpd"
|
|
||||||
fi
|
|
||||||
|
|
||||||
new "test params: -f $cfg"
|
new "test params: -f $cfg"
|
||||||
# Kill old backend and start a new one
|
# Kill old backend and start a new one
|
||||||
new "kill old backend"
|
new "kill old backend"
|
||||||
|
|
@ -99,8 +81,7 @@ function testinit(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function testexit(){
|
function testexit(){
|
||||||
sudo killall snmpd
|
sudo killall clixon_snmp
|
||||||
stop_snmp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new "SNMP table tests"
|
new "SNMP table tests"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue