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:
- Network discovery (search for hosts in a specified network)
- Active agent auto-registration (register an active Zabbix agent)
- Low-level discovery (search for a host’s disk network, etc.)
- Virtual machine discovery (search for virtual machines on a host)
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.
- If they are hosted at an address within the specified network range
- If they share external services (ftp.SSH, Web, POP3, IMAP, TCP etc. )
- If information is received from a Zabbix agent (non-active agent mode)
- 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:
- Service Discovered
When a service is discovered and registered as a host for the first time
- Service Up
When a service starts
- Service Lost
When an active service has stopped
- Service Down
When a service has stopped continuously
- 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
- Host Up
When one or more services have started on a host
- Host Lost
When all services have stopped on a host that was active
- Host Down
When the Host Lost status becomes continuous
Network discovery actions
When these events occur, you can perform the following actions:
- Send notifications
- Add/remove a host
- Enable/disable a host
- Add a host to group
- Remove a host from group
- Link or unlink a host to/from a template
- 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.
The Active agent function of a Zabbix agent can be activated as follows:
- Set the Zabbix server IP address as the ServerActive parameter in the zabbix_agentd.conf configuration file (e. g., `ServerActive = 10.0.0.1 `)
- Set the metadata (host name, OS, service name, etc. ) as required
- Restart the Zabbix agent
— Zabbix server
Add an action to be performed when a host is registered.
- Add an action to the Zabbix action settings
- Select Auto registration as the event source
- If HostMetadata is available, perform the corresponding operation (register in host group, specify host name, add template, etc. ).
- 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 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.
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
- 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.
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.