I have done a patch that make mini_snmpd more uci style +Instead of one option with comma separated interfaces now use uci list +Intestad of use only real interface name now can use also uci interface name the init script check if the interface name specified is from uci than traslate it to real name interface if not check if the interface exist then add it if not exist print an error message and ignore the interface
suggestion are welcomed ;) On Friday 14 October 2011 11:04:20 you wrote: > Hey all! > > I see that in mini_snmpd config you have to use a list of real name > interfaces comma separated, that not the uci style... > > I am thinking to write a patch to use uci list instead of option and more > over you can use uci network name also instead of real name interface only > > What do you thinks about that ?
Index: net/mini_snmpd/files/mini_snmpd.init =================================================================== --- net/mini_snmpd/files/mini_snmpd.init (revision 28448) +++ net/mini_snmpd/files/mini_snmpd.init (working copy) @@ -5,7 +5,8 @@ PROG=/usr/bin/$NAME START=50 -append_string() { +append_string() +{ local section="$1" local option="$2" local value="$3" @@ -14,7 +15,8 @@ [ -n "$_val" ] && append args "$3 $_val" } -mini_snmpd_config() { +mini_snmpd_config() +{ local cfg="$1" args="" @@ -22,8 +24,24 @@ append_string "$cfg" location "-L" append_string "$cfg" contact "-C" append_string "$cfg" disks "-d" + + + local confInterfaces; config_get confInterfaces "$cfg" "interfaces" + local interfaces + + for interface in $confInterfaces + do + ifname=$(uci -P /var/state get network.$interface.ifname 2>&-) + [ ! "void$ifname" = "void" ] && interfaces="$interfaces,$ifname" && continue + [ -d "/sys/class/net/$interface" ] && interfaces="$interfaces,$interface" && continue + + echo "Can't add interface $interface - ignoring" + done + + interfaces=$(echo $interfaces | sed 's/^[,\t]*//;s/[,\t]*$//') append_string "$cfg" interfaces "-i" + config_get_bool ipv6 "$cfg" "ipv6" '0' [ "$ipv6" -gt 0 ] && append args "-6" @@ -31,11 +49,13 @@ [ "$enabled" -gt 0 ] && $PROG $args & } -start() { +start() +{ config_load mini_snmpd config_foreach mini_snmpd_config mini_snmpd } -stop() { +stop() +{ killall mini_snmpd } Index: net/mini_snmpd/files/mini_snmpd.config =================================================================== --- net/mini_snmpd/files/mini_snmpd.config (revision 28448) +++ net/mini_snmpd/files/mini_snmpd.config (working copy) @@ -1,8 +1,14 @@ config mini_snmpd - option enabled 1 - option ipv6 0 - option community public - option location '' - option contact '' - option disks '/tmp,/jffs' - option interfaces 'lo,br-lan,eth0.1,eth1' # Max 4 + option enabled 1 + option ipv6 1 + option community public + option location '' + option contact '' + option disks '/tmp,/jffs' + list interfaces 'loopback' + list interfaces 'lan' + list interfaces 'wan' + +## REMOVEME: On the wiki [0] is reported Max 4 interfaces +## REMOVEME: Maybe a mini_snmpd code limitation... +## REMOVEME: [0] http://wiki.openwrt.org/doc/uci/mini_snmpd
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel