日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

分布式系统——向zabbix中添加监控项, 以nginx和mysql为例

發布時間:2025/3/19 数据库 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 分布式系统——向zabbix中添加监控项, 以nginx和mysql为例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

實驗環境

server1:rhel 7.3系統——172.25.54.1

server2:rhel 6.5系統——172.25.54.11

一、zabbix監控nginx

  • 添加監控項active
    server2
[root@server2 ~]# ls nginx-1.8.0-1.el6.ngx.x86_64.rpm zabbix-agent-3.4.6-1.el6.x86_64.rpm [root@server2 ~]# rpm -ivh nginx-1.8.0-1.el6.ngx.x86_64.rpm //安裝nginx [root@server2 ~]# cd /etc/nginx/conf.d/ [root@server2 conf.d]# vim default.conf 13 location /status {14 stub_status on;15 access_log off;16 allow 127.0.0.1;17 deny all;18 } [root@server2 conf.d]# nginx -t [root@server2 conf.d]# nginx

[root@server2 conf.d]# curl -s http://127.0.0.1/status | grep Active | awk '{print $NF}' //$NF:最后一列 1 [root@server2 conf.d]# curl -s http://127.0.0.1/status | grep Active | awk '{print $3}' 1 [root@server2 conf.d]# cd /etc/zabbix/zabbix_agentd.d/ [root@server2 zabbix_agentd.d]# ls userparameter_mysql.conf [root@server2 zabbix_agentd.d]# cp userparameter_mysql.conf userparameter_nginx.conf [root@server2 zabbix_agentd.d]# vim userparameter_nginx.conf UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $3}' [root@server2 zabbix_agentd.d]# /etc/init.d/zabbix-agent start [root@server2 zabbix_agentd.d]# chkconfig zabbix-agent on //設置開機自啟

server1

[root@server1 ~]# systemctl start mariadb [root@server1 ~]# systemctl enable mariadb [root@server1 ~]# systemctl start zabbix-server [root@server1 ~]# systemctl enable zabbix-server [root@server1 ~]# systemctl start zabbix-agent [root@server1 ~]# systemctl enable zabbix-agent [root@server1 ~]# systemctl start httpd [root@server1 ~]# systemctl enable httpd [root@server1 ~]# ls fping-3.10-1.el7.x86_64.rpm zabbix-get-3.4.6-1.el7.x86_64.rpm iksemel-1.4-2.el7.centos.x86_64.rpm zabbix-java-gateway-3.4.6-1.el7.x86_64.rpm php-bcmath-5.4.16-42.el7.x86_64.rpm zabbix-proxy-mysql-3.4.6-1.el7.x86_64.rpm php-mbstring-5.4.16-42.el7.x86_64.rpm zabbix-server-mysql-3.4.6-1.el7.x86_64.rpm zabbix-agent-3.4.6-1.el7.x86_64.rpm zabbix-web-3.4.6-1.el7.noarch.rpm zabbix-api1.sh zabbix-web-mysql-3.4.6-1.el7.noarch.rpm zabbix-api.sh [root@server1 ~]# rpm -ivh zabbix-get-3.4.6-1.el7.x86_64.rpm [root@server1 ~]# zabbix_get -s 172.25.54.11 -p 10050 -k 'nginx.active' 1 [root@server1 ~]#

瀏覽器







  • 添加監控項accepts、handled、requests
    server2
[root@server2 zabbix_agentd.d]# vim userparameter_nginx.conf UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $3}' UserParameter=nginx.accepts,curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $1}' UserParameter=nginx.handled,curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $2}' UserParameter=nginx.requests,curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $3}' [root@server2 zabbix_agentd.d]# curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $1}' 35 [root@server2 zabbix_agentd.d]# curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $2}' 36 [root@server2 zabbix_agentd.d]# curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $3}' 37 [root@server2 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart

瀏覽器
先添加三個新的監控項







一、zabbix添加mysql模塊并監控

percona-zabbix-templates-1.1.8-1.noarch.rpm安裝包下載
server1

[root@server1 ~]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm [root@server1 ~]# cd /var/lib/zabbix/percona/templates/ [root@server1 templates]# ls userparameter_percona_mysql.conf zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml [root@server1 templates]# cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/ [root@server1 zabbix_agentd.d]# systemctl restart zabbix-agent [root@server1 zabbix_agentd.d]# vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf <?php $mysql_user = 'root'; $mysql_pass = 'redhat'; [root@server1 zabbix_agentd.d]# mysql -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 586 Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> Bye [root@server1 zabbix_agentd.d]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg 4 [root@server1 zabbix_agentd.d]# cd /tmp/ [root@server1 tmp]# ls localhost-mysql_cacti_stats.txt systemd-private-5d2805d4023241a291abf9bec82244af-httpd.service-x6qoiW systemd-private-5d2805d4023241a291abf9bec82244af-mariadb.service-8uQXRk systemd-private-85310d76fe5d48c9af82fc3eeddb75c0-mariadb.service-dwB5hY systemd-private-87d37df39e4b4602909e8a8390477aa7-httpd.service-cy69v5 systemd-private-87d37df39e4b4602909e8a8390477aa7-mariadb.service-gLeaRS [root@server1 tmp]# cat localhost-mysql_cacti_stats.txt [root@server1 tmp]# rm -fr localhost-mysql_cacti_stats.txt [root@server1 tmp]# cd [root@server1 ~]# zabbix_get -s 172.25.54.1 -p 10050 -k 'MySQL.Threads-cached' zabbix_get [13888]: Check access restrictions in Zabbix agent configuration [root@server1 ~]# zabbix_get -s 127.0.0.1 -p 10050 -k 'MySQL.Threads-cached' 0 [root@server1 ~]#

瀏覽器







與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的分布式系统——向zabbix中添加监控项, 以nginx和mysql为例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。