How To Install Sensu on CentOS 7

Sensu on CentOS 7

Sensu is a free and open source tool for composing the monitoring system you need. It is written in Ruby that uses RabbitMQ to handle messages and Redis to store data. Sensu provides a framework for monitoring infrastructure and application health. Sensu supports a number of platforms such as, IBM AIX, Ubuntu, Debian, RedHat, CentOS, FreeBSD, Mac OS, Solaris, Windows and much more.

Table of Contents

Step 1. First let’s start by ensuring your system is up-to-date.

Step 2. Installing Erlang.

Step 3. Installing RabbitMQ.

 

Prerequisites

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Sensu monitoring on a CentOS 7 server.
Install Sensu on CentOS 7

Step 1. First let’s start by ensuring your system is up-to-date.

yum clean all
yum -y update

Step 2. Installing Erlang.

Install Erlang using command:

wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
yum install erlang

Step 3. Installing RabbitMQ.

First thing to do is to go to RabbitMQ’s download page and download the latest stable version of RabbitMQ, At the moment of writing this article it is version 3.6.1:

wget https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpm
rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc

Installing RabbitMQ and related packages is now as simple as running just one command:

yum install rabbitmq-server-3.6.1-1.noarch.rpm

To start, stop, restart and check the RabbitMQ status, use the following:
# To start enable boot service:

systemctl enable rabbitmq-server

# To start the service:
systemctl start rabbitmq-server

# To stop the service:
systemctl stop rabbitmq-server

# To restart the service:
systemctl restart rabbitmq-server

# To check the status:
systemctl status rabbitmq-server

Step 4. Installing Redis.

Next, we will be installing Redis:

yum install redis

Finally, we will start the Redis services and enable them to auto-start:

systemctl start redis-server.service
systemctl enable redis-server.service

Step 5. Installing Sensu.

First, create a yum repository for in /etc/yum.repos.d:

### nano /etc/yum.repos.d/sensu.repo

[sensu]
name=sensu-main
baseurl=http://repositories.sensuapp.org/yum/el/7/x86_64/
gpgcheck=0
enabled=1

Then save and close the file.

Install and start the Sensu services:

yum install sensu uchiwa -y

Create a sample Sensu configuration file:

cp /etc/sensu/config.json.example /etc/sensu/config.json

Start Sensu and Uchiwa and enable auto-start:

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

Step 6. Accessing Sensu.

Sensu will be available on HTTP port 3000 by default. Open your favorite browser and navigate to http://yourdomain.com:3000 or http://server-ip:3000 and complete the required the steps to finish the installation. If you are using a firewall, please open port 3000 to enable access to the control panel.

Congratulation’s! You have successfully installed Sensu. Thanks for using this tutorial for installing Sensu monitoring on CentOS 7 systems. For additional help or useful information, we recommend you to check the official Sensu website.

How To Install Sensu on Ubuntu 16.04 LTS

Install Sensu on Ubuntu 16

Sensu is a free and open source tool for composing the monitoring system you need. It is written in Ruby that uses RabbitMQ to handle messages and Redis to store data. Sensu provides a framework for monitoring infrastructure and application health. Sensu supports a number of platforms such as, IBM AIX, Ubuntu, Debian, RedHat, CentOS, FreeBSD, Mac OS, Solaris, Windows and much more.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Sensu monitoring on an Ubuntu 16.04 Xenial Xerus server.

Install Sensu on Ubuntu 16.04 LTS

Step 1. First make sure that all your system packages are up-to-date

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing RabbitMQ.

Add Erlang repository as RabbitMQ runs on the Erlang runtime:

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

Add Erlang public key to your trusted key list:

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

Install RabbitMQ along with Erlang using the following command:

apt-get update
apt-get install -y socat erlang-nox=1:19.3-1

At this point, we can download and install RabbitMQ. As we have done for Erlang, first of all it is required to add the RabbitMQ repository:

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

Update the repositories and install RabbitMQ server with the following apt command:

apt-get update
apt-get install rabbitmq-server

Once installation is complete, start RabbitMQ and enable it to start at boot time. Execute the commands:

systemctl start rabbitmq-server
systemctl enable rabbitmq-server

Step 3. Installing Redis.

By default, Redis is available in Ubuntu repository, so we can install it by executing the following command:

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

Once the installation is complete, we can start Redis and enable it to start at boot time:

systemctl start redis-server
systemctl enable redis-server

Verify that Redis is ready to use by running the below command:

redis-cli ping

Step 4. Installing Sensu.

First, Install GPG public key and add APT configuration file at /etc/apt/sources.list.d/sensu.list:

wget -O- https://sensu.global.ssl.fastly.net/apt/pubkey.gpg |  sudo apt-key add -
echo "deb https://sensu.global.ssl.fastly.net/apt sensu main" | sudo tee /etc/apt/sources.list.d/sensu.list

Install Sensu using the following command:

apt-get update
apt-get install -y sensu

Step 5. Configure Sensu.

Sensu processes require extra configuration to tell them how to connect to the RabbitMQ transport bus:

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

Update the file with following values. Replace password with the password you chosen few steps back:

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

Next, Create redis.json file to include the connection information for Sensu to access Redis:

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

Add the below lines to the above file:

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

Create api.json file to include the connection information for Sensu to access API service:

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

Add below lines to the above file:

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

Step 5. Installing Uchiwa.

Sensu core does not come with the monitoring dashboard, so you would need to install Uchiwa which is an open source dashboard for Sensu:

apt-get install uchiwa

Once the installation is finished, create a configuration file for Uchiwa:

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

Here, paste the following content:

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

Finally, restart Sensu and Uchiwa and enable them to start at boot time:

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

Congratulation’s! You have successfully installed Sensu. Thanks for using this tutorial for installing Sensu monitoring on your Ubuntu 16.04. For additional help or useful information, we recommend you to check the official Sensu web site.