Esta es una traducción de la página de documentación original en español. Ayúdanos a mejorarla.

7 Descubrimiento de los servicios systemd

Descripción general

Es posible descubrir unidades systemd (servicios, por defecto) con Zabbix.

Item key

The item to use in the discovery rule is the

systemd.unit.discovery

This item key is only supported in Zabbix agent 2.

This item returns a JSON with information about systemd units, for example:

[{
           "{#UNIT.NAME}": "mysqld.service",
           "{#UNIT.DESCRIPTION}": "MySQL Server",
           "{#UNIT.LOADSTATE}": "loaded",
           "{#UNIT.ACTIVESTATE}": "active",
           "{#UNIT.SUBSTATE}": "running",
           "{#UNIT.FOLLOWED}": "",
           "{#UNIT.PATH}": "/org/freedesktop/systemd1/unit/mysqld_2eservice",
           "{#UNIT.JOBID}": 0,
           "{#UNIT.JOBTYPE}": ""
           "{#UNIT.JOBPATH}": "/",
           "{#UNIT.UNITFILESTATE}": "enabled"
       }, {
           "{#UNIT.NAME}": "systemd-journald.socket",
           "{#UNIT.DESCRIPTION}": "Journal Socket",
           "{#UNIT.LOADSTATE}": "loaded",
           "{#UNIT.ACTIVESTATE}": "active",
           "{#UNIT.SUBSTATE}": "running",
           "{#UNIT.FOLLOWED}": "",
           "{#UNIT.PATH}": "/org/freedesktop/systemd1/unit/systemd_2djournald_2esocket",
           "{#UNIT.JOBID}": 0,
           "{#UNIT.JOBTYPE}": "",
           "{#UNIT.JOBPATH}": "/"
           "{#UNIT.UNITFILESTATE}": "enabled"
       }]
Descubrimiento de unidades systemd deshabilitadas

Desde Zabbix 6.0.1 también es posible descubrir unidades systemd deshabilitadas. En este caso se devuelven tres macros en el JSON resultante:

  • {#UNIT.PATH}
  • {#UNIT.ACTIVESTATE}
  • {#UNIT.UNITFILESTATE}.

Para crear métricas e iniciadores a partir de prototipos para unidades systemd deshabilitadas, asegúrese de ajustar (o eliminar) la prohibición de filtros LLD para {#UNIT.ACTIVESTATE} y {#UNIT.UNITFILESTATE}.

Supported macros

The following macros are supported for use in the discovery rule filter and prototypes of items, triggers and graphs:

Macro Description
{#UNIT.NAME} Primary unit name.
{#UNIT.DESCRIPTION} Human readable description.
{#UNIT.LOADSTATE} Load state (i.e. whether the unit file has been loaded successfully)
{#UNIT.ACTIVESTATE} Active state (i.e. whether the unit is currently started or not)
{#UNIT.SUBSTATE} Sub state (a more fine-grained version of the active state that is specific to the unit type, which the active state is not)
{#UNIT.FOLLOWED} Unit that is being followed in its state by this unit, if there is any; otherwise an empty string.
{#UNIT.PATH} Unit object path.
{#UNIT.JOBID} Numeric job ID if there is a job queued for the job unit; 0 otherwise.
{#UNIT.JOBTYPE} Job type.
{#UNIT.JOBPATH} Job object path.
{#UNIT.UNITFILESTATE} The install state of the unit file.

Prototipos de métricas

Los prototipos de métricas que se pueden crear basándose en el descubrimiento de servicios systemd incluyen, por ejemplo:

  • Nombre de la métrica: {#UNIT.DESCRIPTION} información de estado activo; clave de la métrica: systemd.unit.info["{#UNIT.NAME}"]
  • Nombre de la métrica: {#UNIT.DESCRIPTION} información del estado de carga; clave de la métrica: systemd.unit.info["{#UNIT.NAME}",LoadState]

Las métricas de agente systemd.unit.info están soportadas desde Zabbix 4.4.