You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

Welcome to our guide on How to Install Sensu Monitoring Tool on Ubuntu 20.04 | 18.04 LTS. Sensu is an open-source, full-stack monitoring tool suitable for any kind of dynamic operating environments. It is a simple, scalable and malleable framework that helps you compose the monitoring system you need.

Introduction to Sensu Monitoring Tool

Sensu is capable of monitoring public, private, and hybrid cloud, and container-based environments. It is written in Ruby and uses RabbitMQ for queuing check events and requests. Data that needs persistent storage like client information are stored in Redis. Sensu ships with a ton of plugins for monitoring common services.

How Sensu Works

Sensu uses a client-server model where all systems to be monitored runs a sensu client software. This client application is responsible for executing local checks, managing client subscription and registration, and fulfilling checks requested by the Sensu Server. The agent reports the results of a check and the server will take action based on the results, e.g sending a notification message to the user if the service is down.

Install Sensu Monitoring Tool on Ubuntu 20.04/18.04 LTS

In this section, I’ll show you the steps to install the Sensu Monitoring Tool on Ubuntu 20.04/18.04 LTS. I assume you already have a running Ubuntu 20.04/18.04 server, it can be a VM locally, in the Cloud, or a dedicated server.

Step 1: Set server hostname, ntp, and update

Always start your installations by updating system package to the latest version.

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

Wait for the server to come up then set hostname:

sudo hostnamectl set-hostname sensu.example.com

Setup NTP and Timezone

It is good to have NTP configured on both Sensu server and agents for correct timestamp on all data.

Set correct timezone:

sudo timedatectl set-timezone Africa/Nairobi

Install ntp package:

sudo apt -y install ntp

Show ntp status:

$ ntpq -p

Step 2: Install Redis and RabbitMQ

RabbitMQ runs on the Erlang runtime, you need to import GPG key:

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

Add Erlang repository using below command:

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

Install RabbitMQ:

sudo apt update
sudo apt install rabbitmq-server

When done, Create a RabbitMQ vhost for Sensu

$ sudo rabbitmqctl add_vhost /sensu
Creating vhost "/sensu"

Add user to manage the vhost

$ sudo rabbitmqctl add_user sensu  StrongPassword
Creating user "sensu"

Replace StrongPassword with your password.

Assing sensu user full permissions for the vhost /sensu

$ sudo rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"
Setting permissions for user "sensu" in vhost "/sensu"

Install Redis Server:

sudo apt -y install redis-server

Step 3: Install and Configure Sensu

Sensu packages are not available on official Ubuntu repository. You’ll need to add the upstream repository before you can install sensu package.

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

Import repository GPG key:

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

Update package index and install Sensu:

sudo apt update
sudo apt -y install sensu

Sensu configuration files, plugins and extensions will be placed under the /etc/sensu/directory.

Create sensu configuration file for connecting to RabbitMQ, API and Redis

Create API configuration file:

sudo tee /etc/sensu/conf.d/api.json<<EOF
{
  "api": {
    "host": "localhost",
    "bind": "0.0.0.0",
    "port": 4567
  }
}
EOF

Create RabbitMQ access config:

sudo tee /etc/sensu/conf.d/rabbitmq.json<<EOF
{
  "rabbitmq": {
    "host": "127.0.0.1",
    "port": 5672,
    "vhost": "/sensu",
    "user": "sensu",
    "password": "StrongPassword"
  }
}
EOF

Redis config:

sudo tee /etc/sensu/conf.d/redis.json<<EOF
{
  "redis": {
    "host": "127.0.0.1",
    "port": 6379
  }
}
EOF

Step 4: Install and Configure Uchiwa Sensu web interface

Install uchiwa by running:

sudo apt -y install uchiwa

Create configuration file:

Set Some variables for configuring Sensu:

DOMAIN="sensu.example.com"
UI_USERNAME="admin"
UI_PASSWORD="[email protected]"

Create configuration file:

sudo tee /etc/sensu/conf.d/uchiwa.json<<EOF
{
  "sensu": [
    {
      "name": "$DOMAIN",
      "host": "127.0.0.1",
      "port": 4567,
      "timeout": 10
    }
  ],
  "uchiwa": {
    "host": "0.0.0.0",
    "port": 3000,
    "refresh": 10,
    "user": "$UI_USERNAME",
    "pass": "$UI_PASSWORD"
  }
}
EOF

Configure Sensu client:

sudo tee /etc/sensu/conf.d/uchiwa.json<<EOF
{
  "client": {
    "environment": "development",
    "name": "sensu-server",
    "address": "127.0.0.1",
    "subscriptions": [
      "development",
      "sensu-server"
    ]
  }
}
EOF

Set permissions:

sudo chown sensu. /etc/sensu/conf.d/*

Step 5: Start Sensu Service

You can now start sensu services and enable them to start on boot:

for i in sensu-server sensu-api sensu-client uchiwa; do
  sudo systemctl enable $i
  sudo systemctl start $i
done

Access Sensu Dashboard using http://[ip|hostname]:3000

Login with configured username and password.

More guides:

Install and Configure Nagios 4 on Ubuntu

Install Zabbix 5 on Ubuntu

Install LibreNMS on Ubuntu

Install Grafana on Ubuntu

Install Prometheus on Ubuntu

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

LEAVE A REPLY

Please enter your comment!
Please enter your name here