欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

zabbix監(jiān)控Nginx/Tomcat/MySQL的詳細教程

 更新時間:2019年12月09日 13:23:40   作者:Asnfy  
這篇文章主要介紹了zabbix監(jiān)控Nginx/Tomcat/MySQL的詳細教程,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下

zabbix監(jiān)控Nginx

A機器:zabbix服務端(192.168.234.128) B機器:zabbix客戶端(192.168.234.125)

在B機器(zabbix客戶端)操作:

編輯nginx虛擬主機配置文件:

[root@centos ~]# vi /etc/nginx/conf.d/default.conf 

在server{}中添加以下內(nèi)容:

 location /nginx_status
 {
  stub_status on;
  access_log off;
  allow 127.0.0.1;
  deny all;
 }

重載nginx配置:

[root@centos ~]# nginx -s reload

測試:

[root@centos ~]# curl http://127.0.0.1/nginx_status
Active connections: 1 
server accepts handled requests
 3 3 3 
Reading: 0 Writing: 1 Waiting: 0 

#nginx狀態(tài)信息已顯示

狀態(tài)說明:

添加監(jiān)控腳本:

vi /usr/local/sbin/ngx_status.sh

添加以下內(nèi)容:

#!/bin/bash
url="http://127.0.0.1/nginx_status"
curl=/usr/bin/curl

# 檢測nginx進程是否存在
function ping {
 /sbin/pidof nginx | wc -l 
}
# 檢測nginx性能
function active {
 $curl $url 2>/dev/null| grep 'Active' | awk '{print $NF}'
}
function reading {
 $curl $url 2>/dev/null| grep 'Reading' | awk '{print $2}'
}
function writing {
 $curl $url 2>/dev/null| grep 'Writing' | awk '{print $4}'
}
function waiting {
 $curl $url 2>/dev/null| grep 'Waiting' | awk '{print $6}'
}
function accepts {
 $curl $url 2>/dev/null| awk NR==3 | awk '{print $1}'
}
function handled {
 $curl $url 2>/dev/null| awk NR==3 | awk '{print $2}'
}
function requests {
 $curl $url 2>/dev/null| awk NR==3 | awk '{print $3}'
}
$1

添加權(quán)限:

[root@centos ~]# chmod 755 /usr/local/sbin/ngx_status.sh

編輯zabbix_agent配置文件:

[root@centos ~]# vi /etc/zabbix/zabbix_agentd.conf

在Option:UserParameter處添加:UserParameter=nginx.status[*],/usr/local/sbin/ngx_status.sh $1

在這里插入圖片描述

重啟服務:

[root@centos ~]# systemctl restart zabbix-agent

在A機器(服務端)測試:

[root@zabbix ~]# zabbix_get -s 192.168.234.125 -k 'nginx.status[accepts]'
6

