This is a translation of the original English documentation page. Help us make it better.


Zabbix Summit 2022
Register for Zabbix Summit 2022

5 Paramètres utilisateurs


Sometimes you may want to run an agent check that does not come predefined with Zabbix. This is where user parameters come to help.

You may write a command that retrieves the data you need and include it in the user parameter in the agent configuration file ('UserParameter' configuration parameter).

A user parameter has the following syntax:


As you can see, a user parameter also contains a key. The key will be necessary when configuring an item. Enter a key of your choice that will be easy to reference (it must be unique within a host). Restart the agent.

Then, when configuring an item, enter the key to reference the command from the user parameter you want executed.

User parameters are commands executed by Zabbix agent. Up to 512KB of data can be returned before item preprocessing steps. Note, however, that the text value that can be eventually stored in database is limited to 64KB on MySQL (see info on other databases in the table).

/bin/sh is used as a command line interpreter under UNIX operating systems. User parameters obey the agent check timeout; if timeout is reached the forked user parameter process is terminated.

See also:

Exemples de paramètres utilisateur simples

Une commande simple :

UserParameter=ping,echo 1

L'agent renverra toujours '1' pour une élément avec la clé 'ping'.

Un exemple plus complexe :,mysqladmin -uroot ping | grep -c alive

L'agent renverra '1', si le serveur MySQL est actif, '0' - sinon.

Flexible user parameters

Flexible user parameters accept parameters with the key. This way a flexible user parameter can be the basis for creating several items.

Flexible user parameters have the following syntax:

Parameter Description
Key Unique item key. The [*] defines that this key accepts parameters within the brackets.
Parameters are given when configuring the item.
Command Command to be executed to evaluate value of the key.
For flexible user parameters only:
You may use positional references $1…$9 in the command to refer to the respective parameter in the item key.
Zabbix parses the parameters enclosed in [ ] of the item key and substitutes $1,...,$9 in the command accordingly.
$0 will be substituted by the original command (prior to expansion of $0,...,$9) to be run.
Positional references are interpreted regardless of whether they are enclosed between double (") or single (') quotes.
To use positional references unaltered, specify a double dollar sign - for example, awk '{print $$2}'. In this case $$2 will actually turn into $2 when executing the command.

Positional references with the $ sign are searched for and replaced by Zabbix agent only for flexible user parameters. For simple user parameters, such reference processing is skipped and, therefore, any $ sign quoting is not necessary.

Certain symbols are not allowed in user parameters by default. See UnsafeUserParameters documentation for a full list.

Exemple 1

Quelque chose de très simple :

UserParameter=ping[*],echo $1

Nous pouvons définir un nombre illimité d'éléments pour la surveillance de tous les formats ping[quelque chose].

  • ping[0] - retournera toujours '0'
  • ping[aaa] - retournera toujours 'aaa'
Exemple 2

Ajoutons un peu de sens ![*],mysqladmin -u$1 -p$2 ping | grep -c alive

Ce paramètre peut être utilisé pour superviser la disponibilité de la base de données MySQL. Nous pouvons passer le nom d'utilisateur et le mot de passe :[zabbix,our_password]
Exemple 3

Combien de lignes correspondent à une expression régulière dans un fichier ?

UserParameter=wc[*],grep -c "$2" $1

Ce paramètre peut être utilisé pour calculer le nombre de ligne dans un fichier.


Résultat de la commande

La valeur de retour de la commande est la sortie standard avec l'erreur standard.

Un élément de texte (caractère, journal ou information de type texte) ne deviendra pas non supporté en cas de sortie d'erreur standard.

Les paramètres utilisateurs qui revoient du texte (caractère, journal ou information de type texte) peuvent renvoyer des espaces. En cas de retour incorrect, l'élément deviendra non supporté.