0

I want to setup monit on a server which is going to be a centralized server to monitor processes running on remote servers. I checked many docs related to setup monit but could not find how to setup for remote server processes. For example a centralized monit server should monitor nginx running on A server, mongod running on B server and so on. Any suggestion how to do this?

Ajeet Khan
  • 8,582
  • 8
  • 42
  • 65

1 Answers1

0

In the documentation, Monit can be able to test the connection remotely, using tcp or udp, what you can do is to provide a small status file that gets refreshed for each technology you are intending to monitor, and let Monit hit that status file through http, etc. and can be used as follows:

check host nginxserver with address www.nginxserver.com
   if failed port 80 protocol http
      and request "/some_file"
   then alert

Since you are testing a web server that can be easily accomplished with the above. as a note , below is the part about Monit connection testing:

CONNECTION TESTING Monit is able to perform connection testing via networked ports or via Unix sockets. A connection test may only be used within a check process or within a check host service entry in the Monit control file.

If a service listens on one or more sockets, Monit can connect to the port (using either tcp or udp) and verify that the service will accept a connection and that it is possible to write and read from the socket. If a connection is not accepted or if there is a problem with socket i/o, Monit will assume that something is wrong and execute a specified action. If Monit is compiled with openssl, then ssl based network services can also be tested.

The full syntax for the statement used for connection testing is as follows (keywords are in capital and optional statements in [brackets]),

IF FAILED [host] port [type] [protocol|{send/expect}+] [timeout] [retry] [[] CYCLES] THEN action [ELSE IF SUCCEEDED [[] CYCLES] THEN action]

or for Unix sockets,

IF FAILED [unixsocket] [type] [protocol|{send/expect}+] [timeout] [retry] [[] CYCLES] THEN action [ELSE IF SUCCEEDED [[] CYCLES] THEN action]

host:HOST hostname. Optionally specify the host to connect to. If the host is not given then localhost is assumed if this test is used inside a process entry. If this test was used inside a remote host entry then the entry's remote host is assumed. Although host is intended for testing name based virtual host in a HTTP server running on local or remote host, it does allow the connection statement to be used to test a server running on another machine. This may be useful; For instance if you use Apache httpd as a front-end and an application-server as the back-end running on another machine, this statement may be used to test that the back-end server is running and if not raise an alert.

port:PORT number. The port number to connect to

unixsocket:UNIXSOCKET PATH. Specifies the path to a Unix socket. Servers based on Unix sockets always run on the local machine and do not use a port.

Rabea
  • 1,938
  • 17
  • 26