在本機創(chuàng)建.xml文件并添加以下內(nèi)容:(文件名稱自定義)

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
 <version>4.0</version>
 <date>2019-02-11T07:29:29Z</date>
 <groups>
  <group>
   <name>Templates</name>
  </group>
 </groups>
 <templates>
  <template>
   <template>Template App NGINX</template>
   <name>Template App NGINX</name>
   <description/>
   <groups>
    <group>
     <name>Templates</name>
    </group>
   </groups>
   <applications>
    <application>
     <name>nginx</name>
    </application>
   </applications>
   <items>
    <item>
     <name>nginx status server accepts</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[accepts]</key>
     <delay>60</delay>
     <history>90d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>accepts</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap/>
     <logtimefmt/>
     <preprocessing>
      <step>
       <type>10</type>
       <params/>
      </step>
     </preprocessing>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
    <item>
     <name>nginx status connections active</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[active]</key>
     <delay>60</delay>
     <history>90d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>active</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap/>
     <logtimefmt/>
     <preprocessing/>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
    <item>
     <name>nginx status server handled</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[handled]</key>
     <delay>60</delay>
     <history>90d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>handled</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap/>
     <logtimefmt/>
     <preprocessing>
      <step>
       <type>10</type>
       <params/>
      </step>
     </preprocessing>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
    <item>
     <name>nginx status PING</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[ping]</key>
     <delay>60</delay>
     <history>30d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>is live</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap>
      <name>Service state</name>
     </valuemap>
     <logtimefmt/>
     <preprocessing/>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
    <item>
     <name>nginx status connections reading</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[reading]</key>
     <delay>60</delay>
     <history>90d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>reading</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap/>
     <logtimefmt/>
     <preprocessing/>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
    <item>
     <name>nginx status server requests</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[requests]</key>
     <delay>60</delay>
     <history>90d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>requests</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap/>
     <logtimefmt/>
     <preprocessing>
      <step>
       <type>10</type>
       <params/>
      </step>
     </preprocessing>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
    <item>
     <name>nginx status connections waiting</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[waiting]</key>
     <delay>60</delay>
     <history>90d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>waiting</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap/>
     <logtimefmt/>
     <preprocessing/>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
    <item>
     <name>nginx status connections writing</name>
     <type>0</type>
     <snmp_community/>
     <snmp_oid/>
     <key>nginx.status[writing]</key>
     <delay>60</delay>
     <history>90d</history>
     <trends>365d</trends>
     <status>0</status>
     <value_type>3</value_type>
     <allowed_hosts/>
     <units/>
     <snmpv3_contextname/>
     <snmpv3_securityname/>
     <snmpv3_securitylevel>0</snmpv3_securitylevel>
     <snmpv3_authprotocol>0</snmpv3_authprotocol>
     <snmpv3_authpassphrase/>
     <snmpv3_privprotocol>0</snmpv3_privprotocol>
     <snmpv3_privpassphrase/>
     <params/>
     <ipmi_sensor/>
     <authtype>0</authtype>
     <username/>
     <password/>
     <publickey/>
     <privatekey/>
     <port/>
     <description>writing</description>
     <inventory_link>0</inventory_link>
     <applications>
      <application>
       <name>nginx</name>
      </application>
     </applications>
     <valuemap/>
     <logtimefmt/>
     <preprocessing/>
     <jmx_endpoint/>
     <timeout>3s</timeout>
     <url/>
     <query_fields/>
     <posts/>
     <status_codes>200</status_codes>
     <follow_redirects>1</follow_redirects>
     <post_type>0</post_type>
     <http_proxy/>
     <headers/>
     <retrieve_mode>0</retrieve_mode>
     <request_method>0</request_method>
     <output_format>0</output_format>
     <allow_traps>0</allow_traps>
     <ssl_cert_file/>
     <ssl_key_file/>
     <ssl_key_password/>
     <verify_peer>0</verify_peer>
     <verify_host>0</verify_host>
     <master_item/>
    </item>
   </items>
   <discovery_rules/>
   <httptests/>
   <macros/>
   <templates/>
   <screens/>
  </template>
 </templates>
 <triggers>
  <trigger>
   <expression>{Template App NGINX:nginx.status[ping].last()}=0</expression>
   <recovery_mode>0</recovery_mode>
   <recovery_expression/>
   <name>nginx was down!</name>
   <correlation_mode>0</correlation_mode>
   <correlation_tag/>
   <url/>
   <status>0</status>
   <priority>4</priority>
   <description>NGINX進程數(shù):0,請注意</description>
   <type>0</type>
   <manual_close>0</manual_close>
   <dependencies/>
   <tags/>
  </trigger>
 </triggers>
 <graphs>
  <graph>
   <name>nginx status connections</name>
   <width>900</width>
   <height>200</height>
   <yaxismin>0.0000</yaxismin>
   <yaxismax>100.0000</yaxismax>
   <show_work_period>1</show_work_period>
   <show_triggers>1</show_triggers>
   <type>0</type>
   <show_legend>1</show_legend>
   <show_3d>0</show_3d>
   <percent_left>0.0000</percent_left>
   <percent_right>0.0000</percent_right>
   <ymin_type_1>0</ymin_type_1>
   <ymax_type_1>0</ymax_type_1>
   <ymin_item_1>0</ymin_item_1>
   <ymax_item_1>0</ymax_item_1>
   <graph_items>
    <graph_item>
     <sortorder>0</sortorder>
     <drawtype>0</drawtype>
     <color>00C800</color>
     <yaxisside>0</yaxisside>
     <calc_fnc>2</calc_fnc>
     <type>0</type>
     <item>
      <host>Template App NGINX</host>
      <key>nginx.status[active]</key>
     </item>
    </graph_item>
    <graph_item>
     <sortorder>1</sortorder>
     <drawtype>0</drawtype>
     <color>C80000</color>
     <yaxisside>0</yaxisside>
     <calc_fnc>2</calc_fnc>
     <type>0</type>
     <item>
      <host>Template App NGINX</host>
      <key>nginx.status[reading]</key>
     </item>
    </graph_item>
    <graph_item>
     <sortorder>2</sortorder>
     <drawtype>0</drawtype>
     <color>0000C8</color>
     <yaxisside>0</yaxisside>
     <calc_fnc>2</calc_fnc>
     <type>0</type>
     <item>
      <host>Template App NGINX</host>
      <key>nginx.status[waiting]</key>
     </item>
    </graph_item>
    <graph_item>
     <sortorder>3</sortorder>
     <drawtype>0</drawtype>
     <color>C800C8</color>
     <yaxisside>0</yaxisside>
     <calc_fnc>2</calc_fnc>
     <type>0</type>
     <item>
      <host>Template App NGINX</host>
      <key>nginx.status[writing]</key>
     </item>
    </graph_item>
   </graph_items>
  </graph>
  <graph>
   <name>nginx status server</name>
   <width>900</width>
   <height>200</height>
   <yaxismin>0.0000</yaxismin>
   <yaxismax>100.0000</yaxismax>
   <show_work_period>1</show_work_period>
   <show_triggers>1</show_triggers>
   <type>0</type>
   <show_legend>1</show_legend>
   <show_3d>0</show_3d>
   <percent_left>0.0000</percent_left>
   <percent_right>0.0000</percent_right>
   <ymin_type_1>0</ymin_type_1>
   <ymax_type_1>0</ymax_type_1>
   <ymin_item_1>0</ymin_item_1>
   <ymax_item_1>0</ymax_item_1>
   <graph_items>
    <graph_item>
     <sortorder>0</sortorder>
     <drawtype>0</drawtype>
     <color>00C800</color>
     <yaxisside>0</yaxisside>
     <calc_fnc>2</calc_fnc>
     <type>0</type>
     <item>
      <host>Template App NGINX</host>
      <key>nginx.status[accepts]</key>
     </item>
    </graph_item>
    <graph_item>
     <sortorder>1</sortorder>
     <drawtype>0</drawtype>
     <color>C80000</color>
     <yaxisside>0</yaxisside>
     <calc_fnc>2</calc_fnc>
     <type>0</type>
     <item>
      <host>Template App NGINX</host>
      <key>nginx.status[handled]</key>
     </item>
    </graph_item>
    <graph_item>
     <sortorder>2</sortorder>
     <drawtype>0</drawtype>
     <color>0000C8</color>
     <yaxisside>0</yaxisside>
     <calc_fnc>2</calc_fnc>
     <type>0</type>
     <item>
      <host>Template App NGINX</host>
      <key>nginx.status[requests]</key>
     </item>
    </graph_item>
   </graph_items>
  </graph>
 </graphs>
 <value_maps>
  <value_map>
   <name>Service state</name>
   <mappings>
    <mapping>
     <value>0</value>
     <newvalue>Down</newvalue>
    </mapping>
    <mapping>
     <value>1</value>
     <newvalue>Up</newvalue>
    </mapping>
   </mappings>
  </value_map>
 </value_maps>
