• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Saturday, May 10, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

How to Add a CentOS 7 Sensu Client

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
16
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Step 1: Add the Sensu repository
  2. Step 2: Install necessary plugins
  3. Step 3: Add configuration files
  4. Step 4: Give permissions to the sensu user
  5. Want to contribute?


In the guide “How to Install and Configure Sensu Monitoring on CentOS 7”, you learned how to setup a Sensu server. This tutorial is the second part, where you will learn how to add a Sensu client. A Sensu client is a server that Sensu monitors.

I assume that the Sensu client is a CentOS 7 virtual machine. Log into SSH and follow the steps below. You won’t have to alter anything on the Sensu server. As long as the Sensu client successfully authenticates with the Sensu server, checks will automatically be executed.

Before we get started, make sure that your firewall is configured correctly. With a default setup, open outgoing TCP ports 5671 and 5672.

Step 1: Add the Sensu repository

The package sensu-client is not in the default CentOS repositories. Add the repository by pasting the following content into the file /etc/yum.repos.d/sensu.repo:

[sensu]
name=sensu
baseurl=https://sensu.global.ssl.fastly.net/yum/$releasever/$basearch/
gpgcheck=0
enabled=1

Next, update yum and install sensu-client:

yum update
yum install sensu

All services (sensu-server, sensu-client and sensu-api) will be installed by installing the sensu package. You can safely ignore all services except for the sensu-client that we will be using. Do not start the service yet.

Step 2: Install necessary plugins

Sensu’s model is to distribute load over clients that results from executing checks and pushing check results. As a result, you need to install Sensu plugins on the clients themselves rather than on the Sensu server. Some plugins are compiled locally, which means we’ll need build tools on the clients:

yum groupinstall "Development tools"

The following plugins are very popular and used for many checks. Execute each of these commands to install the plugins once the development tools packages have been installed. Depending on the size of your server, this might take a while:

sensu-install -p uptime-checks
sensu-install -p process-checks
sensu-install -p http
sensu-install -p filesystem-checks
sensu-install -p cpu-checks
sensu-install -p memory-checks
sensu-install -p disk-checks
sensu-install -p load-checks
sensu-install -p network-checks

Step 3: Add configuration files

We will be adding four configuration files to the Sensu client.

  • /etc/sensu/conf.d/client.json:

    This file contains subscriptions, the IP address for the Sensu client and the client name. Replace the values ipaddress and hostname with values that describe the client you are adding. Also, specify subscriptions defined on the Sensu server or, if you do not have any, remove the entire subscriptions section. Don’t forget to remove the comma after name if you do:

    {
        "client": {
            "address": "-----ipaddress-----",
            "environment": "production",
            "name": "-----hostname-----",
            "subscriptions": [
                "linux"
            ]
        }
    }
    
  • /etc/sensu/conf.d/transport.json:

    In this file, we define the transport used. By default, the transport used is RabbitMQ. Paste the following contents into the file. No values have to be changed:

    {
        "transport": {
            "name": "rabbitmq",
            "reconnect_on_error": true
        }
    }
    
  • /etc/sensu/conf.d/rabbitmq.json:

    The RabbitMQ server and credentials are specified in this file. Replace hostname with the DNS name. By default, the port is 5672 for unencrypted connections. The RabbitMQ user and password should be replaced as well. These details can differ for each Sensu client or be the same for all clients. This is a practical decision that is made by the user.

    The vhost is / by default but it is often changed to /sensu. If you’re not sure which to use, try both:

    {
        "rabbitmq": {
            "host": "-----hostname-----",
            "password": "-----rabbitmq_password-----",
            "port": 5672,
            "user": "-----username-----",
            "vhost": "/sensu"
        }
    }
    
  • /etc/sensu/conf.d/checks.json:

    Sensu supports two types of checks: standalone checks and subscription checks. Subscription checks are defined on the Sensu server and the subscriptions are defined in the client.json file on a Sensu client. Standalone checks are checks that are defined on the Sensu clients themselves. These are usually checks that only apply to one specific server. For example, a check that would be in a subscription is a check to see if the web server is still running. A standalone check could be a check to see if server A can reach server B. No other server needs that check.

    Standalone checks are defined in this file. Below you will find an example of a checks.json file with some example standalone checks:

    {
        "checks": {
            "httpd": {
                "command": "sudo check-process.rb -p httpd",
                "handlers": [
                    "default",
                    "pushover"
                ],
                "interval": 180,
                "occurences": 3,
                "refresh": "1800",
                "standalone": true,
                "ttl": 1200
            },
            "mysqld": {
                "command": "sudo check-process.rb -p mysqld",
                "handlers": [
                    "default",
                    "pushover"
                ],
                "interval": 180,
                "occurences": 3,
                "refresh": "1800",
                "standalone": true,
                "ttl": 1200
            }
        }
    }
    

After you have finished configuration of the Sensu client, change the rights:

chown -R sensu:sensu /etc/sensu/conf.d

Step 4: Give permissions to the sensu user

Checks are executed as the user sensu. Naturally, this user has limited rights. However, some checks need root permissions to execute. We will allow the user sensu to execute any check as root but limit its other permissions.

Paste the following contents into the file /etc/sudoers.d/sensu:

Defaults:sensu
secure_path=/opt/sensu/embedded/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

sensu ALL=(ALL) NOPASSWD: /opt/sensu/embedded/bin/check*.rb *
sensu ALL=(ALL) NOPASSWD: /opt/sensu/embedded/bin/metrics*.rb *

The first two lines define the default path which allows you to specify only the script name in the check command rather than the entire path. For example, simply using the command sudo check-process.rb -p mysqld will function without having to specify the entire path (/opt/sensu/embedded/bin/check-process.rb -p mysqld).

The other lines allow the sensu user to execute any check script as root.

Finally, start the sensu-client service and automatically start it at boot:

systemctl start sensu-client
systemctl enable sensu-client

If you have Uchiwa installed, the new client should appear in the list. If not, debug the sensu-client by inspecting the log file /var/log/sensu/sensu-client.log

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Cuberite on a CentOS 6 or 7 Server

Next Post

Creating a Network of Minecraft Servers With BungeeCord on Debian 8, Debian 9, or CentOS 7

Next Post

Creating a Network of Minecraft Servers With BungeeCord on Debian 8, Debian 9, or CentOS 7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet