admin管理员组文章数量:1335595
I’m trying to monitor HTTP requests to my FastAPI application running on port 5000 using a custom UserParameter in Zabbix. The script works perfectly when tested manually or with zabbix_agentd -t, returning the expected number of HTTP requests. However, in the Zabbix frontend, the value is always 0, and it doesn’t seem to update correctly at the specified interval.
Zabbix Configuration Here is the relevant UserParameter section in my /etc/zabbix/zabbix_agentd.conf:
UserParameter=http.requests,/usr/local/bin/count_http_requests.sh
Script Content The script used for the UserParameter (/usr/local/bin/count_http_requests.sh) is as follows:
#!/bin/bash
sudo timeout 10 tcpdump -i any port 5000 -A 2>/dev/null | grep -c 'GET /'
What Works Running the script directly:
/usr/local/bin/count_http_requests.sh
This returns the correct count of HTTP GET requests.
Testing with zabbix_agentd:
sudo zabbix_agentd -t http.requests
http.requests [t|18]
What Doesn't Work On the Zabbix frontend, the value for http.requests is always 0, even though the agent and script appear to work correctly. Configurations in the Frontend
Key: http.requests
Type: Zabbix Agent
Update Interval: 10 seconds
Timeout: 15 seconds
Type of Information: Numeric (unsigned)
Confirmed the zabbix user can execute the script:
$ ls -l /usr/local/bin/count_http_requests.sh
-rwxr-xr-x. 1 zabbix zabbix 86 Nov 19 22:38 /usr/local/bin/count_http_requests.sh
Increased timeout: Set Timeout=15 in /etc/zabbix/zabbix_agentd.conf and adjusted the frontend timeout.
Checked logs: No errors in /var/log/zabbix/zabbix_agentd.log or /var/log/zabbix/zabbix_server.log.
Verified item updates: Forced manual updates in the frontend, but the value remains 0.
What I Need Help With Why is the Zabbix frontend showing 0 for this item, even though the script and agent tests return the correct value? How can I ensure that the frontend correctly reflects the number of HTTP requests based on the 10-second execution interval? Any guidance or suggestions would be greatly appreciated!
本文标签:
版权声明:本文标题:Zabbix UserParameter script always returns 0 on frontend despite correct execution in agent tests - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742393257a2466410.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论