0
votes

I want to get alert in mail when Apache Kafka and Apache Zookeeper process get stopped and when it get stopped it automatically restart both of them. Neither Apache Kafka and Apache Zookeeper does not create any pid file nor it comes under init script.

My monit control files for Apache Zookeeper and Apache Kafka is defined below

check process zookeeper match "config/zookeeper.properties"
   if not exist then exec "/Users/xxxx/kafka_2.10-0.9.0.1/bin/zookeeper-server-start.sh -c -d config/zookeeper.properties" and alert [email protected] with reminder on 500 cycles

check process kafka match "config/server.properties"
  if not exist then exec "/Users/xxxx/kafka_2.10-0.9.0.1/bin/kafka-server-start.sh -c -d config/server.properties" and alert [email protected] with reminder on 500 cycles

When I reload and start monit, it gives an error of 'kafka' process is not running and 'zookeeper' process is not running.

Please help me how to restart a Kafka and Zookeeper process and get an alert of mail

1
What is the error you get in log file of Monit? - Vishal Biyani

1 Answers

2
votes

First of all, it's "matching", not "match".

Secondly, your regex pattern will not work. You can test the pattern using

monit procmatch "regex-pattern"

This will tell you if the matching works.

Thirdly, use "start program", "stop program" to start/stop kafka.

Here's an example of my monit:

check process kafka matching "java -Xmx1G.*kafka" start program "/bin/bash -c 'cd /usr/local/xxx/kafka_2.10-0.8.2.1/; bin/kafka-server-start.sh config/server.properties &'" stop program "/bin/bash -c 'cd /usr/local/xxx/kafka_2.10-0.8.2.1/; bin/kafka-server-stop.sh'" alert [email protected] with reminder on 500 cycles