</zabbix_export>

在zabbix前端頁面點擊配置→模板→導入:

在這里插入圖片描述

#導入剛才創(chuàng)建的xml文件即可

導入成功后在主機列表頁面選擇被監(jiān)控的機器(B機器)鏈接該模板即可開始監(jiān)控nginx

zabbix監(jiān)控Tomcat

A機器:zabbix服務端(192.168.234.128) B機器:zabbix客戶端(192.168.234.125)

在A機器安裝zabbix-java-gateway:

[root@zabbix ~]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-java-gateway-4.0.14-1.el7.x86_64.rpm

[root@zabbix ~]# yum -y localinstall zabbix-java-gateway-4.0.14-1.el7.x86_64.rpm 

編輯gateway配置文件:

[root@zabbix ~]# vi /etc/zabbix/zabbix_java_gateway.conf 

去掉LISTEN_IP、LISTEN_PORT(監(jiān)聽端口)、START_POLLERS(進程數(shù))的注釋符號#:

在這里插入圖片描述

#LISTEN_IP定義被監(jiān)控機器的地址,不指定默認監(jiān)聽全部機器

編輯server配置文件:

[root@zabbix ~]# vi /etc/zabbix/zabbix_server.conf

定義以下3個配置參數(shù):

在這里插入圖片描述

