Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monit failing to start process

I have a simple script that I'm trying to get Monit to monitor. After some digging around I found this little nugget: start program = "su - myuser -c '/home/user/myscript.rb start' " which I believe should work but looking at the log files it says:

[PDT Oct 30 02:47:17] info     : 'simple_script' start: su
[PDT Oct 30 02:47:17] error    : Error: Could not execute su

Likewise earlier attempts only seem to read the part preceding a space so:

start program = "/home/user/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /home/user/simple_script_daemon.rb stop"

results in…

[PDT Oct 30 03:09:49] info     : 'simple_script' start: /home/user/.rvm/rubies/ruby-1.9.2-p290/bin/ruby

Which doesn't fail like the first example but still seems to only execute the part preceding the space.

This is my full statement:

check process simple_script
    with pidfile /home/user/simple_script.rb.pid
    start program = "su - user -c '/home/user/simple_script_daemon.rb start' "
    stop program = "su - user -c '/home/user/simple_script_daemon.rb stop' "
    group simple_script

If you've got an idea what might be going on I'd love to hear from you!

like image 200
fetimo Avatar asked Oct 30 '11 10:10

fetimo


People also ask

How do I start monit service?

Step 1: Installing Monit in Linux By default, the Monit monitoring program is not available from the default system base repositories, you need to add and enable a third-party epel repository to install the monit package under RHEL-based distributions such as CentOS, Rocky Linux, and AlmaLinux.

How do I check my monit status?

You can obtain the status of the PSM and other important services via the monit web interface at http:// <server ip address>:2812 or on the command line.

What is monit in Linux?

Monit is a free, open-source process supervision tool for Unix and Linux. With Monit, system status can be viewed directly from the command line, or via the native HTTP(S) web server. Monit is able to do automatic maintenance, repair, and run meaningful causal actions in error situations.


2 Answers

I guess you could try something like:

check process simple_script
    with pidfile /home/user/simple_script.rb.pid
    start program = "/home/user/simple_script_daemon.rb start" as uid user and gid user
    stop program = "/home/user/simple_script_daemon.rb stop" as uid user and gid user
    group simple_script

as stated in monit doc.

like image 109
brisssou Avatar answered Sep 22 '22 00:09

brisssou


You may need to provide full path to su, i.e. /bin/su

like image 32
Michał Szajbe Avatar answered Sep 25 '22 00:09

Michał Szajbe