Zabbix monitors the memory usage and process count of Nginx, php-fpm, and MySQL.
Zabbix uses custom scripts to monitor the memory usage and process count of Nginx, php-fpm, and MySQL.
First, add a script under the zabbix Script directory and write the following code:
#! /Bin/bash
# License: GPL
# Mail: [email protected]
# Date: 2015.04.16
Top-bn1>/usr/local/zabbix-2.4.4/scripts/process. log
LOG =/usr/local/zabbix-2.4.4/scripts/process. log
Php_fpm (){
Grep "php-fpm" $ LOG | awk '{sum + = $6}; END {print sum }'
}
Php_fpm_num (){
Grep "php-fpm" $ LOG | wc-l
}
Nginx (){
Grep "nginx" $ LOG | awk '{sum + = $6}; END {print sum }'
}
Nginx_num (){
Grep "nginx" $ LOG | wc-l
}
Mysqld (){
Grep "mysqld" $ LOG | awk '{sum + = $6}; END {print sum }'
}
Mysqld_num (){
Grep "mysqld" $ LOG | wc-l
}
Case "$1" in
Php_fpm)
Php_fpm
;;
Php_fpm_num)
Php_fpm_num
;;
Nginx)
Nginx
;;
Nginx_num)
Nginx_num
;;
Mysqld)
Mysqld
;;
Mysqld_num)
Mysqld_num
;;
*)
Echo "Usage: $0 {php_fpm | php_fpm_num | nginx | nginx_num | mysqld | mysqld_num }"
Esac
Save the settings, modify its group and owner to zabbix. zabbix, create a new file process. log, and set the owner and group to zabbix. zabbix.
Edit the zabbix_agentd.conf file, add the code above and below, and restart the zabbix_agentd service.
UserParameter = process. php_fpm,/usr/local/zabbix-2.4.4/scripts/processstatus. sh php_fpm
UserParameter = process. php_fpm_num,/usr/local/zabbix-2.4.4/scripts/processstatus. sh php_fpm_num
UserParameter = process. nginx,/usr/local/zabbix-2.4.4/scripts/processstatus. sh nginx
UserParameter = process. nginx,/usr/local/zabbix-2.4.4/scripts/processstatus. sh nginx_num
UserParameter = process. mysqld,/usr/local/zabbix-2.4.4/scripts/processstatus. sh mysqld
UserParameter = process. mysqld_num,/usr/local/zabbix-2.4.4/scripts/processstatus. sh mysqld_num
After that, you can add an item on the web page to generate a chart. Note that the memory unit obtained by top is KB. Therefore, you need to customize the unit and set the multiple when defining the item.
The following figure shows the memory size occupied by each program generated:
The number of processes generated for each program is shown in the figure below. You can set a trigger to send an alarm when the process meets the trigger conditions.
Some Zabbix Tutorials:
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy Zabbix in CentOS 6.3
Zabbix distributed monitoring system practice
Under CentOS 6.3, Zabbix monitors apache server-status
Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3
Install Zabbix 2.0.6 in 64-bit CentOS 6.2
ZABBIX details: click here
ZABBIX: click here
This article permanently updates the link address: