749 |
|
|
750 |
If specified in the control file, monit can do dependency |
If specified in the control file, monit can do dependency |
751 |
checking before starting or stopping processes. The syntax for |
checking before starting or stopping processes. The syntax for |
752 |
the depend statement is simply: |
the depends statement is simply: |
753 |
|
|
754 |
DEPEND [process]+ |
DEPENDS [process]+ |
755 |
|
|
756 |
Where B<process> is a process entry name, for instance B<apache>. |
Where B<process> is a process entry name, for instance B<apache>. |
757 |
You may add more than one process name in a depend statement. |
You may add more than one process name in a depends statement. |
758 |
See also the example section below. |
|
759 |
|
Processes specified in a I<depends> statement will be checked |
760 |
|
during stop/start operations. If a process is stopped it will |
761 |
|
first stop any processes that depends on itself. Likewise, if a |
762 |
|
process is started, it will first stop the dependant processes, |
763 |
|
start the process, and then start the dependant processes again. |
764 |
|
|
765 |
|
Consider the following common server setup: |
766 |
|
|
767 |
|
(a) WEB-SERVER -> (b) APPLICATION-SERVER -> (c) DATABASE |
768 |
|
|
769 |
|
You can set dependencies so that the web-server depends on the |
770 |
|
application server to run before the web-server starts and the |
771 |
|
application server depends on the database server to run before |
772 |
|
it starts. See the example section below for the configuration |
773 |
|
statements used for such a setup. |
774 |
|
|
775 |
|
Here are some situations to describe how the dependencies above |
776 |
|
will work with monit: |
777 |
|
|
778 |
|
=over 4 |
779 |
|
|
780 |
|
=item If no servers are running |
781 |
|
|
782 |
|
monit will start the servers in the following order: I<c>, I<b>, |
783 |
|
I<a> |
784 |
|
|
785 |
|
=item If all servers are running |
786 |
|
|
787 |
|
When you run 'monit stop' this is the stop order: I<a>, I<b>, |
788 |
|
I<c> |
789 |
|
|
790 |
|
=item If I<a> does not run |
791 |
|
|
792 |
|
When monit runs it will start I<a> |
793 |
|
|
794 |
|
=item If I<b> does not run |
795 |
|
|
796 |
|
When monit runs it will first stop I<a> then start I<b> and |
797 |
|
finally start I<a> again. |
798 |
|
|
799 |
|
=item If I<c> does not run |
800 |
|
|
801 |
|
When monit runs it will first stop I<a> and I<b> then start I<c> |
802 |
|
and finally start I<b> then I<a>. |
803 |
|
|
804 |
|
|
805 |
|
=item If monitrc contains a dependency loop |
806 |
|
|
807 |
|
A dependency loop is for example; a->b and b->a or a->b->c->a. |
808 |
|
|
809 |
|
When monit starts it will check for any such loops and complain |
810 |
|
and exit if a depend loop is found. It will also exit with a |
811 |
|
complaint if a depend statement was used that does not point to |
812 |
|
any processes in the controlfile. |
813 |
|
|
814 |
|
=back |
815 |
|
|
|
Processes specified in a I<depend> statement will be checked |
|
|
during stop/start operations. When a process is stopped it will |
|
|
first stop the dependant processes. Likewise, if a process is |
|
|
started, it will first stop the dependant processes, start the |
|
|
process, and then start the dependant processes. |
|
816 |
|
|
817 |
=head1 MONIT HTTPD |
=head1 MONIT HTTPD |
818 |
|
|
1241 |
system load average over a number of cylces. If |
system load average over a number of cylces. If |
1242 |
the compare expression matches then the action |
the compare expression matches then the action |
1243 |
start, alert or stop is avtivated. |
start, alert or stop is avtivated. |
1244 |
depend Must be followed by the name of a process that depends |
|
1245 |
on the process given in the check field. This process |
depends (on) Must be followed by the name of a process this |
1246 |
will be stopped/started before/after the current |
process depends on to run before it starts. The |
1247 |
process. |
depending process will be stopped before the |
1248 |
|
current process is started and started again |
1249 |
|
after. |
1250 |
|
|
1251 |
Here's the complete list of reserved B<keywords> used by monit: |
Here's the complete list of reserved B<keywords> used by monit: |
1252 |
|
|
1256 |
I<port(number)>, I<unix(socket)>, I<type>, I<proto(col)>, I<tcp>, |
I<port(number)>, I<unix(socket)>, I<type>, I<proto(col)>, I<tcp>, |
1257 |
I<tcpssl>, I<udp>, I<alert>, I<mail-format>, I<restart>, |
I<tcpssl>, I<udp>, I<alert>, I<mail-format>, I<restart>, |
1258 |
I<timeout>, I<checksum>, I<resource>, I<expect>, I<mailserver>, |
I<timeout>, I<checksum>, I<resource>, I<expect>, I<mailserver>, |
1259 |
I<every>, I<mode>, I<active>, I<passive>, I<manual>, I<host>, |
I<every>, I<mode>, I<active>, I<passive>, I<manual>, I<depends>, |
1260 |
I<default>, I<http>, I<ftp>, I<smtp>, I<pop>, I<nntp>, I<imap>, |
I<host>, I<default>, I<http>, I<ftp>, I<smtp>, I<pop>, I<nntp>, |
1261 |
I<ssh>, I<request>, I<cpuusage>, I<memusage>, I<memkbyte>, I<loadavg>, |
I<imap>, I<ssh>, I<request>, I<cpuusage>, I<memusage>, |
1262 |
I<timestamp>, I<second(s)>, I<minute(s)>, I<hour(s)> and I<day(s)>. |
I<memkbyte>, I<loadavg>, I<timestamp>, I<second(s)>, |
1263 |
|
I<minute(s)>, I<hour(s)> and I<day(s)>. |
1264 |
|
|
1265 |
And here is a complete list of B<noise keywords> ignored by |
And here is a complete list of B<noise keywords> ignored by |
1266 |
monit: |
monit: |
1415 |
timeout (3, 5) |
timeout (3, 5) |
1416 |
group server |
group server |
1417 |
|
|
1418 |
In this example, we demonstrate usage of the depend |
In this example, we demonstrate usage of the depends on |
1419 |
statement. In this case, we want to start oracle and |
statement. In this case, we want to start oracle and |
1420 |
apache. However, we've set up apache to use oracle as |
apache. However, we've set up apache to use oracle as a backend, |
1421 |
a backend, and if oracle is restarted, apache must be |
and if oracle is restarted, apache must be restarted as well. |
1422 |
restarted as well. |
|
1423 |
|
check apache with pidfile /var/run/httpd.pid |
1424 |
|
start program = "/etc/init.d/httpd start" |
1425 |
|
stop program = "/etc/init.d/httpd stop" |
1426 |
|
depends on oracle |
1427 |
|
|
1428 |
check oracle with pidfile /var/run/oracle.pid |
check oracle with pidfile /var/run/oracle.pid |
1429 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1430 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1431 |
port 9001 |
port 9001 |
1432 |
depend apache |
|
1433 |
|
In the next example, we have a standard three tier setup with |
1434 |
|
apache, an application server and a back end database server. |
1435 |
|
Dependencies are setup so should oracle be restarted then both |
1436 |
|
apache and the weblogic application server are also restarted. |
1437 |
|
|
1438 |
check apache with pidfile /var/run/httpd.pid |
check apache with pidfile /var/run/httpd.pid |
1439 |
start program = "/etc/init.d/httpd start" |
start program = "/etc/init.d/httpd start" |
1440 |
stop program = "/etc/init.d/httpd stop" |
stop program = "/etc/init.d/httpd stop" |
1441 |
|
depends on weblogic |
1442 |
|
|
1443 |
In the next example, we have a another program, webfoo, that |
check weblogic with pidfile /var/run/weblogic.pid |
1444 |
has been added and requires that it be restarted should apache |
start program = "/etc/init.d/weblogic start" |
1445 |
be restarted. |
stop program = "/etc/init.d/weblogic stop" |
1446 |
|
depends on oracle |
1447 |
|
|
1448 |
check oracle with pidfile /var/run/oracle.pid |
check oracle with pidfile /var/run/oracle.pid |
1449 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1450 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1451 |
port 9001 |
port 9001 |
|
depend apache |
|
1452 |
|
|
|
check apache with pidfile /var/run/httpd.pid |
|
|
start program = "/etc/init.d/httpd start" |
|
|
stop program = "/etc/init.d/httpd stop" |
|
|
depend webfoo |
|
1453 |
|
|
1454 |
check webfoo with pidfile /var/run/webfoo.pid |
Next, we have 2 programs oracle-import and oracle-export that |
1455 |
start program = "/etc/init.d/webfoo start" |
need to be restarted if oracle is restarted, but are independent |
1456 |
stop program = "/etc/init.d/webfoo stop" |
of each other. |
|
|
|
|
Next, we have 2 programs oracle-import and oracle-export |
|
|
that need to be restarted if oracle is restarted, but are |
|
|
independent of each other. |
|
1457 |
|
|
1458 |
check oracle with pidfile /var/run/oracle.pid |
check oracle with pidfile /var/run/oracle.pid |
1459 |
start program = "/etc/init.d/oracle start" |
start program = "/etc/init.d/oracle start" |
1460 |
stop program = "/etc/init.d/oracle stop" |
stop program = "/etc/init.d/oracle stop" |
1461 |
port 9001 |
port 9001 |
|
depend oracle-import |
|
|
depend oracle-export |
|
1462 |
|
|
1463 |
check oracle-import with pidfile /var/run/oracle-import.pid |
check oracle-import with pidfile /var/run/oracle-import.pid |
1464 |
start program = "/etc/init.d/oracle-import start" |
start program = "/etc/init.d/oracle-import start" |
1465 |
stop program = "/etc/init.d/oracle-import stop" |
stop program = "/etc/init.d/oracle-import stop" |
1466 |
|
depends on oracle |
1467 |
|
|
1468 |
check oracle-export with pidfile /var/run/oracle-export.pid |
check oracle-export with pidfile /var/run/oracle-export.pid |
1469 |
start program = "/etc/init.d/oracle-export start" |
start program = "/etc/init.d/oracle-export start" |
1470 |
stop program = "/etc/init.d/oracle-export stop" |
stop program = "/etc/init.d/oracle-export stop" |
1471 |
|
depends on oracle |
1472 |
|
|
1473 |
Finally an example with all statements: |
Finally an example with all statements: |
1474 |
|
|
1491 |
mail-format { from: monit@foo.bar.no } |
mail-format { from: monit@foo.bar.no } |
1492 |
every 2 cycles |
every 2 cycles |
1493 |
mode active |
mode active |
1494 |
depend webfoo |
depends on weblogic |
1495 |
|
|
1496 |
Note; only the B<check-> and B<pidfile statement> are mandatory, |
Note; only the B<check-> and B<pidfile statement> are mandatory, |
1497 |
the other statements are optional and the order of the optional |
the other statements are optional and the order of the optional |