/bin/sh -c '/usr/local/sbin/pluginctl -s openvpn start 3'
i've found this thread...also i want to restart my opnvpn clients on my opnsense (22.7.9_3)in CLI i can successfully root@OPNsense:~ # ps aux | grep openvpnroot 95966 25.8 0.0 17928 7952 - Ss 12:38 0:16.58 /usr/local/sbin/openvpn --config /var/etc/openvpn/client15.confroot 23564 0.0 0.0 17928 7808 - Ss 12:38 0:00.41 /usr/local/sbin/openvpn --config /var/etc/openvpn/client19.confroot 60688 0.0 0.0 17928 7952 - Ss 12:40 0:00.04 /usr/local/sbin/openvpn --config /var/etc/openvpn/client12.confand also then successfully root@OPNsense:~ # pluginctl -s openvpn start 19Service `openvpn' has been started.root@OPNsense:~ # pluginctl -s openvpn start 15Service `openvpn' has been started.root@OPNsense:~ # pluginctl -s openvpn start 12Service `openvpn' has been started.When i follow your steps, you created a copy of "ping failed" test and changed it to executable, which i did then too..The failed ping test copy i can save successfully, but as soon as i select it in the service settings, i get issues i see this in cli under " cat /usr/local/etc/monitrc""check host OpenVPNClientGateway address 8.8.4.4 if failed ping then alert if failedpingGW then exec /bin/sh -c '/usr/local/sbin/pluginctl -s openvpn start 12'"so basically the ping test and the script are there, but i can't save via webgui as i always get an error.."Error monit /usr/local/etc/monitrc:32: syntax error 'failedpingGW'"can you help me here please?
#!/usr/local/bin/bashclearMONITOR_IP="1.1.1.1"LOG_FILE="/var/log/openvpn-monitor.log"dt=$(date '+%d/%m/%Y %H:%M:%S');echo ${dt}printf "Getting Openvpn interface list...\n\n" | tee -a ${LOG_FILE}INTERFACES=$(ifconfig | awk '/^ovpnc[0-9]+:/ { interface = $1 } /inet / { print interface, $2 }' | grep ovpnc)if [ -z "$INTERFACES" ]; then echo "No running openvpn instances found, exiting" | tee -a ${LOG_FILE} exit 0else echo "Current active openvpn interfaces..." | tee -a ${LOG_FILE} echo "${INTERFACES}" | tee -a ${LOG_FILE} printf "\n\n" | tee -a ${LOG_FILE} echo "Checking connectivity..." | tee -a ${LOG_FILE} grep -oE 'ovpnc[0-9]+: [0-9.]+' <<< "$INTERFACES" | while read -r interface; do INTERFACE_NO=$(echo $interface | awk '{print $1}' | sed 's/[^0-9]*//g') INTERFACE_IP=$(echo $interface | awk '{print $2}') if ping -c2 -S ${INTERFACE_IP} ${MONITOR_IP} >/dev/null 2>&1; then echo "Ping ${MONITOR_IP} via openvpn-${INTERFACE_NO} succeeded" | tee -a ${LOG_FILE} else echo "Ping ${MONITOR_IP} via openvpn-${INTERFACE_NO} Failed" | tee -a ${LOG_FILE} echo "Restarting openvpn interface ${INTERFACE_NO}" | tee -a ${LOG_FILE} /usr/local/sbin/pluginctl -s openvpn start ${INTERFACE_NO} fi donefiecho "--------------------------------------------" | tee -a ${LOG_FILE}
[start]command:/usr/local/sbin/openvpn-monitor.shparameters:type:scriptmessage:OpenVPN Monitordescription:OpenVPN Monitor