How To Install & Configure Sensu To Monitor Ubuntu

When managing environments based on Linux, it is essential to know the various applications that allow us to take a much more straightforward management level and with a much higher management scope.

Sensu is a vital solution for the analysis and monitoring of the system.

Today in we will analyze what is and how to configure Sensu in Ubuntu.

What is Sensu?

Sensu is an open source monitoring platform which helps organizations to compose monitoring and telemetry solutions that meet the business requirements at the analysis level.

It is written in Ruby which uses RabbitMQ to handle messages and Redis to store data.

Sensu offers a simple framework to monitor the infrastructure and health of the applications and services available.

Also supports several platforms such as IBM AIX, Ubuntu, Debian, RedHat, CentOS, FreeBSD, Mac OS, Solaris, Windows and many more.

Update Ubuntu

The first step is to update the system and to do this we will execute the following commands:

sudo apt-get update -y
sudo apt-get upgrade -y

Once updated, we proceed to its restart executing

sudo reboot

Install & Configure RabbitMQ

RabbitMQ works in Erlang, so it will be necessary to install Erlang in the system.

First, we will add the Erlang repository and the Erlang public key to the list of trusted keys by executing the following command:

wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb

Next we will extract the content running:

sudo dpkg -i erlang-solutions_1.0_all.deb

Now we will download the public key by executing the following:

wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -

We proceed to update the repositories using the following command:

sudo apt-get update -y

With the updated repositories we continue to the installation of Erlang by running the following:

sudo apt-get install socat erlang-nox -y

Now it will be necessary to download and install the latest version of the RabbitMQ repository on your system by executing the following:

wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server_3.6.10-1_all.deb

We extract the downloaded content by running the following:

sudo dpkg -i rabbitmq-server_3.6.10-1_all.deb

Again we update the installed repositories by executing:

sudo apt-get update -y

Now we can proceed to install RabbitMQ by executing the following:

sudo apt-get install rabbitmq-server -y

Once installed, we will start the service and enable it to be executed in the boot of Ubuntu 17.04:

sudo systemctl start rabbitmq-server

sudo systemctl enable rabbitmq-server

Create VHOST & User for Sensu

The next step is to run the following commands:

sudo rabbitmqctl add_vhost /sensu [Create VHOST]
sudo rabbitmqctl add_user sensu (password) [Create user]
sudo rabbitmqctl set_permissions -p /sensu ".*" ".*" ".*" [Set Permissions]

Install Redis Server

Sensu makes use of the Redis server for data storage, by default, Sensu is available in the Ubuntu repository.

We can install the Redis server by executing the following command:

sudo apt-get install redis-server apt-transport-https -y

Once installed, we proceed to start it and enable it at the beginning of the session:

sudo systemctl start redis-server
sudo systemctl enable redis-server

Install & Configure Sensu

By default, Sensu is not available in the Ubuntu repository and therefore it will be necessary to add the public key and repository to Ubuntu.

First, we will add the GPG key with the following command:

wget -O- https://sensu.global.ssl.fastly.net/apt/pubkey.gpg | sudo apt-key add –

Now we will add the Sensu repository creating the sensu.list file inside the /etc/apt/sources.list.d directory by executing the following:

sudo nano /etc/apt/sources.list.d/sensu.list

In this file we will add the following line:

deb https://sensu.global.ssl.fastly.net/apt sensu main

Save the changes using the following key combination Ctrl + O and exit the editor using Ctrl + X.

We update the repository using the following line:

sudo apt-get update -y

Now we will install Sensu by executing the following:

sudo apt-get install sensu -y

After the installation of Sensu, it will be necessary to configure Sensu for RabbitMQ and Redis.

By default, Sensu will load the configuration from the /etc/sensu/conf.d/ directory, which is why we must create configuration files for RabbitMQ, Redi and Api.

First, we will create a rabbitmq.json file inside the /etc/sensu/conf.d directory by executing the following:

sudo nano /etc/sensu/conf.d/rabbitmq.json

There we will add the following:

{
  "rabbitmq": { 
    "host": "127.0.0.1", 
    "port": 5672, 
    "vhost": "/sensu", 
    "user": "sensu", 
    "password": "Password" 
  }
}

Save the changes.

Now we will create the redis.json file by executing the following:

sudo nano /etc/sensu/conf.d/redis.json

There we will add the following:

{
  "redis": { 
    "host": "127.0.0.1", 
    "port": 6379 
  }
}

Save the changes. Now we will create the api.json file:

sudo nano /etc/sensu/conf.d/api.json

There we will add the following. We save the changes and leave the file.

{
  "api": { 
    "host": "localhost", 
    "bind": "0.0.0.0", 
    "port": 4567 
  }
}

Install & Configure Sensu Dashboard

By default the dashboard in Sensu is not predefined so it will be necessary to install an open source Uchiwa Dashboard in Ubuntu for this purpose.

For this we will first add an Uchiwa repository in Ubuntu by executing the following:

wget -O- https://sensu.global.ssl.fastly.net/apt/pubkey.gpg | sudo apt-key add –

Now we will add the Uchiwa repository creating the uchiwa.list file inside the /etc/apt/sources.list.d directory:

sudo nano /etc/apt/sources.list.d/uchiwa.list

In this file we will add the following:

deb https://sensu.global.ssl.fastly.net/apt sensu main

Save the changes.

We update the repositories using

sudo apt-get update -y

Now we will install Uchiwa by running the following:

sudo apt-get install uchiwa -y

Next, we will create the Uchiwa configuration file by executing the following:

sudo nano /etc/sensu/conf.d/uchiwa.json

We will paste the following lines into this file:

{
"sensu": [
{
	 "name": "Sensu",
	 "host": "localhost",
	 "port": 4567,
	 "timeout": 10
}
],
"uchiwa": {
"host": "0.0.0.0",
"port": 3000,
"refresh": 10
}
}

Save the changes.

Now we will execute the following commands in their order to start Uchiwa and enable it from the beginning, and in the same way restart Sensu:

sudo systemctl start sensu-server
sudo systemctl enable sensu-server
sudo systemctl start sensu-api
sudo systemctl enable sensu-api
sudo systemctl start sensu-client
sudo systemctl enable sensu-client
sudo systemctl start uchiwa
sudo systemctl enable uchiwa

Enter the Sensu Dashboard

The next step is to execute the following commands for the installation and enablement of the port used by Sensu:

sudo apt-get install ufw -y
sudo ufw enable
sudo ufw allow 3000

With these permits we go to a browser and introduce any of the following options:

http://IP_Computer:3000
or
http://localhost:3000

In this way we can configure Sensu to monitor applications and services in Ubuntu 17.04.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *