monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [monit] Re: File check with execution of a script


From: Martin Pala
Subject: Re: [monit] Re: File check with execution of a script
Date: Sat, 27 Sep 2008 18:26:46 +0200

Hi,

when the service is to be restarted and depends on some other service, monit tries to make sure that the parent service is running. The problem is, that monit doesn't use it's own parent service check result, but tries to verify that the parent service is OK directly during the restart ... and this "real-time" check is very limited:

1.) if the parent service is process, it checks that the process is running (independent of process service check result) ... if it's not running, monit tries to start it before the child service is started and then starts the child service. If the parent process is running already, monit just tries to start he child service directly.

2.) if the parent service is any other type (file, directory, filesystem, ...) then monit doesn't verify whether it is running or not and just calls the start method of the parent service (which may cascade if the dependency chain is longer as in your case).


In your case there is dependency chain of three file services defined as MNT -> MNTDEP -> MNTDEPDEP, whereas MNTDEPDEP+MNTDEP (grandparent + parent) exists, MNT (child) doesn't exist.

The monit verbose mode (-v option) shows the actions sequence:

--8<--
bash# monit -vIc ../monit_files validate
...
'MNTDEPDEP' file existence check succeeded
'MNTDEPDEP' is a regular file
'MNTDEP' file existence check succeeded
'MNTDEP' is a regular file
'MNT' file doesn't exist
'MNT' trying to restart
Monitoring disabled -- service MNT
'MNT' stop: /etc/monit/monit.sh
'MNTDEPDEP' start: /etc/monit/monit_dep_dep.sh
'MNTDEP' start: /etc/monit/monit_dep.sh
'MNT' start: /etc/monit/monit.sh
Monitoring enabled -- service MNT
--8<--


=> the behavior is given by current monit limitation. We plan to improve the dependency behavior and use the result of the full service check in the action chain, which will solve your problem.

The workaround could be to modify your scripts this way ... for example monit_dep.sh:
--8<--
#!/bin/bash

#
# WORKAROUND FOR MONIT DEPENDENCY ACTION CHAIN
#
if test -f /etc/monit/monit_dep.txt; then exit 0; fi

case $1 in
    start)
            touch /etc/monit/monit_dep.txt
            echo "asdfasdfasdfasdf" > /etc/monit/monit_dep.txt
            echo "monit start" >> /etc/monit/hier.txt
            ;;
    stop)
            echo "monit stop" >> /etc/monit/hier.txt
            ;;
esac
--8<--



Thanks,
Martin



On Sep 25, 2008, at 4:00 PM, Julian Thomé wrote:

Sorry, i made an error in the last email

the files monit_dep_dep.txt and monit_dep.txt exist and the file monit.txt doesnt exist.

Julian Thomé


                
___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http:// messenger.yahoo.de



--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general





reply via email to

[Prev in Thread] Current Thread [Next in Thread]