Ошибка метрик Zabbix: Not supported – Unsupported item key

Задача:
---------------------------------------------------------------Исправить ошибку мониторинга заббикс: Not supported – Unsupported item key
В статье “Мониторинг скорости интернет канала в Zabbix” я настраивал мониторинг пропускной способности интернет канала. Сегодня заметил, что мониторинг показывает ошибку

Если открыть “Configuration > Hosts”, видно что агент активен.

Открывает “Items” заббикс сервера, где был реализовал мониторинг скорости интернета

Авторизуемся на сервере по SSH и проверяем логи агента:
[root@appliance zabbix]# cat /var/log/zabbix/zabbix_agentd.log 3303:20210411:094314.602 Got signal [signal:15(SIGTERM),sender_pid:92074,sender_uid:996,reason:0]. Exiting ... 3303:20210411:094314.603 Zabbix Agent stopped. Zabbix 5.2.6 (revision 798506596c). 92078:20210411:094314.614 Starting Zabbix Agent [Zabbix server]. Zabbix 5.2.6 (revision 798506596c). 92078:20210411:094314.614 **** Enabled features **** 92078:20210411:094314.614 IPv6 support: YES 92078:20210411:094314.614 TLS support: YES 92078:20210411:094314.614 ************************** 92078:20210411:094314.614 using configuration file: /etc/zabbix/zabbix_agentd.conf 92078:20210411:094314.614 agent #0 started [main process] 92079:20210411:094314.614 agent #1 started [collector] 92080:20210411:094314.615 agent #2 started [listener #1] 92083:20210411:094314.615 agent #5 started [active checks #1] 92081:20210411:094314.616 agent #3 started [listener #2] 92082:20210411:094314.616 agent #4 started [listener #3] 92078:20210411:110518.728 Got signal [signal:15(SIGTERM),sender_pid:92781,sender_uid:996,reason:0]. Exiting ... 92078:20210411:110518.730 Zabbix Agent stopped. Zabbix 5.2.6 (revision 798506596c). 1072:20210411:110534.603 Starting Zabbix Agent [Zabbix server]. Zabbix 5.2.6 (revision 798506596c). 1072:20210411:110534.604 **** Enabled features **** 1072:20210411:110534.604 IPv6 support: YES 1072:20210411:110534.604 TLS support: YES 1072:20210411:110534.604 ************************** 1072:20210411:110534.604 using configuration file: /etc/zabbix/zabbix_agentd.conf 1072:20210411:110534.604 agent #0 started [main process] 1074:20210411:110534.605 agent #2 started [listener #1] 1073:20210411:110534.605 agent #1 started [collector] 1075:20210411:110534.606 agent #3 started [listener #2] 1077:20210411:110534.606 agent #5 started [active checks #1] 1076:20210411:110534.609 agent #4 started [listener #3] 1077:20210411:110534.609 active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to [[127.0.0.1]:10051]: [111] Connection refused) 1077:20210411:110634.619 active check configuration update from [127.0.0.1:10051] is working again zabbix_agentd [1688]: Is this process already running? Could not lock PID file [/var/run/zabbix/zabbix_agentd.pid]: [11] Resource temporarily unavailable [root@appliance zabbix]#
Из логов видно, что порт TCP 10051 не доступен и пид процесса не может залочить так как уже он существует. С помощью netstat проверяем активные соединения на сервере
[root@appliance zabbix]# netstat -tulpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1144/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1052/sshd tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1083/zabbix_agentd tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1247/zabbix_server tcp6 0 0 :::3306 :::* LISTEN 1143/mysqld tcp6 0 0 :::22 :::* LISTEN 1052/sshd tcp6 0 0 :::3000 :::* LISTEN 1244/grafana-server tcp6 0 0 :::10050 :::* LISTEN 1083/zabbix_agentd tcp6 0 0 :::10051 :::* LISTEN 1247/zabbix_server tcp6 0 0 :::33060 :::* LISTEN 1143/mysqld tcp6 0 0 127.0.0.1:10052 :::* LISTEN 1063/java udp 0 0 0.0.0.0:68 0.0.0.0:* 989/dhclient udp 0 0 127.0.0.1:323 0.0.0.0:* 774/chronyd udp6 0 0 ::1:323 :::* 774/chronyd [root@appliance zabbix]#
Если netstat не установлен, можно установить следующей командой
yum install net-tools -y
Проверяем содержимое конфига агента заббикс
[root@appliance zabbix]# grep -v '^#' /etc/zabbix/zabbix_agentd.conf | grep -v '^$' PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 AllowKey=system.run[*] DenyKey=* Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server Include=/etc/zabbix/zabbix_agentd.d/*.conf UserParameter=upload[*],cat /tmp/speedtest.txt | grep Upload | sed 's/ //g' | cut -d ':' -f2 | grep -o '^[^M]*' UserParameter=download[*],cat /tmp/speedtest.txt | grep Download | sed 's/ //g' | cut -d ':' -f2 | grep -o '^[^M]*' [root@appliance zabbix]#
Пояснения параметров команды grep
^ обозначаем начало строки # ищем символ комментирования, следующий за началом строки | передаём вывода первой команды на обработку второй $ обозначаем конец строки
Есть способ уложить всё в одну команду, использую команду egrep
[root@appliance zabbix]# egrep -v '^#|^$' zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 AllowKey=system.run[*] DenyKey=* Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server Include=/etc/zabbix/zabbix_agentd.d/*.conf UserParameter=upload[*],cat /tmp/speedtest.txt | grep Upload | sed 's/ //g' | cut -d ':' -f2 | grep -o '^[^M]*' UserParameter=download[*],cat /tmp/speedtest.txt | grep Download | sed 's/ //g' | cut -d ':' -f2 | grep -o '^[^M]*' [root@appliance zabbix]#
Проверяем работу агента при помощи zabbix_get
[root@appliance zabbix]# zabbix_get -s 127.0.0.1 -p10050 -k upload ZBX_NOTSUPPORTED: Unsupported item key. [root@appliance zabbix]# zabbix_get -s 127.0.0.1 -p10050 -k download ZBX_NOTSUPPORTED: Unsupported item key. [root@appliance zabbix]# zabbix_get -s 127.0.0.1 -p10050 -k agent.hostname ZBX_NOTSUPPORTED: Unsupported item key. [root@appliance zabbix]#
На всякий случай проверяем версию агента
[root@appliance ~]# zabbix_agentd -V zabbix_agentd (daemon) (Zabbix) 5.2.6 Revision 798506596c 29 March 2021, compilation time: Mar 29 2021 14:43:28 Copyright (C) 2021 Zabbix SIA License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it according to the license. There is NO WARRANTY, to the extent permitted by law. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/). Compiled with OpenSSL 1.1.1g FIPS 21 Apr 2020 Running with OpenSSL 1.1.1g FIPS 21 Apr 2020 [root@appliance ~]#
До Zabbix версии 5.0.2, в конфигурационном файле агента, для ограничения проверок, требовалось указывать EnableRemoteCommands=1. Начиная с Zabbix 5.0.2 этот параметр признан устаревшим, а для агента версии 2 не поддерживаемым.
В наем случаем ошибки возникли после написания статьи “Мониторинг срока действия сертификата веб-сайта в zabbix” в которой мы активировали два параметра
### Option: AllowKey # Allow execution of item keys matching pattern. # Multiple keys matching rules may be defined in combination with DenyKey. # Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. # Parameters are processed one by one according their appearance order. # If no AllowKey or DenyKey rules defined, all keys are allowed. # # Mandatory: no AllowKey=system.run[*] ### Option: DenyKey # Deny execution of items keys matching pattern. # Multiple keys matching rules may be defined in combination with AllowKey. # Key pattern is wildcard expression, which support "*" character to match any number of any characters in certain position. It might be used in both key name and key arguments. # Parameters are processed one by one according their appearance order. # If no AllowKey or DenyKey rules defined, all keys are allowed. # Unless another system.run[*] rule is specified DenyKey=system.run[*] is added by default. # # Mandatory: no # Default: # DenyKey=system.run[*] DenyKey=*
Комментируем параметры AllowKey и DenyKey и перезапускаем агента zabbix и проверяем снова при помощи zabbix_get
[root@appliance zabbix]# systemctl restart zabbix-agent [root@appliance zabbix]# zabbix_get -s 127.0.0.1 -p10050 -k download 67.32 [root@appliance zabbix]# zabbix_get -s 127.0.0.1 -p10050 -k upload 29.57 [root@appliance zabbix]# zabbix_get -s 127.0.0.1 -p10050 -k agent.hostname Zabbix server [root@appliance zabbix]#
Для решения проблемы я изменил конфигурационный файл агента и перезапустил службу
[root@appliance zabbix]# egrep -v '^#|^$' /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 DenyKey=vfs.file.contents[*passwd*] AllowKey=system.run[*] Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server Include=/etc/zabbix/zabbix_agentd.d/*.conf UserParameter=osbsd.upload[*],cat /tmp/speedtest.txt | grep Upload | sed 's/ //g' | cut -d ':' -f2 | grep -o '^[^M]*' UserParameter=osbsd.download[*],cat /tmp/speedtest.txt | grep Download | sed 's/ //g' | cut -d ':' -f2 | grep -o '^[^M]*' [root@appliance zabbix]# systemctl restart zabbix-agent [root@appliance zabbix]#
Свежие комментарии