You can discover multiple hosts with Zabbix

Introduction to Monitoring with Zabbix #6 – Discovery Functions

In the last column, I discussed how you can use actions to perform tasks in response to events generated by triggers. Now let’s take a look at discovery functions that can be used to set up multiple hosts.

In the last column, I discussed how you can use actions to perform tasks in response to events generated by triggers. Now let’s take a look at discovery functions that can be used to set up multiple hosts.

Zabbix has four discovery functions, which are as follows:

  1. Network discovery (search for hosts in a specified network)
  2. Active agent auto-registration (register an active Zabbix agent)
  3. Low-level discovery (search for a host’s disk network, etc.)
  4. Virtual machine discovery (search for virtual machines on a host)

Network discovery

The network discovery function automatically detects monitoring targets in a specified network. This makes it easy to add or delete hosts in an environment where the number of hosts is liable to fluctuate.

In network discovery, monitoring targets are added or deleted based on the following criteria.

  1. If they are hosted at an address within the specified network range
  2. If they share external services (ftp.SSH, Web, POP3, IMAP, TCP etc. )
  3. If information is received from a Zabbix agent (non-active agent mode)
  4. If information is received from an SNMP agent

Network discovery events

When the network discovery function detects the addition or deletion of a monitoring target, Zabbix generates the following events:

  1. Service Discovered
    When a service is discovered and registered as a host for the first time
  2. Service Up
    When a service starts
  3. Service Lost
    When an active service has stopped
  4. Service Down
    When a service has stopped continuously
  5. Host Discovered
    When one of the following conditions has been met:
    • One or more services have been detected while all host services were stopped.
    • A service from an unregistered host has been detected
  6. Host Up
    When one or more services have started on a host
  7. Host Lost
    When all services have stopped on a host that was active
  8. Host Down
    When the Host Lost status becomes continuous

Network discovery actions

When these events occur, you can perform the following actions:

  1. Send notifications
  2. Add/remove a host
  3. Enable/disable a host
  4. Add a host to group
  5. Remove a host from group
  6. Link or unlink a host to/from a template
  7. Execute a remote script

These actions can include settings such as the device type, IP, status, and uptime/downtime.

Network discovery use case

By using a combination of network discovery functions, it is possible to perform operations such as the following:

  • When a host is detected in the specified IP address range, register it to Zabbix
  • Apply an http service template to a host when an http service is detected (and automatically register it if the host is not registered)
  • Register the host in a DB dedicated host group when a MySQL service is detected (and automatically register it if the host is not registered)
  • Register equipment to Zabbix when an SNMP service is detected
  • Temporarily remove inactive hosts from Zabbix

Active agent auto-registration

Active agent auto-registration is a function whereby a Zabbix agent can register itself to a Zabbix server.By using this function, a Zabbix server is able to monitor hosts that are frequently added or deleted in a cloud environment (such as IaaS).

To enable this function, you need to configure the Zabbix agent and Zabbix server.

—Zabbix agent
The Active agent function of a Zabbix agent can be activated as follows:

  1. Set the Zabbix server IP address as the ServerActive parameter in the zabbix_agentd.conf configuration file (e. g., `ServerActive = 10.0.0.1 `)
  2. Set the metadata (host name, OS, service name, etc. ) as required
  3. Restart the Zabbix agent

— Zabbix server
Add an action to be performed when a host is registered.

  1. Add an action to the Zabbix action settings
  2. Select Auto registration as the event source
  3. If HostMetadata is available, perform the corresponding operation (register in host group, specify host name, add template, etc. ).
  4. If the host name is not specified, use the host name set in the target host system

By using active agent auto-registration, you can set the template corresponding to the OS/service when the Zabbix agent starts.

Low-level discovery

Low-level discovery is a mechanism for the automatic detection of hardware parameters that can differ from one host to the next. You can set your own detection rules for low-level discovery. Since detection rules are specified even in the template that is set by default, they can easily be used by applying the template. The hardware that can be detected is as follows:

— Acquire information about mounted file systems from the agent item (`vfs. fs. get`).

  • Name of mount point
  • Type of mount point
  • File system size
  • inode information

— Obtain NIC (network interface card) information from the agent item (`net. if. discovery`).

  • Network traffic input statistics
  • Network traffic output statistics
  • Total network traffic input/output statistics

— Obtain information such as the number of CPUs from the agent item (`system. cpu. discovery`).

  • CPU utilization rate per CPU (idle/user/system/iowait/interrupt etc. )
  • CPU clock frequency and maximum frequency per CPU
  • Obtain SNMP number detection by using discovery for OID in the SNMP agent item.

— Use the `snmpwalks` command to acquire each value under an OID by specifying the SNMP version, community name, and the OID to search

  • Can be used to obtain information such as the network switch NIC name, NIC traffic statistics, life/death monitoring, etc.

— Use the `jmx. discovery` JMX agent item to obtain the JMX MBean attribute or MBean attribute of a Java JMX object.

  • Use the JMX Mbean attribute to get devices, applications and resources that require management
  • Use the MBean attribute to obtain information such as the number of connections, number of threads, request timeout, http file cache, and memory usage
  • Use `db. odbc. discover` to obtain the results of executing SQL queries via ODBC.

— Monitor specific data on a DB

  • Check the status of a DB, etc.

— Use the `service. discovery` agent item to obtain Windows service information.

  • Service name
  • Service description
  • Service status etc.

Virtual Machine

VMware

It is possible to monitor VMware environments. Use low-level discovery to automatically discover VMware hypervisors and virtual machines. This detection is included in the default template.Supported VMware versions are VMware vCenter and vSphere version 4.1 or higher.

The following items can be monitored by this discovery function.

  • Number of VMware instances
  • VMware cache size
  • VM frequency
  • VMware perf frequency
  • Timeout

Docker

Zabbix can also monitor Docker. By using [Zabbix Docker Monitoring], made by [Monitoring Artist]/, it is possible to automatically collect information about Docker running on a host.

  • Container startup status
  • Container memory usage
  • Container CPU usage
  • Container block I/O utilization
  • Results of docker inspect
  • Result of docker info
  • systemd information

This Zabbix Docker Monitoring is published on Github. The published content also includes Docker monitoring templates. [Docker image for monitoring] (hub.docker.com/r/monitoringartist/dockbix-agent-xxl-limited/) is also published on Docker Hub, and the limited version can be used freely.

Conclusion

In this column, I introduced the discovery functions that can be used to set up multiple hosts. Next time, I will explain how to edit the monitoring screen in Zabbix.

Part 1

Part 2

Part 3

Part 4

Part 5

Satoru Miyazaki

PREVIOUS ARTICLE