Adding different host and its services

Is it possible to monitor Windows and Linux machines without deploying an agent? If so, please provide details on the approach. Additionally, do we need to configure any settings on the host side, or can Icinga automatically detect and monitor key metrics such as CPU load, disk space, and memory usage through additional configuration on the Icinga server?

Yes and no.
If you use SSH then this is the agent.
If you use SNMP then this is the agent.
If you use WinRM then this is the agent.

But yes, you can monitor without the icinga2 agent.

Icinga doesn’t do anything if it wan’t told to do so.
To me it’s not a monitoring solution but a monitoring framework in which I can implement my ideal monitoring.

I would recommend the icinga2 agent with the monitoring plugins from the Linuxfabrik. This Plugin collection comes with service sets that would provide you with some defaults like CPU load, disk space, RAM, std. services of the OS etc.

You could also run thinly wrapped checks via cronjob, systemd timer or scheduled tasks and send the results via Icinga2 API (passive checks) from the wrapper. To make this scale, would require some sort of config management like Ansible to create the hosts and services in Icinga, deploy the wrapped checks and schedules them.

yes, it is possible to monitor Windows and Linux machines without deploying an agent by using agentless monitoring techniques in Icinga.

Agentless Monitoring Approaches in Icinga

Icinga can monitor remote machines without an agent using standard network protocols like SNMP, SSH.

Monitoring a Linux Server Using check_by_ssh in Icinga 2

If you want to monitor a Linux server without installing an agent, you can use check_by_ssh, which allows Icinga to execute commands remotely via SSH. Below is a step-by-step guide:

1. Prerequisites

  • Ensure SSH is enabled and running on the target Linux server (systemctl status sshd).
  • The Icinga 2 server must have SSH access to the target machine.
  • A dedicated user (e.g., icinga) should be created on the remote server with restricted privileges.

2. Set Up SSH Key-Based Authentication

On the Icinga server, generate an SSH key if you haven’t already:

ssh-keygen -t rsa -b 4096

Copy the public key to the remote server:

ssh-copy-id icinga@<remote_host>

Test the connection:

ssh icinga@<remote_host> uptime

3. Install check_by_ssh Plugin

Ensure the plugin is installed on your Icinga server:

apt install nagios-plugins -y   # Debian/Ubuntu  
yum install nagios-plugins-ssh -y   # CentOS/RHEL  

4. Define the Service in Icinga 2

Edit the configuration file (e.g., /etc/icinga2/conf.d/services.conf):

apply Service "CPU Load" {
  import "generic-service"
  check_command = "by_ssh"
  
  vars.by_ssh_host = host.address
  vars.by_ssh_command = "uptime | awk '{print $10}'"
  vars.by_ssh_logname = "icinga"
  
  assign where host.vars.os == "Linux"
}

5. Restart Icinga 2

Apply the changes:

systemctl restart icinga2

6. Test the Check

Run the command manually to verify:

/usr/lib/nagios/plugins/check_by_ssh -H <remote_host> -l icinga -C "uptime"

References

Hope this helps! Let me know if you need further clarification. :blush: