Hi, is it possible to use monit with configctl?
I have problems with my WAN Interface when my provider is changing the public IP. I have to reboot or disable and enable the WAN interface to get opnsense connected again.
Now I tried to configure monit with configtl and following commands to "restart" the WAN Interface
Start Service: /usr/local/sbin/configctl interface reconfigure vtnet1; /usr/local/sbin/configctl interface linkup start vtnet1
Stop Service: /usr/local/sbin/configctl interface linkup stop vtnet1
When I manually execute the command, the WAN Interface is online again, via monit it does not work. I can see in the log file, that monit ist executing the commands, but nothing happens.
Logfile from monit:
<30>1 2022-04-16T10:48:18+02:00 xx.xx.at monit 58983 - [meta sequenceId="8"] 'wan_check' stop: '/usr/local/sbin/configctl interface linkup stop vtnet1'
<30>1 2022-04-16T10:48:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="9"] 'wan_check' start: '/usr/local/sbin/configctl interface reconfigure vtnet1; /usr/local/sbin/configctl interface linkup start vtnet1'
<28>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="1"] Ping request for 8.8.8.8 1/5 failed -- No route to host
<28>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="2"] Ping request for 8.8.8.8 2/5 failed -- No route to host
<28>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="3"] Ping request for 8.8.8.8 3/5 failed -- No route to host
<28>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="4"] Ping request for 8.8.8.8 4/5 failed -- No route to host
<27>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="5"] Ping request for 8.8.8.8 5/5 failed -- No route to host
<27>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="6"] 'wan_check' ping test failed
<30>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="7"] 'wan_check' trying to restart
<30>1 2022-04-16T10:50:19+02:00 xx.xx.at monit 58983 - [meta sequenceId="8"] 'wan_check' stop: '/usr/local/sbin/configctl interface linkup stop vtnet1'
<30>1 2022-04-16T10:50:20+02:00 xx.xx.at monit 58983 - [meta sequenceId="9"] 'wan_check' start: '/usr/local/sbin/configctl interface reconfigure vtnet1; /usr/local/sbin/configctl interface linkup start vtnet1'
<28>1 2022-04-16T10:52:20+02:00 xx.xx.at monit 58983 - [meta sequenceId="1"] Ping request for 8.8.8.8 1/5 failed -- No route to host
<28>1 2022-04-16T10:52:20+02:00 xx.xx.at monit 58983 - [meta sequenceId="2"] Ping request for 8.8.8.8 2/5 failed -- No route to host
<28>1 2022-04-16T10:52:20+02:00 xx.xx.at monit 58983 - [meta sequenceId="3"] Ping request for 8.8.8.8 3/5 failed -- No route to host
<28>1 2022-04-16T10:52:20+02:00 xx.xx.at monit 58983 - [meta sequenceId="4"] Ping request for 8.8.8.8 4/5 failed -- No route to host
<27>1 2022-04-16T10:52:20+02:00 xx.xx.at monit 58983 - [meta sequenceId="5"] Ping request for 8.8.8.8 5/5 failed -- No route to host
<27>1 2022-04-16T10:52:20+02:00 monit 58983 - [meta sequenceId="6"] 'wan_check' ping test failed
<30>1 2022-04-16T10:52:20+02:00 xx.xx.at monit 58983 - [meta sequenceId="7"] 'wan_check' trying to restart
Is it a permissions or environment problem ?!
I can not provide a solution, just a hint here: I usually use wrapper scripts for monit test and services. It makes debugging much easier and gives you extended logging options...
You might need to run it in a shell, similar to the approach I use for pluginctl here: https://forum.opnsense.org/index.php?topic=18745.msg97953#msg97953
Wrapping the command within a shell was the solution. Thanks
/bin/sh -c '/usr/local/sbin/configctl interface reconfigure vtnet1; /usr/local/sbin/configctl interface linkup start vtnet1'