How to Install Sensu on Ubuntu 16.04

By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Monitoring IT infrastructure is an essential part of any system administrator to maximize availability and minimize disruption, enabling rapid intervention by detecting failures and developing issues. Sensu is one of the free and open source monitoring tool that monitors your servers, services, application, cloud infrastructure simply and efficiently. Sensu is a powerful Next-Generation monitoring framework that is quickly replacing traditional monitoring systems like Zabbix, Icinga, and Nagios. It is written in Ruby, uses RabbitMQ to handle messages and Redis to store data. You can easily integrate Sensu with many modern DevOps stacks, such as Slack, HipChat and IRC. Sensu is very scalable so you can easily monitor hundreds or thousands of servers.

Sensu supports on multiple operating systems such as, Ubuntu, Debian, RedHat, CentOS, FreeBSD, Mac OS, Solaris and Windows.

In this tutorial, we will be installing and configuring Sensu on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 server.

Requirements

  • Two free Alibaba cloud instance with Ubuntu 16.04 installed.
  • A static IP address 192.168.0.101 is configured on the first instance (Sensu Server) and 192.168.0.104 is configured on the second instance (Sensu Client).
  • A root password is set up on both instances.

Launch Alibaba Cloud ECS Instance

First, Login to your Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

Install RabbitMQ and Redis

Sensu uses RabbitMQ to handle messages and Redis to store its data. So you will need to install RabbitMQ and Redis on the server instance.

First, install Redis server with the following command:

Once the Redis is installed, start the Redis service and enable it to start on boot with the following command:

You can check the Redis service with the following command:

Output:

Before installing RabbitMQ, you will need to install Erlang to your system. Because, RabbitMQ runs on the Erlang runtime.

First, install Erlang repository with the following command:

Next, add Erlang public key to your trusted key list:

Next, update the repository and install Erlang with the following command:

Next, install RabbitMQ repository with the following command:

Next, update the repository and install RabbitMQ with the following command:

Once the installation is completed, start RabbitMQ service and enable it to start on boot with the following command:

You can now check the status of RabbitMQ service with the following command:

Output:

Next, you will need to create a RabbitMQ vhost and user for Sensu. You can do this by running the following command:

Install and Configure Sensu

By default, Sensu package is not available in the Ubuntu 16.04 default repository. So, you will need to add Sensu repository to your server.

First, download and add the GPG public key with the following command:

Next, add Sensu repository to APT configuration file with the following command:

Next, update the repository and install Sensu with the following command:

Once the installation is completed, start Sensu service and enable it to start on boot time with the following command:

By default, Sensu configuration files are located at /etc/sensu directory.

Before starting, you will need to configure Sensu for using with RabbitMQ and Redis.

First, create a RabbitMQ file with the following command:

Add the following lines:

Next, create a Redis file with the following command:

Add the following lines:

Next, create a api.json file:

Add the following lines:

Save and close the file, when you are finished.

Install and Configure Uchiwa Dashboard

Sensu does not provide any web-based interface to monitor Sensu through a web browser. So, you will need to install Uchiwa dashboard to your server instance.

Uchiwa is a simple dashboard for the Sensu monitoring framework, built with Go and AngularJS. Uchiwa provides an easy mechanism to silence any check for an unlimited period of time.

You can install Uchiwa by just running the following command:

Once the installation is completed, create an uchiwa configuration file:

Add the following lines:

Save and close the file. Then, restart Sensu and Uchiwa service with the following command:

Now, open your web browser and type the URL http://your-server-ip:3000. You will be redirected to the Uchiwa dashboard as shown in the following page:

Image for post
Image for post

Now, click on the data centers icon in the left pane. You should see the Sensu Server instance as below:

Image for post
Image for post

Monitor Sensu Server

Next, you will need to configure the Sensu server as a client to monitor itself. You can do this by creating client.json file:

Add the following lines:

Save and close the file. Then, restart the sensu-client service with the following command:

Now, go to the Uchiwa dashboard and click on the clients page. You should see the status of the newly added client in the following page:

Image for post
Image for post

Now, click on the sensu-server. You should see detail information in the following page:

Image for post
Image for post

Configure Sensu Client

Sensu server is now installed and working fine. It’s time to install Sensu client on the Sensu client instance and monitoring it from Sensu server.

By default, Sensu package is not available in the Ubuntu 16.04 default repository. So, you will need to add Sensu repository to your Sensu client instance.

First, download and add the GPG public key with the following command:

Next, add Sensu repository to APT configuration file with the following command:

Next, update the repository and install Sensu with the following command:

Next, you will need to create a client configuration file for Sensu. You can do this with the following command:

Add the following lines:

Save and close the file, when you are finished.

Next, you will need to configure Sensu client to connect with Sensu transport. You can do this by creating transport.json file:

Add the following lines:

Save and close the file. Then, create a RabbitMQ configuration file:

Add the following lines:

Save and close the file. Then, restart sensu-client service with the following command:

Now, go to the Uchiwa dashboard. You should see the newly added Sensu-Client in the following page:

Image for post
Image for post

You can see the detail information of the newly added client in the following page:

Image for post
Image for post

Monitor Apache and Disk Status

Sensu server and client is now installed and working fine. Now, we will configure Sensu to monitor Apache and Disk status on Client instance. Sensu uses checks command to monitor specific services.

First, you will need to configure “Subscription checks” for Apache on the Sensu server instance. You can do this by creating the following file:

Add the following lines:

Save and close the file. Then, restart Sensu service with the following command:

On the Client Instance, you will need to install Sensu plugins to monitor system resources, services, and application health. You can install it with the following command on the Client instance:

Next, create a client.json file for Apache service check:

Add the following lines:

Save and close the file.

Next, create a configuration file for Disk check with the following command:

Add the following lines:

Save and close the file. Then, restart Sensu client service with the following command:

Next, go to the Uchiwa dashboard. You should see the apache-status and disk-status in the following page:

Image for post
Image for post

Congratulations! You have successfully installed Sensu server and add remote host into Sensu server. You can now easily add another host and monitor services as per your need.

Original Source

https://www.alibabacloud.com/blog/how-to-install-sensu-on-ubuntu-16-04_594940?spm=a2c41.13059740.0.0

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store