SHORT INTRODUCTION
Sensu is an agent-based monitoring tool that you use into your organization’s infrastructure. Sensu’s agent gives you visibility into everything you care about. The Sensu backend provides you with flexible, functional automatic defaults to route metrics and alerts. Sensu is designed to monitor everything from server transparency to the cloud. Sensu’s open architecture makes it easy to integrate monitoring with tools you already use such as Nagios, Chef, Graphite, InfluxDB, and PagerDuty plugins. Sensu gives you full control of your displays with variable filters, full context notifications, reporting, event management and auto-correction.
Here, we are using two servers :
sensu – 192.168.33.47
client_sensu – 192.168.33.40
Login to client_sensu – 192.168.33.40
Step 1: install the Epel-release
Install wget & vim too if you didn’t have :
Step 2: Install Erlang
Step 3 : Install Sensu
Add repository first –
Now, Install Sensu, Redis & Import Rabbitmq –
Step 4 : Now, Inserting some Repositories :
*client.json –
Copy Paste the below lines in the file & change your server-ip-
{ "client": { "name": "mysecondclient", "address": "192.168.33.47", "subscriptions": [ "default", "webserver", "production" ] } }
*transport.json –
Copy Paste the below lines in the file –
{ "transport": { "name": "rabbitmq", "reconnect_on_error": true } }
*rabbitmq.json –
Copy Paste the below lines in the file & change your server-ip –
{ "rabbitmq": { "host": "192.168.33.47", "port": 5671, "vhost": "/sensu", "user": "sensu", "password": "secret", "heartbeat": 30, "prefetch": 50, "ssl": { "cert_chain_file": "/etc/sensu/ssl/cert.pem", "private_key_file": "/etc/sensu/ssl/key.pem" } } }
make sure above 3 files are placed in /etc/sensu/conf.d directory as shown below :
Step 5 : Import ssl & install plugins
Make directory & set permission
Install some plugins :
Restart & enable all the services
Login to sensu-server – 192.168.33.47
Step 1: install the Epel-release
Install wget & vim too if you didn’t have :
Step 2: Insert the Erlang's repository file
Copy Paste the below lines in the file –
Install erlang
Step 3 : Install Sensu
Add repository first –
Now, Install Sensu, Redis & Rabbitmq –
Step 4 : Install Sensu SSL Tool
Step 5 : Configure Rabbitmq
Stop rabbitmq service & Create configure file –
Copy Paste the below lines in the file –
[
{rabbit, [
{ssl_listeners, [5671]},
{ssl_options, [{cacertfile,"/etc/rabbitmq/ssl/cacert.pem"},
{certfile,"/etc/rabbitmq/ssl/cert.pem"},
{keyfile,"/etc/rabbitmq/ssl/key.pem"},
{versions, ['tlsv1.2']},
{ciphers, [{rsa,aes_256_cbc,sha256}]},
{verify,verify_peer},
{fail_if_no_peer_cert,true}]}
]}
].
Configuring ssl –
Restarting the rabbitmq service-
Installing net-tools & configuring rabbitmq service & set permissions :
set sensu permissions & make ssl directory in /etc/sensu copy files into it :
Create sensu directory & set permission of it:
Step 6 : Now, Inserting some repositories :
*uchiwa.json –
*client.json –
Copy Paste the below lines in the file –
{ "client": { "name": "sensuserver", "address": "127.0.0.1", "subscriptions": [ "server" ] } }
*transport.json –
Copy Paste the below lines in the file –
{
"transport": {
"name": "rabbitmq",
"reconnect_on_error": true
}
}
*rabbitmq.json –
Copy Paste the below lines in the file –
{
"rabbitmq": {
"host": "127.0.0.1",
"port": 5671,
"vhost": "/sensu",
"user": "sensu",
"password": "secret",
"heartbeat": 30,
"prefetch": 50,
"ssl": {
"cert_chain_file": "/etc/sensu/ssl/cert.pem",
"private_key_file": "/etc/sensu/ssl/key.pem"
}
}
}
*api.json –
Copy Paste the below lines in the file –
{ "api": { "host": "127.0.0.1", "bind": "0.0.0.0", "port": 4567 } }
*sensu_check.json –
Copy Paste the below lines in the file –
{ "checks": { "check_mysql_running": { "type": "metric", "command": "check-process.rb -p mysql", "subscribers": [ "production" ], "interval": 10, "handlers": ["logstash" , "file"] }, "check_memory": { "type": "metric", "command": "check-memory.rb -w 300 -c 200 -p", "subscribers": [ "production" ], "interval": 10, "handlers": ["logstash" , "file"] }, "check_sensu_running": { "type": "metric", "command": "check-process.rb -p sensu", "subscribers": [ "production" ], "interval": 10, "handlers": ["logstash" , "file"] }, "check_memory_percentage": { "type": "metric", "command": "check-memory-percent.rb -w 79 -c 80", "subscribers": [ "production" ], "interval": 10, "handlers": ["logstash" , "file"] }, "check-cpu": { "command": "check-cpu.rb -w 10 -c 80", "subscribers": ["production"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] }, "check-cpu_iowait": { "command": "check-cpu.rb --iowait -w 20 -c 50", "subscribers": ["production"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] }, "check-cpu_idle": { "command": "check-cpu.rb --idle -w 20 -c 10", "subscribers": ["production"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] }, "check-mariadb": { "command": "check-systemd.rb -s mariadb.service", "subscribers": ["production"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] }, "check-redis": { "command": "check-systemd.rb -s redis.service", "subscribers": ["server"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] }, "check-sensu_server": { "command": "check-systemd.rb -s sensu-server.service", "subscribers": ["server"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] }, "check-sensu_client": { "command": "check-systemd.rb -s sensu-client.service", "subscribers": ["production", "server"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] }, "check-sensu_api": { "command": "check-systemd.rb -s sensu-api.service", "subscribers": ["server"], "interval": 10, "refresh": 10, "handlers": ["logstash" , "file"] } } }
*file_handler.json –
Copy Paste the below lines in the file –
{ "handlers": { "file": { "type": "pipe", "command": "/opt/sensu/embedded/bin/file.rb" } } }
make sure above 6 files are placed in /etc/sensu/conf.d directory as shown below :
*file.rb
Copy Paste the below lines in the file –
#!/usr/bin/env ruby require 'rubygems' require 'json' # Read event data event = JSON.parse(STDIN.read, :symbolize_names => true) # Write the event data to a file #file_name = "/tmp/sensu_#{event[:client][:name]}_#{event[:check][:name]}" #file_name = "/tmp/sensu" file_name = "/sensu/#{event[:check][:name]}" reviews = event[:client] check = event[:check] File.open(file_name, 'a') do |file| file.write("#{event[:client][:name]} #{event[:client][:timestamp]} #{event[:check][:name]} #{event[:check][:output]}") # file.write("arun") end
Step 7 : Export SSL
Export the ssl file to the client –
Step 8 : Install Uchiwa
Install uchiwa
add plugin for sensu :
Restart & enable all the services of both Servers
Step 9 : Open Browser
Open your browser & type the url with port “3000” as shown below
No responses yet