Sensu Setting up a Client

Posted on Friday, October 24, 2014

This guide will go over setting up Sensu client on a
separate server from your Sensu Master Server.
The server I will be setting up Sensu client on is a freshly installed
Ubuntu 14.04 server. This guide assumes
you already have a Sensu Master Server set up, if you don't you can check out
my write up on setting up a Sensu Master server at

And if I try to test the check I made in the last article
(It just checks to see if a file exists, so I will remove the file and see if I
get an alert)

> rm ~/test.txt

Looks like its all working fine!

Touch the file to remove the alert

> touch ~/test.txt

Setting up a second Sensu Client on another Server

I have my master Sensu server set up and now I want to set
up a Sensu Client on another server. In
my case it will be a server located at 192.168.0.151.

Before I get too far, sense I
have a fresh install of Ubuntu 14.04, I need to update and upgrade apt-get.

> sudo apt-get update

> sudo apt-get upgrade

Install Sensu

Edit to /etc/apt/sources.list

> sudo vi /etc/apt/sources.list

Append this to the end

deb http://repos.sensuapp.org/apt sensu main

Add an ssl key

> wget -q
http://repos.sensuapp.org/apt/pubkey.gpg

> sudo apt-key add pubkey.gpg

> sudo apt-get update

Install Sensu

> sudo apt-get install sensu

Create the client.json file

Create the
client.json file

> sudo vi
/etc/sensu/conf.d/client.json

And place the
following in it

{

"client": {

"name": "client-1",

"address": "192.168.0.151",

"subscriptions": [ "client-1"
],

"safe_mode":true

}

}

Create the rabbitmq.json file

Create the
rabbitmq.json file.

> sudo vi
/etc/sensu/conf.d/rabbitmq.json

Put the following in
it, host contains the Master Sensu hostname or IP address

{

"rabbitmq": {

"host": "192.168.0.150",

"port": 5672,

"vhost": "/sensu",

"user": "sensu",

"password": "mypassword"

}

}

> sudo service sensu-client start

Then look at the log
real quick

> sudo tail -f
/var/log/sensu/sensu-client.log

I have this error!

"[amqp]
Detected TCP connection failure"

I think this is due
to the set up of rabbitMQ on the master server.
I think it's not aware of the client.

Turns out I need to edit the /etc/rabbitmq/rabbitmq.config on the Sensu Master
Server

Currently
it is set to

[

{rabbit, [

{tcp_listeners,[{"127.0.0.1",5672}]}

]}

].

Which basically says only
listen to localhost on port 5672

Edit the file and fix it.

> sudo vi
/etc/rabbitmq/rabbitmq.config

Here is what I set
mine to I had to remove the
specific listener.

[

{rabbit, [

]}

].

Then reboot rabbitMQ on the master Sensu server

> sudo service rabbitmq-server restart

Reload Uchiwa and
click on the clients button on the right.
And you can see that my client-1 sever was added! Now I have two Sensu clients, client-1 and
sensu-master.
Enable the services to start automatically

Run the following
command

> sudo update-rc.d sensu-client defaults

Reboot to make sure
it all comes up like it should

> sudo reboot now

Add a check on the new client

I am going to recreate
check-file.rb that exists on the Sensu Master onto the Sensuc Client.

I wrote an article on this subject1st client http://www.whiteboardcoder.com/2014/10/sensu-setting-up-client.html2nd client on another server http://www.whiteboardcoder.com/2014/10/sensu-setting-up-second-client-with-ssl.html

Also there is this page that chronicles all my sensu articleshttp://www.whiteboardcoder.com/p/sensu-epic.html