diff --git a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd index 2d6335b..d1e3c33 100755 --- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd +++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmpd @@ -60,7 +60,15 @@ TRAPDOPTS="-Lsd -p $TRAPD_PID" test -x $SNMPD_BINARY || exit 0 test -x $TRAPD_BINARY || exit 0 +create_ns_if_not_exists() { + [ -n "$1" ] || return 0 + exists=`$IP_BINARY netns | egrep "^$1\$" | wc -l` + [ $exists -le 0 ] || return 0 + $IP_BINARY netns add "$1" +} + if [ "x$SNMPDNS" != "x" ]; then + create_ns_if_not_exists "$SNMPDNS" SNMPDOPTS="netns exec $SNMPDNS $SNMPD_BINARY $SNMPDOPTS" SNMPDEXEC=$IP_BINARY else @@ -68,6 +76,7 @@ else fi if [ "x$TRAPDNS" != "x" ]; then + create_ns_if_not_exists "$TRAPDNS" TRAPDOPTS="netns exec $TRAPDNS $TRAPD_BINARY $TRAPDOPTS" TRAPDEXEC=$IP_BINARY else diff --git a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd index afb9369..1e3917d 100755 --- a/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd +++ b/deployment_scripts/puppet/modules/plugin_zabbix_snmptrapd/files/initscripts/snmptrapd @@ -54,6 +54,12 @@ pidfile=/var/run/snmptrapd.pid if [ "x$NS" != "x" ]; then cmd="/sbin/ip netns exec $NS $binary" + exists=`$IP_BINARY netns | egrep "^$1\$" | wc -l` + if [ $exists -le 0 ]; then + /sbin/ip netns add $NS + fi +} + else cmd=$binary fi