Breaking News
Home / How To / How to install Sensu Monitoring on Ubuntu 20.04

How to install Sensu Monitoring on Ubuntu 20.04



Sensu is a free open source tool used to monitor infrastructure and application health. It is written in Ruby, uses RabbitMQ to handle messages and Redis to store data. It can be installed on most operating systems including Ubuntu, Debian, RHEL, CentOS, IBM, AIX, FreeBSD, Mac OS, Solaris, Windows and many more. It is one of the most popular and next generation platforms replacing other monitoring systems such as Zabbix, Icinga and Nagios. Sensu uses a client server model. You only need to install one sensu client on each system you want to monitor.

In this tutorial we will show you how to install Sensu Monitoring Server on Ubuntu 20.04 server.

Conditions

  • A server running Ubuntu 20.04.
  • A root password is configured on the server.

Getting Started

First you need to update your system to the latest stable release. You can do this by updating all system packages with the following command:

apt-get update -y

After updating your system, install other dependencies with the following command:

apt-get install gnupg2 curl wget unzip -y

Once all the packages have been installed, you can proceed to the next step.

Install Redis and RabbitMQ

Sensu uses RabbitMQ to handle messages and Redis to store data. So both packages need to be installed in your system. By default, RabbitMQ is not available in the standard Ubuntu 20.04 repository. So you need to add the RabbitMQ repository to your system.

First import the GPG key with the following command:

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

Then add the repository by running the following command:

echo "deb http://binaries.erlang-solutions.com/debian $(lsb_release -cs) contrib" | tee /etc/apt/sources.list.d/erlang-solutions.list

Then update the repository and install the RabbitMQ package with the following command:

apt-get update -y
apt-get install rabbitmq-server -y

Once installed, you will need to create a RabbitMQ vhost for Sensu. You can create it with the following command:

rabbitmqctl add_vhost /sensu

You should see the following output:

Adding vhost "/sensu" ...

Then create a user to manage vhost with the following command:

rabbitmqctl add_user sensu password

You should see the following output:

Adding user "sensu" ...

You must then assign full permissions for vhost / sensu.

rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"

You should get the following output:

Setting permissions for user "sensu" in vhost "/sensu" ...

Then install the Redis server with the following command:

apt-get install redis-server -y

When the installation is complete, start the Redis service and make it possible to restart at system startup with the following command:

systemctl start redis-server
systemctl enable redis-server

When you are done, you can move on to the next step.

Install Sensu Server

By default, Sensu is not available in the official Ubuntu archive. So you need to add Sensu archives to your system.

First import the repository’s GPG key with the following command:

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

Then add the repository with the following command:

echo "deb https://sensu.global.ssl.fastly.net/apt bionic main" | tee /etc/apt/sources.list.d/sensu.list

Once the repository has been added, update the repository and install Sensu with the following command:

apt-get update -y
apt-get install sensu -y

Once Sensu has been installed, you can proceed to the next step.

Configure Sensu

Then you need to create configuration files for RabbitMQ, Redis and Api. First, create an api.json file with the following command:

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

Add the following lines:Advertisement

Advertisement

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

Save and close the file, and then create a redis.json file with the following command:

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

Add the following lines:

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

Save and close the file, and then create a RabbitMQ configuration file with the following command:

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

Add the following lines:

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

Save and close the file when you are done.

Install and configure Sensu Dashboard

Next, you need to install the Uchiwa Dashboard in your system. Uchiwa is an open source monitor for Sensu via the web interface.

You can install Uchiwa with the following command:

apt-get install uchiwa -y

After installing Uchiwa, create a configuration file for Uchiwa with the following command:

nano /etc/sensu/uchiwa.json

Add the following lines:

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

Save and close the file when you are done.Advertisement

Next, you need to create a client.json file to monitor the Sensu server itself. You can create it with the following command:

nano /etc/sensu/conf.d/client.json

Add the following lines:

{
  "client": {
    "name": "sensu-server",
    "address": "127.0.0.1",
    "environment": "management",
    "subscriptions": [
      "dev",
      "ubuntu"
   ],
    "socket": {
      "bind": "127.0.0.1",
      "port": 3030
    }
  }
}

Save and close the file when you are done.

Then start the Sensu server, Api, Uchiwa and the Sensu client service with the following command:

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

Once all services have been started, you can verify the status of all services with the following command:

systemctl status sensu-server sensu-api sensu-client uchiwa

You should get the following output:

? sensu-server.service - sensu server
     Loaded: loaded (/lib/systemd/system/sensu-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:04:43 UTC; 4min 18s ago
   Main PID: 10031 (sensu-server)
      Tasks: 24 (limit: 2353)
     Memory: 20.6M
     CGroup: /system.slice/sensu-server.service
             ??10031 /opt/sensu/embedded/bin/ruby /opt/sensu/bin/sensu-server -c /etc/sensu/config.json -d /etc/sensu/conf.d -e /etc/sensu/ext>

Aug 23 09:04:43 ubuntu2004 systemd[1]: Started sensu server.

? sensu-api.service - sensu api
     Loaded: loaded (/lib/systemd/system/sensu-api.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:04:42 UTC; 4min 19s ago
   Main PID: 10023 (sensu-api)
      Tasks: 2 (limit: 2353)
     Memory: 18.9M
     CGroup: /system.slice/sensu-api.service
             ??10023 /opt/sensu/embedded/bin/ruby /opt/sensu/bin/sensu-api -c /etc/sensu/config.json -d /etc/sensu/conf.d -e /etc/sensu/extens>

Aug 23 09:04:42 ubuntu2004 systemd[1]: Started sensu api.

? sensu-client.service - sensu client
     Loaded: loaded (/lib/systemd/system/sensu-client.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:04:42 UTC; 4min 18s ago
   Main PID: 10027 (sensu-client)
      Tasks: 2 (limit: 2353)
     Memory: 17.0M
     CGroup: /system.slice/sensu-client.service
             ??10027 /opt/sensu/embedded/bin/ruby /opt/sensu/bin/sensu-client -c /etc/sensu/config.json -d /etc/sensu/conf.d -e /etc/sensu/ext>

Aug 23 09:04:42 ubuntu2004 systemd[1]: sensu-client.service: Succeeded.
Aug 23 09:04:42 ubuntu2004 systemd[1]: Stopped sensu client.
Aug 23 09:04:42 ubuntu2004 systemd[1]: Started sensu client.

? uchiwa.service - LSB: Uchiwa, a Sensu dashboard.
     Loaded: loaded (/etc/init.d/uchiwa; generated)
     Active: active (exited) since Sun 2020-08-23 09:04:41 UTC; 4min 19s ago

When you are done, you can move on to the next step.

Go to the Sensu Dashboard

Now open your browser and enter the URL http: // your server-ip: 3000. You should see the Sensu instrument panel on the following screen:

Sensu Monitoring Tool

Now click on client icon in the left pane. You should see the status of the Sensu client on the following screen:

Sensu instrument panel

Conclusion

Congratulations! you have installed and configured Sensu and Uchiwa on an Ubuntu 20.04 server. You can now add more clients and start monitoring from the Uchiwa Dashboard. Feel free to ask me if you have any questions.


Source link