Monitoring Applications and Services on Linux with Zabbix Agent
Zabbix application provides lots of templates to integrate those popular software into their monitoring system. https://www.zabbix.com/integrations privides the list and in this post, I will show a detailed steps regarding how to integrate some Linux popular services or applications into Zabbix.
MySQL
1. Install Zabbix agent and MySQL client. If necessary, add the path to the 'mysql' and 'mysqladmin' utilities to the global environment variable PATH.
2. Copy the 'template_db_mysql.conf' file with user parameters into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget to restart Zabbix agent.
3. Create the MySQL user that will be used for monitoring ('<password>' at your discretion). For example:
CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
For more information, please see MySQL documentation (https://dev.mysql.com/doc/refman/8.0/en/grant.html).
NOTE: In order to collect replication metrics, MariaDB Enterprise Server 10.5.8-5 and above and MariaDB Community Server 10.5.9 and above require the SLAVE MONITOR privilege to be set for the monitoring user:
GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW,SLAVE MONITOR ON *.* TO 'zbx_monitor'@'%';
For more information, please read the MariaDB documentation (https://mariadb.com/docs/server/ref/mdb/privileges/SLAVE_MONITOR/).
4. Create '.my.cnf' configuration file in the home directory of Zabbix agent for Linux distributions (/var/lib/zabbix by default) or 'my.cnf' in c:/ for Windows. For example:
[client]
protocol=tcp
user='zbx_monitor'
password='<password>'
For more information, please see MySQL documentation (https://dev.mysql.com/doc/refman/8.0/en/option-files.html).
NOTE: Linux distributions that use SELinux may require additional steps for access configuration.
You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384189-discussion-thread-for-official-zabbix-template-db-mysql
Generated by official Zabbix template tool "Templator"
This description of template also can be found from :
- https://www.zabbix.com/integrations/mysql
or Github page:
- https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent?at=refs%2Fheads%2Frelease%2F7.4
-
Specifies the hostname or IP address of the remote MySQL server.
-
Specifies the username to connect to the MySQL server. This user must have the necessary privileges on the remote server to perform the desired operations and must be configured to allow remote connections.
-
Specifies the password for the given username. Note that there is no space between
-pand the password. If you omit the password after-p,mysqladminwill prompt you for it interactively, which is generally more secure. -
This is the
mysqladmincommand you want to execute on the remote server, such asstatus,version,ping,shutdown, etc.
Monitor Services guacd
Make sure you have this line exactly in your Zabbix agent config file (/etc/zabbix/zabbix_agentd.conf):
textUserParameter=service.status.guacd,systemctl is-active guacd.service
-
Restart Zabbix agent
After editing the config, restart the agent to apply changes:
bashsudo systemctl restart zabbix-agent
-
Test the key locally
Run the key test on the monitored Linux host to make sure the agent can execute it properly:
bashzabbix_agentd -t service.status.guacd
You should see output like:
textservice.status.guacd [t|active]
| Step | Example |
|---|---|
| UserParameter | UserParameter=service.status.guacd,systemctl is-active guacd.service |
| Item key | service.status.guacd |
| Trigger expression | {hostname:service.status.guacd.str()}<>"active" |
| Process monitoring key | proc.num[guacd] |
CPU usage
Create item:
-
Name:
guacd: CPU usage -
Type: Zabbix agent
-
Key:
-
Units:
% -
Type of information: Float
Memory usage
Create item:
-
Name:
guacd: Memory usage -
Key:
-
Units:
B(orbytes) -
Type: Numeric
Process count
Troubleshooting
The "Unsupported item key" message for your service.status.guacd item means Zabbix agent does not recognize the key as configured. This usually happens when:
-
The UserParameter was not correctly added or the agent was not restarted.
-
The key was mistyped or not listed in the agent config.
-
The command in the UserParameter returns no output or errors.
Troubleshooting Steps
-
Verify UserParameter in agent config
Make sure you have this line exactly in your Zabbix agent config file (/etc/zabbix/zabbix_agentd.conf):
textUserParameter=service.status.guacd,systemctl is-active guacd.service
-
Restart Zabbix agent
After editing the config, restart the agent to apply changes:
bashsudo systemctl restart zabbix-agent
-
Test the key locally
Run the key test on the monitored Linux host to make sure the agent can execute it properly:
bashzabbix_agentd -t service.status.guacd
You should see output like:
textservice.status.guacd [t|active]
If you get an error or no output, fix the UserParameter command or permissions.
-
Check command permissions
If the agent runs as a non-root user, ensure it has permissions to run systemctl is-active guacd.service. You might need to allow the command without a password in sudoers or adjust permissions.
Example if sudo is required, modify UserParameter:
textUserParameter=service.status.guacd,sudo systemctl is-active guacd.service
And configure /etc/sudoers accordingly:
textzabbix ALL=NOPASSWD: /bin/systemctl is-active guacd.service
-
Validate item key in Zabbix
Ensure the item key in Zabbix frontend matches service.status.guacd exactly, including no trailing spaces.
These should resolve the Unsupported item key issue for your guacd service status check.
Videos
References
- https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent2?at=refs%2Fheads%2Frelease%2F7.4
- https://www.zabbix.com/integrations
- https://www.zabbix.com/documentation/7.0/en/manual/appendix/items/proc_get
- https://www.zabbix.com/documentation/7.0/en/manual/appendix/items/proc_mem_num_notes
- https://www.zabbix.com/documentation/7.0/en/manual/appendix/items/proc_mem_notes


共有 0 条评论