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.
Latest posts by Rajesh Kumar (see all)
- Installing Jupyter: Get up and running on your computer - November 2, 2024
- An Introduction of SymOps by SymOps.com - October 30, 2024
- Introduction to System Operations (SymOps) - October 30, 2024