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:
Kristofer Hallin 2022-05-03 03:06:50 -07:00 committed by Olof hagsand
parent 1c55ed05f2
commit 80651503fd
3 changed files with 30 additions and 47 deletions

View file

@ -13,15 +13,15 @@ if [ ${WITH_NETSNMP} != "yes" ]; then
fi
snmpd=$(type -p snmpd)
snmpget="$(type -p snmpget) -On -c public -v2c localhost:1161 "
snmpset="$(type -p snmpset) -On -c public -v2c localhost:1161 "
snmptable="$(type -p snmptable) -c public -v2c localhost:1161 "
snmpget="$(type -p snmpget) -On -c public -v2c localhost:161 "
snmpset="$(type -p snmpset) -On -c public -v2c localhost:161 "
snmptable="$(type -p snmptable) -c public -v2c localhost:161 "
cfg=$dir/conf_startup.xml
fyang=$dir/clixon-example.yang
# AgentX unix socket
SOCK=/tmp/clixon_snmp.sock
SOCK=/var/run/snmp.sock
# OID
# .netSnmpExampleTables.netSnmpIETFWGTable
@ -56,24 +56,6 @@ module clixon-example{
EOF
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"
# Kill old backend and start a new one
new "kill old backend"
@ -99,8 +81,7 @@ function testinit(){
}
function testexit(){
sudo killall snmpd
stop_snmp
sudo killall clixon_snmp
}
new "SNMP table tests"