Define custom agent keys to collect custom metrics by executing scripts or commands with Zabbix user parameters.
Having a simple way to extend the metric collection functionality of a monitoring tool can be vital if we wish to monitor custom in-house software or simply collect metrics not available out of the box.
Collect custom metrics with Zabbix agent by defining user parameters:
- Define an unlimited number of user parameters for your Zabbix agents
- Parameters such as usernames and passwords can be passed to flexible user parameters
- User parameters support Zabbix agent data collection in active and passive modes
- User parameters can collect bulk data for further processing by dependent items
Check out the video to learn how to define user parameters for Zabbix agents.
Define user parameters for Zabbix agents:
- Test your custom command on the host on which you will create the user parameter
- Open the Zabbix agent configuration file in a text editor
- A simple user parameter can be defined by adding the line: UserParameter=key,command
- A flexible user parameter can be defined by adding the line: UserParameter=key[*],command
- For flexible user parameters, use $1…$9 positional references to reference your custom key parameters
- Save the changes
- Reload user parameters by using the command zabbix_agentd -R userparameter_reload
- Open the Zabbix frontend and navigate to Configuration → Hosts
- Find your host and click on the Items button next to the host
- Press the Create item button
- Give your item a name and select the item type – Zabbix agent or Zabbix agent (active)
- Provide the key that you defined as your user parameter key
- For flexible user parameters, provide the key parameters
- Press the Test button and then press Get value and test to test your user parameter
- Press the Add button to add the item
Tips and best practices
- User parameter commands need to be executed within the Zabbix agent Timeout parameter value
- User parameters can be reloaded by executing the zabbix_agentd -R userparameter_reload command
- User parameters can be defined in the Zabbix agent configuration file, or the files specified by the Include parameter
- By default, certain symbols are not permitted to be used in user parameters
- The usage of restricted characters can be permitted by setting the value of UnsafeUserParameters parameter to 1
Learn how to leverage the many types of data collection provided by Zabbix and empower your data collection and processing. Sign up for our Zabbix Certified Specialist course, where under the guidance of a Zabbix certified trainer you will learn more about different types and technologies of monitoring and learn how to get the most out of your Zabbix instance.