Gonit is an open source utility for managing and monitoring systems. It is included in all Bitnami Stacks and helps you to have total control of the application servers and services.
How to control servers using Gonit?
Apart from the control script that lets you control the services, every Bitnami stack includes also Gonit as a component that allows you to monitor and also control the services. Gonit is located at /etc/gonit/gonitrc.
Using the sudo gonit command followed by the action and the service name as argument, you can easily stop, start and restart services. Let's see some examples to learn how does it work:
|NOTE: To check what services are included in your stack, you can execute the sudo gonit status command as it is shown in the How to minitor servers status section.|
Use it to restart a single service, such as Apache, by passing the service name as argument:
$ sudo gonit restart apache
Use it to stop a single service such as MySQL:
$ sudo gonit stop mysql
Use it to start a single service such as php-fpm:
$ sudo gonit start php-fpm
How to monitor the status of the services included in your stack?
With Gonit system status can be viewed directly from the command line. It monitors processes, program files, directories, and filesystems of each service/component included in your stack.
To check which services are included in your stack, the main files, processes, and status, run the sudo gonit status command. You should see an output similar to this:
$ sudo gonit status Uptime 15m50s Last Check 2018-06-25 13:30:49.591583338 +0000 UTC Next Check 2018-06-25 13:32:49.591583338 +0000 UTC Pid 4041 Pid File /var/run/gonit.pid Socket File /var/run/gonit.sock Log File /var/log/gonit.log Process 'apache' status Running pid 2000 Uptime 17s monitoring status monitored Process 'mysql' status Running pid 3558 Uptime 17s monitoring status monitored Process 'php-fpm' status Running pid 3737 Uptime 17s monitoring status monitored
Use sudo gonit to check the Gonit status:
$ sudo gonit daemon with PID 4041 awakened
How to test Gonit?
Gonit is always running in your stack. It is constantly monitoring the server status to check if something goes wrong. When a server goes down, Gonit initiates automatically the recovery of the affected services.
To test how Gonit restarts down servers, try to kill one of the processes and check, after some minutes, the status of the servers as shown below. The following examples are executed on a WordPress deployed in the cloud:
Execute the sudo gonit status command to identify all the running processes, and note the pid of the server process you want to stop. In this case, Apache.
Execute the sudo kill command to abruptly stop the selected process.
$ sudo kill 2000
Execute the sudo gonit status command to check that Apache is stopped:
After some minutes, check again the status of the servers. The status of 'apache' should change now from "Stopped" to "Running":
What is the default configuration?
Gonit configuration files
- Gonit main configuration file: is located at /etc/gonit/gonitrc.
- Servers configuration files: the configuration files of the servers monitored by Gonit are located under the /opt/bitnami/config/monit/conf.d/ directory.