I figured out where the issues are in the procd implementation and expanded it to include most of the softflowctl functionality. It’s been running tickety-boo feeding PRTG for a couple of months now. I’m trying to figure out how to issue a PR ATM, but if you want to give it a test, I can post my script and config.
Put this into /etc/init.d/softflowd
#! /bin/sh /etc/rc.common
# Copyright (C) 2007-2011 OpenWrt.org/Copyright (C) 2020 RuralRoots
USE_PROCD=1
START=50
Run_Dir="/var/run/softflowd"
Ctl_Dir="/usr/sbin/softflowctl"
EXTRA_COMMANDS="statistics dump pause resume expire delete timeouts active shutdown update"
EXTRA_HELP="
SOFTFLOWCTL COMMANDS
Syntax: /etc/init.d/sflow <Command> Control File Name
statistics -> Show Interface Statistics
dump -> Dump Interface Flows
pause -> Pause Interface Flow Monitoring
resume -> Resume Interface Flow Monitoring
expire -> Expire Interface Flows
delete -> Delete All Interface Flows
timeouts -> Show Interface Timeout Settings
active -> Show All Active Interfaces
shutdown -> Exit Gracefully & close softflowd
update -> Enable/Disable An Interface & Restart softflowd Monitoring"
append_bool() {
local section="$1"
local option="$2"
local value="$3"
local _val
config_get_bool _val "$section" "$option" '0'
[ "$_val" -gt 0 ] && append args "$3"
}
append_string() {
local section="$1"
local option="$2"
local value="$3"
local _val
config_get _val "$section" "$option"
[ -n "$_val" ] && append args "$3 $_val"
}
run_cmd(){
echo "" && echo " $msg " && echo ""
$Ctl_Dir -c $Run_Dir/$iface.ctl $command
}
start_instance() {
local section="$1"
config_get_bool enabled "$section" 'enabled' '0'
[ "$enabled" -gt 0 ] || return 1
args=""
append args "-c /var/run/softflowd/$section.ctl"
append_string "$section" 'interface' '-i'
append_string "$section" 'pcap_file' '-r'
append_string "$section" 'timeout1' '-t'
append_string "$section" 'timeout2' '-t'
append_string "$section" 'timeout3' '-t'
append_string "$section" 'timeout4' '-t'
append_string "$section" 'timeout5' '-t'
append_string "$section" 'timeout6' '-t'
append_string "$section" 'timeout7' '-t'
append_string "$section" 'timeout8' '-t'
append_string "$section" 'max_flows' '-m'
append_string "$section" 'host_port' '-n'
append_string "$section" 'export_version' '-v'
append_string "$section" 'hoplimit' '-L'
append_string "$section" 'tracking_level' '-T'
append_string "$section" 'sampling_rate' '-s'
append_bool "$section" track_ipv6 '-6'
procd_open_instance
procd_set_param command /usr/sbin/softflowd -d $args
procd_set_param respawn
procd_close_instance
}
start_service() {
mkdir -p /var/run/softflowd
config_load 'softflowd'
config_foreach start_instance
}
statistics(){
command="statistics" && iface=$1 && msg="Showing $iface Statistics" && run_cmd
}
dump(){
command="dump-flows" && iface=$1 && msg="Dumping $iface Flows" && run_cmd
}
pause(){
command="stop-gather" && iface=$1 && msg="Pausing $iface Flow Monitoring" && run_cmd
}
resume(){
command="start-gather" && iface=$1 && msg="Resuming $iface Flow Monitoring" && run_cmd
}
expire(){
command="expire-all" && iface=$1 && msg="Expiring All $iface Flows" && run_cmd
}
delete(){
command="delete-all" && iface=$1 && msg="Immediately Deleting All $iface Flows" && run_cmd
}
timeouts(){
command="timeouts" && iface=$1 && msg="Showing Current $iface Timeout Values" && run_cmd
}
active(){
echo "" && echo " Showing All Active Control Sockets: " && echo ""
ls $Run_Dir 2> /dev/null
}
shutdown(){
echo "" && echo " Shutting Down All Instances" && echo ""
config_load softflowd
config_foreach cleanup
/etc/init.d/softflowd stop
echo "" && echo " Cleaning Up Run Environment" && echo "" && echo "" echo ""
rm -r $Run_Dir 2> /dev/null
echo "" && echo " D O N E" && echo "" && echo "" && echo " . . . . Goodbye" && echo ""
}
cleanup() {
$Ctl_Dir -c $Run_Dir/$1.ctl shutdown 2> /dev/null
}
update(){
local socket=$1
local updown=$2
shutdown
uci set softflowd.$socket.enabled=$updown
echo " Restarting softflowd With Updated Configuration"
/etc/init.d/softflowd start
}
Put this into /etc/config/softflowd
config ctlsock lan # Control Socket File Name
option enabled '1' # Interface enabled=1/disabled=0
option interface 'br-lan' # Interface to be monitored
option pcap_file '' # Read/process/exit pcap packet capture file
option timeout1 'expint=90s' # # # # # # # # # # # # # # #
option timeout2 'udp=600s' # Flow timeout override values
option timeout3 '' # # # # # Valid entries with Defaults:
option timeout4 '' # expint=60s udp=300s
option timeout5 '' # tcp=3600s tcp.rst=120s
option timeout6 '' # tcp.fin=300s icmp=300s
option timeout7 '' # general=3600s maxlife=604800s
option timeout8 '' # # # # # # # # # # # # # # #
option max_flows '8192'
option host_port '10.10.1.100:5555' # Collector IP:Port
option export_version '9' # NetFlow export version 1/5/9
option hoplimit ''
option tracking_level 'full'
option track_ipv6 '1' # Track ipv6 regardless enabled=1
option sampling_rate '100'
config ctlsock vpn0
option enabled '1'
option interface 'vpn0'
option pcap_file ''
option timeout1 ''
option timeout2 ''
option timeout3 ''
option timeout4 ''
option timeout5 ''
option timeout6 ''
option timeout7 ''
option timeout8 ''
option max_flows '8192'
option host_port '10.10.1.100:5556'
option export_version '9'
option hoplimit ''
option tracking_level 'full'
option track_ipv6 '1'
option sampling_rate '100'
Make /etc/config/softflowd changes for your setup - interface and host_port at least.
Startup softflowd: /etc/init.d/softflowd start
enter /etc/init.d/softflowd to see a command list.
enter ps -A | grep softflowd to see what configured softflowd instances are running.