啟動zabbix-java-gateway服務:

[root@zabbix ~]# systemctl start zabbix-java-gateway

重啟zabbix-server服務:

[root@zabbix ~]# systemctl restart zabbix-server

查看監(jiān)聽端口:

[root@zabbix ~]# netstat -lntp |grep java
tcp6  0  0 :::10052    :::*     LISTEN  8706/java 

開啟JMX

在B機器編輯tomcat配置文件:

[root@centos ~]# vi /usr/local/tomcat/bin/catalina.sh 

添加以下內(nèi)容:

export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=192.168.234.125
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"

#hostname定義B機器地址,端口9999(默認12345)

重啟tomcat:

[root@centos ~]# /usr/local/tomcat/bin/shutdown.sh 

[root@centos ~]# /usr/local/tomcat/bin/startup.sh 

查看監(jiān)聽端口9999:

[root@centos ~]# netstat -lntp |grep 9999
tcp6  0  0 :::9999     :::*     LISTEN  25861/java 

進入zabbix前端頁面添加主機:

在這里插入圖片描述

#與普通情況添加監(jiān)控主機不同,監(jiān)控B機器的tomcat需要配置JMX接口

模板鏈接JMX相關的兩個模板:

在這里插入圖片描述

當JMX圖標變綠即表示配置成功:

在這里插入圖片描述

zabbix監(jiān)控MySQL

A機器:zabbix服務端(192.168.234.128) B機器:zabbix客戶端(192.168.234.125)

zabbix_agent定義mysql監(jiān)控的配置文件:/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf

在B機器登錄mysql創(chuàng)建用戶:

mysql> grant usage,process,replication client on *.* to zamysql@'localhost' identified by 'zamysql';

創(chuàng)建配置文件指定的目錄:

[root@centos ~]# mkdir /var/lib/zabbix

創(chuàng)建my.cnf文件:

[root@centos ~]# vi /var/lib/zabbix/.my.cnf

#需要注意該文件是隱藏文件

添加以下內(nèi)容:

[mysql]
host=localhost
user=zamysql
password='zamysql'
socket=/tmp/mysql.sock

[mysqladmin]
host=localhost
user=zamysql
password='zamysql'
socket=/tmp/mysql.sock

在A機器測試:

[root@zabbix ~]# zabbix_get -s 192.168.234.125 -p 10050 -k mysql.ping
1
[root@zabbix ~]# zabbix_get -s 192.168.234.125 -p 10050 -k mysql.version
mysql Ver 14.14 Distrib 5.6.43, for linux-glibc2.12 (x86_64) using EditLine wrapper
[root@zabbix ~]# zabbix_get -s 192.168.234.125 -p 10050 -k mysql.size
10240

#已成功獲取數(shù)據(jù)

在zabbix前端頁面添加主機:

在這里插入圖片描述

