性能监控之中间件监控
Redis监控
一、通过info查看
通过redis-cli或者其他redis连接工具查看info,info内容可参考:https://www.cnblogs.com/daydayup-lin/p/14317535.html
二、redis-stat
Nginx监控
一、netstat
连接数是Nginx重点监控连接数,一般是通过netstat命令来监控
监听80端口的连接数情况:netstat -anp|grep :80
查看80端口的总连接数:netstat -anp|grep :80 | wc -l
查看nginx所有连接数的状态,分类展示: netstat -anp | grep :80 | awk '{print $6}' | sort | uniq -c |sort -rn
二、ngxtop
1、安装
系统自带的都是python2,ngxtop需要在python环境下运行,所以需要在先安装python3
--安装依赖包
# yum -y groupinstall "Development tools"
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel zlib1g-dev zlib1g-dev zlib* gcc make
--下载解压缩python
# yum -y install wget
# cd /usr/local/
# wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
# tar zxvf Python-3.9.9.tgz
--安装python3
# cd /usr/local/Python-3.9.9
# ./configure --prefix=/usr/local/python3 --with-ssl
# make clean
# make && make install
# /usr/local/python3/bin/python3.9 -m pip install --upgrade p
--创建软链接
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
--查看pyhon3、pip3版本信息
# python3 -V
# pip3 -V
2、创建非root账号,ngxtop必须在非root账号下运行
# useradd ngxtop -G wheel # passwd ngxtop Changing password for user ngxtop. New password: 123456 BAD PASSWORD: The password is shorter than 8 characters Retype new password: 123456 passwd: all authentication tokens updated successfully.
3、切换到非root账号,安装ngxtop
# su ngxtop
$ pip3 install ngxtop
4、查看ngxtop是否安装成功
# cd /home/ngxtop/.local/bin $ ./ngxtop --version $ ./ngxtop --help
5、查看监控
./ngxtop -c /etc/nginx/nginx.conf