network check does not allow "program" configs
The manual example on network is:
check network eth0 with interface eth0
start program = '/sbin/ipup eth0'
stop program = '/sbin/ipdown eth0'
if failed link then restart
as soon as I add a "* program" entry monit does not startup with
$ ./monit -c monitrc
[...]/monitrc:10: syntax error '='
monitrc
is as simple as
set daemon 60
set log syslog
set httpd port 2812 and
use address localhost
allow localhost
allow admin:monit
check network net-test with interface eth0
start program = '/usr/bin/touch /tmp/start-eth0'
stop program = '/usr/bin/touch /tmp/stop-eth0'
I tested it with the latest git (pasted outputs are from this version @ 5.25.3, cloned 2018-09-09 15:00), on arch-linux (community package @ 5.25.2-1), and the current debian/testing version (default repo @ 5.25.2)
After some more testing I found out the following:
Omitting the spaces or the keyword "program =" makes monit to start up with errors:
check network net-test with interface eth0
start program='/usr/bin/touch /tmp/start-eth0'
stop '/usr/bin/touch /tmp/stop-eth0'
This shows:
$ ./monit -c monitrc
/home/boppy/Code/monit-src/monit-dev/monitrc:10: Program does not exist: 'program='
/home/boppy/Code/monit-src/monit-dev/monitrc:11: Program does not exist: ''/usr/bin/touch /tmp/stop-eth0''
Starting Monit 5.25.3 daemon with http interface at [localhost]:2812
Web Frontend states:
Then I shortened my program call to a script without a space in its name (it's still just a touch
on a tmp-file):
check network net-test with interface eth0
start /home/boppy/Code/monit-src/test.sh
This will "do the trick" and will also work from the web frontend button! But the syntax might need some improvements... ;)
PS: git version is 5.25.3, but this version is not (yet) present in the Version dropdown.
Comments (4)
-
-
reporter This problem does not persist to other types; it's with network only. For processes everything is working fine.
-
Ok now I understand.
Program does not exist: 'program
Just to be sure, did you try the double quotes around the commands ?
In some circumstances I found monit a little picky about the syntax, while parsing the definitions...
-
reporter - changed status to resolved
Oh dear, you got me! I totally owe you a beer! ;)
It really is the double quotes.
PS: After checking all my configs, that in fact was the only place I used single quotes.
- Log in to comment
With monit 5.25.2 we can use, for example
check process folium with pidfile /var/run/folium.pid start program = "/etc/init.d/folium start" stop program = "/etc/init.d/folium stop"
Did you try the double quotes ?
p.s.: I am just a monit user