監(jiān)控模板選擇DB mysql:

在這里插入圖片描述

ZBX標準變?yōu)榫G色表示成功:

在這里插入圖片描述

在監(jiān)測→最新數(shù)據(jù)頁面即可查看mysql監(jiān)控數(shù)據(jù):

在這里插入圖片描述

總結(jié)

以上所述是小編給大家介紹的zabbix監(jiān)控Nginx/Tomcat/MySQL的詳細教程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關文章

  • 重置Zabbix密碼的方法(一步到位)

    重置Zabbix密碼的方法(一步到位)

    由于長時間不通過賬號密碼的方式登錄zabbix,容易忘記密碼,小編今天通過轉(zhuǎn)換對應的md5直接在數(shù)據(jù)庫中重置密碼,對重置Zabbix密碼感興趣的朋友一起看看吧
    2020-02-02
  • Zabbix郵件報警設置方法

    Zabbix郵件報警設置方法

    這篇文章主要介紹了Zabbix郵件報警設置方法,在Zabbix服務端設置郵件報警,當被監(jiān)控主機宕機或者達到觸發(fā)器預設值時,會自動發(fā)送報警郵件到指定郵箱
    2014-10-10
  • Zabbix如何通過ssh監(jiān)控獲取網(wǎng)絡設備數(shù)據(jù)

    Zabbix如何通過ssh監(jiān)控獲取網(wǎng)絡設備數(shù)據(jù)

    這篇文章主要介紹了Zabbix如何通過ssh監(jiān)控獲取網(wǎng)絡設備數(shù)據(jù),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-08-08
  • Zabbix遠程執(zhí)行命令的示例詳解

    Zabbix遠程執(zhí)行命令的示例詳解

    這篇文章主要介紹了Zabbix遠程執(zhí)行命令,本文主要配置驗證zabbix執(zhí)行遠程命令的相關知識,通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2020-03-03
  • Zabbix監(jiān)控多個JVM進程的方法

    Zabbix監(jiān)控多個JVM進程的方法

    這篇文章主要介紹了Zabbix監(jiān)控多個JVM進程的方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-09-09
  • zabbix 2.2安裝步驟詳細介紹

    zabbix 2.2安裝步驟詳細介紹

    這篇文章主要介紹了zabbix 2.2安裝步驟詳細介紹的相關資料,本文給大家介紹的非常詳細,具有參考借鑒價值,需要的朋友可以參考下
    2016-10-10
  • Zabbix安裝圖文教程(需要LAMP或者LNMP運行環(huán)境)

    Zabbix安裝圖文教程(需要LAMP或者LNMP運行環(huán)境)

    要想安裝Zabbix那么在Linux下安裝zabbix需要有LAMP或者LNMP運行環(huán)境才可以,這里給大家分享下Zabbix安裝方法,需要的朋友可以參考下
    2014-10-10
  • Zabbix實現(xiàn)監(jiān)控多個mysql過程解析

    Zabbix實現(xiàn)監(jiān)控多個mysql過程解析

    這篇文章主要介紹了Zabbix實現(xiàn)監(jiān)控多個mysql過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2020-08-08
  • Zabbix對Kafka?topic積壓數(shù)據(jù)監(jiān)控的解決方案

    Zabbix對Kafka?topic積壓數(shù)據(jù)監(jiān)控的解決方案

    這篇文章主要介紹了Zabbix對Kafka?topic積壓數(shù)據(jù)監(jiān)控的解決方案,它與Apache Storm和Spark非常好地集成,用于實時流式數(shù)據(jù)分析,需要的朋友跟隨小編一起看看吧
    2022-07-07
  • zabbix 4.04 安裝文檔教程詳解(基于CentOS 7.6)

    zabbix 4.04 安裝文檔教程詳解(基于CentOS 7.6)

    這篇文章主要介紹了基于CentOS 7.6系統(tǒng)zabbix 4.04 安裝文檔,本文分步驟給大家介紹的非常詳細,具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2020-01-01

最新評論