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!