MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

icinga: How to add new remote server check in icinga2 with SSH Protocol

To add a new remote server for monitoring in Icinga 2 using SSH checks, you'll need to configure SSH access between your Icinga 2 master server and the remote server, and then set up the necessary check commands to execute monitoring tasks over SSH. Here’s a detailed step-by-step guide on how to do it:

Step 1: Set Up SSH Key Authentication
Generate SSH Key on the Master Server:
If you do not already have an SSH key, generate one on your Icinga 2 master server:

ssh-keygen -t rsa -b 2048
Follow the prompts, and choose a secure location to save the key (if not using the default).
Copy the SSH Public Key to the Remote Server:
Use ssh-copy-id to copy the public key to the remote server. This enables passwordless SSH access:

ssh-copy-id -i ~/.ssh/id_rsa.pub your-username@remote-server-ip
Replace your-username with the appropriate user on the remote server that has the necessary permissions to execute monitoring plugins.

Step 2: Install Necessary Plugins on the Remote Server
Install Monitoring Plugins:
Ensure that the necessary monitoring plugins are installed on the remote server. These are typically available in the monitoring-plugins package:

sudo apt-get install monitoring-plugins

Step 3: Configure Icinga 2 for SSH Checks
Define Check Commands:
Define a new check command on the master server to perform checks over SSH. Edit your commands configuration file (e.g., /etc/icinga2/conf.d/commands.conf):

object CheckCommand "ssh-disk" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_by_ssh" ]

  arguments = {
    "-H" = "$address$"
    "-C" = "$ssh_command$"
    "-l" = "$user$"
    "-i" = "$ssh_identity_file$"
  }

  vars.user = "your-username"
  vars.ssh_identity_file = "/home/your-username/.ssh/id_rsa"
  vars.ssh_command = "/usr/lib/nagios/plugins/check_disk -w 20% -c 10%"
}
Adjust vars.ssh_command with the appropriate monitoring command and thresholds.

Step 4: Configure Host and Service Objects
Add the Remote Host:
Define the remote server in your host configuration file (e.g., /etc/icinga2/conf.d/hosts.conf):

object Host "remote-server" {
  import "generic-host"
  address = "remote-server-ip"
  check_command = "hostalive"
  vars.os = "Linux"
}
Add Services Using SSH Checks:
Define a service that uses the SSH check command in your services configuration file (e.g., /etc/icinga2/conf.d/services.conf):

apply Service "ssh-disk-check" {
  import "generic-service"
  check_command = "ssh-disk"
  assign where host.name == "remote-server"
}

Step 5: Reload Icinga 2 Configuration
Check Configuration for Errors:
Before reloading the service, check the configuration for any errors:

sudo icinga2 daemon -C
Reload Icinga 2:
If there are no configuration errors, reload Icinga 2 to apply changes:

sudo systemctl reload icinga2
Step 6: Verify and Monitor
Verify Operation:
Log into Icinga Web 2 and check that the new service is reporting correctly.
Ensure that the SSH checks are returning the expected results.
By following these steps, you will successfully add a new remote server to your Icinga 2 monitoring setup using SSH checks. This method is beneficial when you cannot install the Icinga 2 agent on a remote server but still have SSH access.Code language: PHP (php)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

How to login linux server using ssh?

You log in to a Linux server over SSH by running ssh username@server-ip from an SSH client, then proving who you are with either a password or…

Read More

Wetty – How to Install & Access Wetty (Web-based SSH) on AWS EC2 linux to access using browser

Wetty is a web-based terminal. It runs a small Node.js server that opens an SSH session and streams it to your browser over WebSockets, so you can…

Read More

Complete Tutorial: Use Two GitHub Accounts on One Mac with SSH

This tutorial explains how to configure two GitHub accounts on the same MacBook using separate SSH keys, without repeatedly switching accounts or breaking your existing Git configuration….

Read More

Development Workflows with an FTP and SFTP Client for Mac: From Local Files to Staging

An FTP and SFTP client for Mac is best suited when it displays the project that you are working on in one window and the remote server…

Read More

Linux Commands and Shell Scripting Reference for Linux Admins and DevOps Engineers

A structured Linux command and shell scripting reference for operations and DevOps work, rebuilt from the original link collection. It includes a practical learning workflow, command comparison tables, ready-to-use examples, and curated source links.

Read More

How to Install Nagios XI from Tarball and Set Up Client Monitoring Paths

This revised guide walks through a practical Nagios XI server installation using the tarball/fullinstall method from the original post, then shows how to validate access and plan client monitoring. It also adds a clear workflow diagram, command examples, and a comparison of common client check methods.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x