Having monit print the output of a process when starting

Issue #1017 new
Alexis Fischer created an issue

I’ve been looking for a way to print the output of a process when starting it with :

sudo monit start process

I have multiple custom services that give the following output when started from /etc/init.d/ :

Service starting... 
Service started.

Is it possible to have the same behavior when started with monit ?

Comments (1)

  1. Lutz Mader

    Hello Alexis,
    similar information are available in the syslog or log file written by monit.

    For example you will find something like this.

    [2021-11-30T18:01:17MEZ] info     : 'Postgres' stop on user request
    [2021-11-30T18:01:17MEZ] info     : Monit daemon with PID 34603282 awakened
    [2021-11-30T18:01:17MEZ] info     : Awakened by User defined signal 1
    [2021-11-30T18:01:17MEZ] info     : 'Postgres' stop: '/usr/local/etc/monit/scripts/post.sh stop'
    [2021-11-30T18:01:27MEZ] info     : 'Postgres' stop action done
    [2021-11-30T18:01:58MEZ] info     : 'Postgres' start on user request
    [2021-11-30T18:01:58MEZ] info     : Monit daemon with PID 34603282 awakened
    [2021-11-30T18:01:58MEZ] info     : Awakened by User defined signal 1
    [2021-11-30T18:01:58MEZ] info     : 'Postgres' start: '/usr/local/etc/monit/scripts/post.sh start'
    [2021-11-30T18:02:03MEZ] info     : 'Postgres' start action done
    

    The line command interface is very asynchronous, monit send command requests to the monit daemon process only and does not wait for the response, for commands like start, stop or restart. This is not very useful (I think), because these commands spend a lot of time sometimes. And it is not very useful to get a message from the backgroud after some minutes or to wait until the command finished, in my opinion.

    But this depends on my way how to use monit, the information you are interresting in are available.

    With regards,
    Lutz

  2. Log in to comment