Install Sensu Agent on Ubuntu/Debian

0
10

This guide will take you through how to install Sensu agent on Ubuntu/Debian systems. We are using Ubuntu 22.04 and Debian 11 specifically on this setup to install Sensu agents.

Install Sensu Agent on Ubuntu/Debian

In order to start collecting remote system metrics for monitoring using Sensu Go server, you need to install Sensu agents on the hosts being monitored.

Install Sensu agent on Debian

To install Sensu agent on Debian;

  • Install Sensu APT repository;
curl -s https://packagecloud.io/install/repositories/sensu/stable/script.deb.sh | sudo bash
  • Install Sensu Agent on Debian 11

Once the repository is installed, ran the command below to install Sensu agent on Debian 11;

sudo apt install sensu-go-agent

Install Sensu agent on Ubuntu 22.04

To install Sensu agent on Ubuntu;

  • Install Sensu APT repository;
curl -s https://packagecloud.io/install/repositories/sensu/stable/script.deb.sh | sudo bash

For Ubuntu 22.04, you need to use the repository for Ubuntu 20.04 since there is no Sensu APT repos for Ubuntu 22.04 as of this writing.

wget https://packagecloud.io/install/repositories/sensu/stable/script.deb.sh
os=ubuntu dist=focal bash ./script.deb.sh
  • Install Sensu Agent on Ubuntu

Once the repository is installed, ran the command below to install Sensu agent on Ubuntu;

sudo apt install sensu-go-agent

Configure and Run Sensu Agent

You can run Sensu agent with or without defining a configuration file.

To run without defining a configuration file, use the command below

sudo -u sensu sensu-agent start --backend-url <sensu-server-web-socket-url>

Sensu backend web socket listens on port 8081. Ensure this port is opened on the server to allow agents to connect. The protocol is WS or WSS.

sudo -u sensu sensu-agent start --backend-url ws://127.0.0.1:8081

or

sudo -u sensu sensu-agent start --backend-url ws://192.168.56.124:8081

To run Sensu agent with a configuration file, download and install the sample configuration;

sudo curl -sL https://docs.sensu.io/sensu-go/latest/files/agent.yml -o /etc/sensu/agent.yml

This is how sample config looks like;

---
# Sensu agent configuration


##
# agent configuration
##
#name: "hostname"
#namespace: "default"
#subscriptions:
#  - example
#labels:
#  example_key: "example value"
#annotations:
#  example/key: "example value"
#agent-managed-entity: false
#allow-list: /etc/sensu/check-allow-list.yaml
#assets-burst-limit: 100
#assets-rate-limit: 1.39
#backend-handshake-timeout: 15
#backend-heartbeat-interval: 30
#backend-heartbeat-timeout: 45
#backend-url:
#  - "ws://127.0.0.1:8081"
#cache-dir: "/var/cache/sensu/sensu-agent"
#config-file: "/etc/sensu/agent.yml"
#deregister: false
#deregistration-handler: "example_handler"
#detect-cloud-provider: false
#disable-assets: false
#keepalive-critical-timeout: 0
#keepalive-handlers:
#  - slack
#  - email
#keepalive-interval: 20
#keepalive-warning-timeout: 120
log-level: "debug" # available log levels: panic, fatal, error, warn, info, debug
#user: "agent"
#password: "[email protected]!"
#redact:
#  - password
#  - passwd
#  - pass
#  - api_key
#  - api_token
#  - access_key
#  - secret_key
#  - private_key
#  - secret
#require-fips: false
#require-openssl: false


##
# api configuration
##
#api-host: "127.0.0.1"
#api-port: 3031
#disable-api: false
#events-burst-limit: 10
#events-rate-limit: 10.0


##
# socket configuration
##
#socket-host: "127.0.0.1"
#socket-port: 3030
#disable-sockets: false


##
# statsd configuration
##
#statsd-disable: false
#statsd-event-handlers:
#  - example_handler
#statsd-flush-interval: 10
#statsd-metrics-host: "127.0.0.1"
#statsd-metrics-port: 8125


##
# tls configuration
##
#cert-file: "/path/to/tls/agent.pem"
#trusted-ca-file: "/path/to/tls/ca.pem"
#key-file: "/path/to/tls/agent-key.pem"
#insecure-skip-tls-verify: false

The default Sensu backend URL is ws://127.0.0.1:8081.

If you are using a remove Sensu backend;

sudo vim /etc/sensu/agent.yml

update the backend url from;

#backend-url:
#  - "ws://127.0.0.1:8081"

To (replace <sensu-backend-IP> with Sensu backend IP address);

backend-url:
  - "ws://<sensu-backend-IP>:8081"

At the very least, Sensu agent just requires the backend url to be defined.

Next, start and enable the Sensu agent service to run on system boot;

sudo systemctl enable --now sensu-agent

Check the Status;

systemctl status sensu-agent
● sensu-agent.service - The Sensu Agent process.
     Loaded: loaded (/lib/systemd/system/sensu-agent.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-05-07 01:17:26 EAT; 3s ago
   Main PID: 4246 (sensu-agent)
      Tasks: 7 (limit: 1133)
     Memory: 8.3M
        CPU: 62ms
     CGroup: /system.slice/sensu-agent.service
             └─4246 /usr/sbin/sensu-agent start -c /etc/sensu/agent.yml

May 07 01:17:27 debian11 sensu-agent[4246]: {"component":"agent","header":"Accept: application/octet-stream","level":"debug","msg":"setting header","time":"2022-05-07T01:1>
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","level":"info","msg":"successfully connected","time":"2022-05-07T01:17:28+03:00"}
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","header":"Accept: [application/octet-stream application/json]","level":"debug","msg":"received header","ti>
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","format":"protobuf","level":"debug","msg":"setting serialization/deserialization","time":"2022-05-07T01:17>
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","header":"Content-Type: application/octet-stream","level":"debug","msg":"setting header","time":"2022-05-0>
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","level":"debug","msg":"maxSessionLength is 0s, agent won't periodically disconnect","time":"2022-05-07T01:>
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","content_type":"application/octet-stream","level":"info","msg":"message received","payload_size":143,"time>
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","level":"debug","msg":"received an entity config from the backend","time":"2022-05-07T01:17:28+03:00"}
May 07 01:17:28 debian11 sensu-agent[4246]: {"component":"agent","level":"debug","msg":"successfully received the initial entity config","time":"2022-05-07T01:17:28+03:00"}
May 07 01:17:28 debian11 sensu-agent[4246]: {"check":"keepalive","component":"agent","entity":"debian11","event_uuid":"14a4c0f8-301c-4fe2-9db3-119c8a53274a","level":"info

In case of any issue, check the logs using journalctl command;

journalctl -u sensu-agent

Very Sensu Agents Connectivity with Sensu Backend Server

Login back to Sensu backend and confirm the status of the agents.

Install Sensu Agent on Ubuntu/Debian

You can click on any of the Entities to view more details;

Install Sensu Agent on Ubuntu/Debian

And that is how you can easily install Sensu Agent on Ubuntu/Debian.

Next, follow the guide below to learn how to monitor Linux system metrics using Sensu.

How to Monitor Linux System Metrics using Sensu

Reference

Install Sensu

Other Tutorials;

Install Nagios NRPE Agents on Ubuntu 22.04/Ubuntu 20.04

Install and Enroll Elastic Agents to Fleet Manager in Linux

Install Wazuh Agent on Rocky Linux 8

LEAVE A REPLY

Please enter your comment!
Please enter your name here