Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

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 a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

icinga: Commands

Rajesh Kumar I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at…

Read More

icinga: icinga object types

In Icinga2, “objects” are fundamental components that represent various elements and configurations within the monitoring environment. They form the core building blocks of the Icinga2 configuration system….

Read More

icinga2: How to install icinga2 plugins in Linux?

Rajesh Kumar I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at…

Read More

icinga2: How to enable Api in icinga?

In this example: Available permissions for specific URL endpoints: The permissions field in the ApiUser object specifies what the API user is allowed to do. You can…

Read More

icinga2: How to install icinga modules?

Rajesh Kumar I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at Cotocus. I share tech blog at DevOps School, travel stories at…

Read More

icinga: Step by Step installing Icinga Director in ubuntu

Installing Icinga Director on an Ubuntu system involves several steps, primarily focused on ensuring that your system meets the prerequisites, installing Icinga Director, and integrating it with…

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