nginx配置普米监控

一.编译Nginx,增加vts模块

yum -y install gcc gcc-c++ make zlib-devel pcre pcre-devel openssl-devel perl-devel perl-ExtUtils-Embed gd-devel libxml2 libxml2-dev libxslt-devel
yum -y install GeoIP GeoIP-devel GeoIP-data  
wget http://x.x.x.x/nginx-1.20.2.tar.gz
tar xf nginx-1.20.2.tar.gz
cd nginx-1.20.2
wget http://x.x.x.x/nginx-module-vts.tgz
tar xf nginx-module-vts.tgz
./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --add-module=/var/kingdee/soft/nginx-1.20.2/nginx-module-vts
make -j 2 && make install

二. 配置vts
vim nginx.conf
在http栏目下

vhost_traffic_status_zone;   #流量状态监控
server {
   listen  8080;
   location /status {
     vhost_traffic_status_display;
     vhost_traffic_status_display_format html;
   }
}

三.配置exporter

wget http://x.x.x.x/nginx-vts-exporter.tgz
tar xf nginx-vts-exporter.tgz
rm -f nginx-vts-exporter.tgz
cd /usr/lib/systemd/system/
cat nginx-vts-exporter.service
systemctl daemon-reload
systemctl start nginx-vts-exporter

nginx-vts-exporter.service 内容如下

[Unit]
Description=https://github.com/hnlq715/nginx-vts-exporter;port:9913
After=network-online.target

[Service]
ExecStart=/var/nginx-vts-exporter/nginx-vts-exporter -nginx.scrape_uri=http://127.0.0.1:8080/status/format/json --telemetry.address=:9913
Restart=always
RestartSec=5
StartLimitInterval=0
StartLimitBurst=10

[Install]
WantedBy=multi-user.target

四.配置普米

- job_name: 'nginx_exporter'
  static_configs:
  - targets: ['x.x.x.x:9913']
    labels: { job: 'nginx', region: '监控主机'}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值