Zabbix Monitor nginx,php-fpm and MySQL memory usage and number of processes with custom scripts

Source: Internet
Author: User
Tags fpm memory usage

Zabbix Monitor nginx,php-fpm and MySQL memory usage and number of processes with custom scripts

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 "$" 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: $ {Php_fpm|php_fpm_num|nginx|nginx_num|mysqld|mysqld_num}"

Esac

After saving, modify its genus and owner to Zabbix.zabbix, then create a new file Process.log, also set the owner and the group as Zabbix.zabbix

Then edit the zabbix_agentd.conf file, add the following code at the end, 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_num,/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

You can then add item to the Web page, generate the chart, and note that the memory unit top is in KB, so you need to customize the unit and set multiple when you define the item

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6B/80/wKiom1UvNEbSdVSbAAB9vqqsXSo658.jpg "title=" 1.png " alt= "Wkiom1uvnebsdvsbaab9vqqsxso658.jpg"/>

The graphs generated by each program occupy memory size are as follows

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6B/80/wKiom1UvNJygIArSAAUIoiF9ZSg645.jpg "title=" 2.png " alt= "Wkiom1uvnjygiarsaauioif9zsg645.jpg"/> The number of processes generated by the program graph is as follows, you can set the trigger, when the process satisfies the trigger its condition to send an alarm

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6B/7C/wKioL1UvNlHCeZ99AASOUhadZvA947.jpg "title=" 3.png " alt= "Wkiol1uvnlhcez99aasouhadzva947.jpg"/>

This article is from the "Lemon" blog, be sure to keep this source http://xianglinhu.blog.51cto.com/5787032/1633333

Zabbix Monitor nginx,php-fpm and MySQL memory usage and number of processes with custom scripts

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.