Zabbix monitors the memory usage and process count of Nginx, php-fpm, and MySQL.

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.