<\/p>\n
Sensu<\/strong>\u00a0is an open-source monitoring solution that has the capability to monitor different environments, especially for mixed environments like public, private, and hybrid clouds. Sensu also provides numerous plugins that can be used as what they call “Sensu checks”. These plugins monitor the health of services, server resources, and collect different server metrics from different services. It also provides alerts and notifications.<\/p>\n
It is developed using the Ruby language. It utilizes RabbitMQ as the intermediary for the messages, and Redis for data-caching and storage.<\/p>\n
<\/p>\n
In this article, we will show you step-by-step instructions on\u00a0how to install Sensu\u00a0<\/b>on Ubuntu 18.04<\/strong>.<\/p>\n
Table of Contents<\/p>\n
For this tutorial, we recommend using a fresh\u00a0Ubuntu 18.04 VPS<\/a>\u00a0installation.<\/p>\n
Software:<\/strong><\/p>\n
To learn more about back-end and agent requirements for Sensu, you may visit their official article about hardware requirements<\/a>.<\/p>\n
Log in to your server via SSH:<\/p>\n
ssh [username]@[server_ip_address]<\/pre>\nBe sure to replace “username” with the account name of a root user found on the server (or the root user itself), and replace “server_ip” with the IP address of your server.<\/p>\n
Before starting with the installation, it is recommended to update all Ubuntu packages to their latest versions:<\/p>\n
apt-get update\r\napt-get upgrade<\/pre>\nTo avoid the “missing libraries” issue in future installations, installing basic dependencies is recommended:<\/p>\n
apt-get install software-properties-common build-essential -y<\/pre>\n<\/span>Installing and Setting Up RabbitMQ<\/span><\/h2>\n
RabbitMQ is the most-popular message broker. It will act as the intermediary messaging system for Sensu. RabbitMQ requires Erlang – a programming language which is used for building real-time application systems.<\/p>\n
To install Erlang, use the following commands to install the Erlang repository package:<\/p>\n
cd \/opt\r\nwget https:\/\/packages.erlang-solutions.com\/erlang-solutions_1.0_all.deb\r\ndpkg -i erlang-solutions_1.0_all.deb<\/pre>\nAfter setting up the Erlang and RabbitMQ repository and updating our Ubuntu installation, we can now proceed to install the Erlang package by simply typing the following:<\/p>\n
apt-get update\r\napt-get install erlang rabbitmq-server<\/pre>\nTo verify if the RabbitMQ service was successfully installed, run the following to check the status of the RabbitMQ service:<\/p>\n
systemctl status rabbitmq-server<\/pre>\nYou should be able to see a message similar to this one:<\/p>\n
rabbitmq-server.service - RabbitMQ Messaging Server
\nLoaded: loaded (\/lib\/systemd\/system\/rabbitmq-server.service; enabled; vendor
\nActive: active (running) since Sun 2019-03-17 23:12:51 CDT; 1min 22s ago<\/code><\/p>\n
Now, we need to create a vhost for our Sensu installation:<\/p>\n
rabbitmqctl add_vhost \/sensu<\/pre>\n
Next is to add a user to the vhost. Please replace [password] with a strong password.<\/p>\n
rabbitmqctl add_user sensu [password]<\/pre>\nFinally, grant full permissions to our “sensu” user:<\/p>\n
rabbitmqctl set_permissions -p \/sensu sensu \".*\" \".*\" \".*\"<\/pre>\n<\/span>Installing and Setting Up Redis<\/span><\/h2>\n
Redis is being used by Sensu as its main data-caching system for the data produced by monitoring agents, including checks, events, alerts, and notifications.<\/p>\n
Installing the Redis server is simple – you only need to type the following:<\/p>\n
apt-get -y install redis-server<\/pre>\nTo verify that the Redis server is running:<\/p>\n
systemctl status redis-server<\/pre>\nYou should see “Active(running)” in the results:
\nredis-server.service - Advanced key-value store
\nLoaded: loaded (\/lib\/systemd\/system\/redis-server.service; enabled; vendor pre
\nActive: active (running) since Sun 2019-03-17 23:23:15 CDT; 1min 15s ago<\/code><\/p>\n
<\/span>Installing Sensu<\/span><\/h2>\n
After installing the two main requirements, we can now proceed with the Sensu Core installation and configuration.<\/p>\n
As of this writing, Sensu Core package is not yet officially available in Ubuntu repository. To add Sensu’s official repository and keys, use the following commands:<\/p>\n
echo \"deb https:\/\/sensu.global.ssl.fastly.net\/apt bionic main\" | sudo tee \/etc\/apt\/sources.list.d\/sensu.list\r\nwget -O- https:\/\/sensu.global.ssl.fastly.net\/apt\/pubkey.gpg | sudo apt-key add -<\/pre>\nThe next step is to update and finally install the Sensu package:<\/p>\n
apt-get update\r\napt-get install sensu -y<\/pre>\n<\/span>Configuring Sensu<\/span><\/h2>\n
After installing Sensu, we will need to configure API, RabbitMQ, and Redis for Sensu by creating individual configuration files which are in the JSON format. We will be using
nano<\/code> to open the configuration files.<\/p>\n
API:<\/h3>\n
nano\u00a0\/etc\/sensu\/conf.d\/api.json<\/pre>\n{\r\n \"api\": {\r\n \"host\": \"localhost\",\r\n \"bind\": \"0.0.0.0\",\r\n \"port\": 4567\r\n }\r\n}<\/pre>\nRabbitMQ:<\/h3>\n
nano\u00a0\/etc\/sensu\/conf.d\/rabbitmq.json<\/pre>\n{\r\n \"rabbitmq\": {\r\n \"host\": \"127.0.0.1\",\r\n \"port\": 5672,\r\n \"vhost\": \"\/sensu\",\r\n \"user\": \"sensu\",\r\n \"password\": \"[password]\"\r\n }\r\n}<\/pre>\nRedis:<\/h3>\n
nano\u00a0\/etc\/sensu\/conf.d\/redis.json<\/pre>\n{\r\n \"redis\": {\r\n \"host\": \"127.0.0.1\",\r\n \"port\": 6379\r\n }\r\n}<\/pre>\n<\/span>Installing and Setting Up Uchiwa as Sensu’s Dashboard Web Interface<\/span><\/h2>\n
Sensu has no monitoring dashboard installed by default. Uchiwa is an open-source dashboard designed for Sensu.<\/p>\n
To install Uchiwa, type the following commands:<\/p>\n
apt-get install uchiwa -y<\/pre>\nOnce installed, we need to create the config file for Sensu. It is recommended to use a strong password for the Uchiwa admin account:<\/p>\n
nano \/etc\/sensu\/uchiwa.json<\/pre>\n{\r\n \"sensu\": [\r\n {\r\n \"name\": \"sensu.your-domain.com\",\r\n \"host\": \"127.0.0.1\",\r\n \"port\": 4567,\r\n \"timeout\": 10\r\n }\r\n ],\r\n \"uchiwa\": {\r\n \"host\": \"0.0.0.0\",\r\n \"port\": 3000,\r\n \"refresh\": 10,\r\n \"user\": \"admin\",\r\n \"pass\": \"[password]\"\r\n }\r\n}<\/pre>\nRemember to replace [password] with a strong password of your choice.<\/p>\n
<\/span>Configure Sensu Server as a Client<\/span><\/h2>\n
We can setup Sensu to monitor itself by creating the following file:<\/p>\n
nano \/etc\/sensu\/conf.d\/client.json<\/pre>\n{\r\n \"client\": {\r\n \"environment\": \"development\",\r\n \"name\": \"sensu-server\",\r\n \"address\": \"127.0.0.1\",\r\n \"subscriptions\": [\r\n \"development\",\r\n \"sensu-server\"\r\n ]\r\n }\r\n}<\/pre>\nFinally, setting the correct permissions for the configuration is required.<\/p>\n
chown -R sensu:sensu \/etc\/sensu\/conf.d\/*<\/pre>\nchown sensu:sensu \/etc\/sensu\/uchiwa.json<\/pre>\n<\/span>Managing Sensu Services<\/span><\/h2>\n
To enable automatic startup of all services at boot:<\/p>\n
systemctl enable sensu-server \r\nsystemctl enable sensu-api\r\nsystemctl enable sensu-client \r\nsystemctl enable uchiwa<\/pre>\nLet’s make sure that all services are started:<\/p>\n
systemctl start sensu-server \r\nsystemctl start sensu-api\r\nsystemctl start sensu-client \r\nsystemctl start uchiwa<\/pre>\nYou may now access your Uchiwa dashboard using
http:\/\/[server's public IP]:3000<\/code>. You should be able to see sensu-server as a client.<\/p>\n
<\/p>\n
That’s it –\u00a0<\/strong>you now have a working Sensu monitoring server\u00a0on your Ubuntu 18.04 server.<\/p>\n
\n
Of\u00a0course, you don\u2019t have to install Sensu\u00a0<\/b>on Ubuntu 18.04<\/strong> if you have an\u00a0Ubuntu VPS<\/a> with us. You can simply ask our support team to install Sensu on Ubuntu 18.04 for you. They are available 24\/7 and will be able to help you with the installation.<\/p>\n
There is a new updated article on how to Install Sensu on Ubuntu 20.04 <\/a>in our step-by-step guide.<\/p>\n