How to Use Sensu and RabbitMQ on Ubuntu to Monitor Your WordPress Website

Data speaks for itself. In case of computers, the data often yells at you for ages before a crisis occurs. If your web server is running low on memory, getting more traffic than it can handle, or just has bugs in it that are making the system perform poorly, you need to know.

Monitoring system often gets out of hand once we get more than two or three servers running. Sensu is designed to cope up with exactly these type of issues.

A little about the Sensu architecture

Now before you hastily scroll down to copy and run commands, it is important to have an overview of the Sensu architecture in the back of your head.

First is the Sensu client which runs on the system you want to monitor (for e.g your web server), it runs checks, which are essentially measurements that you want from the system. Checks which the client runs periodically, or on its own, are known as stand-alone checks.

These checks are typically meant to measure a certain parameter of the system that is of interest. The client sends the information it has gathered to a RabbitMQ service that acts as a transport layer for maintaining communication between the Sensu client and the Sensu server.

The Sensu server is responsible for running dedicated actions, called handlers depending on what data it receives via RabbitMQ transport layer. For example, you can set a handler to send you an alert via email if your system memory utilization is above 80%. Sensu server can also send requests which would reach the Client via RabbitMQ to query unscheduled checks, this further improves the flexibility of the monitoring system.

Knowing the entire history of monitoring is often better than just knowing the current state of affairs. To store this Sensu uses Redis. The final component is the Sensu API which establishes an interface between Redis and RabbitMQ, and the Dashboard and other User Interfaces.

The RabbitMQ, Redis, Sensu server and Sensu API can all run on a single server. We can then install Sensu clients on our target systems and monitor them. This is a typical setup. Some installation can go all modular with each component, including the API, Redis and RabbitMQ all running on different machines. In our example, for sake of simplicity, we have used a single machine for all the components, as well as the Sensu client.

Related:  VestaCP; Installing the Free Website Management Utility on Ubuntu

Software Installation

1. Installing RabbitMQ

Assuming you have a typical WordPress site set up, we start with installation of the transport layer, that is RabbitMQ. RabbitMQ’s APT repositories are added to the sources.list.d along with the keys and then an apt install later we have a RabbitMQ server up and running.

$sudo echo 'deb testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
$sudo wget -O- | sudo apt-key add -
$sudo apt update
$sudo apt install rabbitmq-server erlang-nox
$sudo service rabbitmq-server start

RabbitMQ would need secure SSL certificates to start communicating with various components of the monitoring setup. The following command would fetch a script from Sensuapp’s website and run it to generate ssl certificate and keys.

$cd /tmp && wget && tar -xvf ssl_certs.tar
$cd ssl_certs && ./ generate

Now we provide the newly obtained certificates to RabbitMQ

$sudo mkdir -p /etc/rabbitmq/ssl && sudo cp /tmp/ssl_certs/sensu_ca/cacert.pem /tmp/ssl_certs/server/cert.pem /tmp/ssl_certs/server/key.pem /etc/rabbitmq/ssl

After this we need to add a file /etc/rabbitmq/rabbitmq.config and add the contents given below to it.

 {rabbit, [
 {ssl_listeners, [5671]},
 {ssl_options, [{cacertfile,"/etc/rabbitmq/ssl/cacert.pem"},

Restarting RabbitMQ is recommended before we move on to the next part

$sudo service rabbitmq-server restart

After this, we add a sensu virtual host and a user for using RabbitMQ and give it appropriate permissions.
Remember to use appropriate password instead of the word pass when running the commands below.

$sudo rabbitmqctl add_vhost /sensu
$sudo rabbitmqctl add_user sensu pass
$sudo rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"

2. Installing Redis

Once this is done, time to install the next important component that is Redis.

$sudo apt install redis-server
#Start the service as well
$service start redis-server

3. Installing Sensu Packages

Lastly, we would need to get Sensu package which contains both the server, client, and API bits in it. But first, we need to ascertain the code-name of your Ubuntu installation. For the 16.04 LTS version, it is xenial. If your case is different, try running the following

$. /etc/os-release && echo $VERSION

This would give you an output similar to this.

In case of 14.04 the code name will be trusty. However, we can move from here to store the value of your version code name and adding appropriate repository to our list

$export CODENAME=xenial
$echo "deb $CODENAME main" | sudo tee /etc/apt/sources.list.d/sensu.list
$apt update
$apt install sensu uchiwa

That’s pretty much all we need for a basic installation.

Related:  How to Install, Configure and Run a Personal Mail Server using Postal on Ubuntu


Sensu doesn’t come with any ‘default configuration’ whatsoever. The entire system is a blank slate for the administrator to do whatever he/she wishes to do. We begin by making Sensu aware of the RabbitMQ’s availability. To do this create a file with the exact name and location as /etc/sensu/conf.d/rabbitmq.json and add the following text to it.

 "rabbitmq": {
 "ssl": {
 "cert_chain_file": "/etc/sensu/ssl/cert.pem",
 "private_key_file": "/etc/sensu/ssl/key.pem"
 "host": "localhost",
 "port": 5671,
 "vhost": "/sensu",
 "user": "sensu",
 "password": "pass"

Remember to change word pass with the password chosen while creating Sensu user in RabbitMQ, in the above steps.
Similarly, we put the following in a file named /etc/sensu/conf.d/redis.json

 "redis": {
 "host": "localhost",
 "port": 6379
Followed by /etc/sensu/conf.d/api.json
 "api": {
 "host": "localhost",
 "port": 4567

Finally, we create the configuration file for our dashboard in the file /etc/sensu/conf.d/uchiwa.json

 "sensu": [
 "name": "Sensu",
 "host": "localhost",
 "ssl": false,
 "port": 4567,
 "path": "",
 "timeout": 5000
 "uchiwa": {
 "port": 3000,
 "stats": 10,
 "refresh": 10000

Since we are going to use the same server as our target system to be monitored, we should also add a /etc/sensu/conf.d/client.json

 "client": {
 "name": "server",
 "address": "localhost",
 "subscriptions": [ "ALL" ]

Finally, we need to restart/start all the services in appropriate order for the monitoring service to kick in. Run the following commands one after the other

$sudo service rabbitmq-server restart
$sudo service redis-server restart
$sudo service sensu-server start
$sudo service sensu-api start
$sudo service sensu-client start
$sudo service uchiwa start

Now that we are done, we can visit the http://public_ip:3000 or if you have a domain name associated with the server, then that domain name at port 3000 would give you something similar to this.

We hope you have enjoyed reading this post about WordPress website monitoring with Sensu and RabbitMQ. Feel free to reach out to our support crew in the case of any issues, we offer 24/7 WordPress support at a ridiculously low price. If you liked this article, then please subscribe to our mailing list for WordPress video tutorials. You can also find us on Twitter and Facebook.

How to Use Sensu and RabbitMQ on Ubuntu to Monitor Your WordPress Website
4 (85%) 120 votes