[Linux36-2] zabbix monitoring (mysql+percona+tomcat+active monitoring+onealert cloud alarm)


Zabbix monitoring experiment deployment



1. Monitoring database


1.2 Type 1: mysql


  • Server configuration

mkdir /var/lib/zabbix

vim /var/lib/zabbix/.my.cnf

[mysql]
user=root
password=westos
socket=/var/lib/mysql/mysql.sock
[mysqladmin]
user=root
password=westos
socket=/var/lib/mysql/mysql.sock

Insert picture description here

  • Add template

Insert picture description here



1.2 Category 2: percona


  • Install percona

rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm

Insert picture description here

  • Install php and php-mysql

yum install -y php php-mysql

  • Copy key file template

cd /var/lib/zabbix/percona/templates/

cp userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/

  • Restart the agent service

systemctl restart zabbix-agent.service

  • Add user name and password to percona database script

vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php

$mysql_user = 'root';
$mysql_pass = 'westos';

rm -fr /tmp/localhost-mysql_cacti_stats.txt

  • Import template zbx_percona_mysql_template.xml

Insert picture description here

  • Add percona database template (cancel the mysql template added before)

Insert picture description here

2. Monitoring java (using apache-tomcat)


Java monitoring object: server2: 192.168.17.2


2.1 Agent configuration


  • Install jdk

yum install -y java-1.8.0-openjdk.x86_64
Insert picture description here

  • Install apache-tomcat, create a soft link,

tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local/

cd /usr/local/

ln -s apache-tomcat-7.0.37/ tomcat

  • Configure tomcat

cd /usr/local/tomcat/bin/

vim catalina.sh

CATALINA_OPTS='-Dcom.sun.management.jmxremote.port=8888
  -Dcom.sun.management.jmxremote.ssl=false
  -Dcom.sun.management.jmxremote.authenticate=false'

Insert picture description here

./startup.sh

netstat -antlupe | grep 8080

netstat -antlupe | grep :8888

Insert picture description here

2.2 Server configuration


server1:192.168.17.1


  • Install zabbix-java-gateway**

yum install -y zabbix-java-gateway

  • Change setting

vim /etc/zabbix/zabbix_java_gateway.conf(According to your own needs, you can not modify it)

  9 LISTEN_IP="0.0.0.0"#默认
 17 LISTEN_PORT=10052#默认端口
 35 START_POLLERS=10

  • Open zabbix-java-gateway service

systemctl enable --now zabbix-java-gateway.service

netstat -antlupe | grep 10052
Insert picture description here

  • Configure java gateway

vim /etc/zabbix/zabbix_server.conf

JavaGateway=192.168.17.1
JavaGatewayPort=10052
StartJavaPollers=10

Insert picture description here

  • Restart zabbix-server service

systemctl restart zabbix-server

2.3 Add JMX interface and template for monitoring


  • Add JMX interface

Insert picture description here

  • Add JMX template

Insert picture description here

  • Check whether the monitoring is normal

Insert picture description here



3. Active monitoring


The client actively sends data


  • Full clone template (because new creation is too troublesome)

Insert picture description here
Insert picture description here

  • Modify the cloned template to be active : select the template Template OS Linux–Active, select all monitoring items of the template, and perform batch updates

Insert picture description here

  • Cancel the template before cloning on the agent side and add the active template

Insert picture description here



4. Distributed monitoring (proxy)


  • Zabbix provides effective and available distributed monitoring for IT infrastructure through Zabbix proxies
  • Proxies can be used to collect data locally instead of Zabbix server, and then report the data to the server.

4.1 Experimental environment


Proxy host: proxy:192.168.17.3 (limited hosts, change the agent host into a proxy host)


  • Modify the host name as proxy and delete it from the agent host

Insert picture description here
Insert picture description here

  • Add resolution to all hosts

vim /etc/hosts

192.168.17.3	proxy

4.2 define proxy server


  • Create agent

Insert picture description here

  • Set the agent host server2 to be monitored by the agent

Insert picture description here
Insert picture description here

4.3 Proxy configuration


  • Install database and proxy

yum install -y zabbix-proxy-mysql

yum install -y mariadb-server

  • Open and create database

systemctl enable --now mariadb

mysql

create database zabbix_proxy character set utf8 collate utf8_bin;
create user 'zabbix'@'localhost' identified by 'westos';
grant all privileges on zabbix_proxy.* to 'zabbix'@'localhost';

Insert picture description here

  • Change setting

vim /etc/zabbix/zabbix_proxy.conf

 30 Server=192.168.17.1
 49 Hostname=proxy
173 DBName=zabbix_proxy
188 DBUser=zabbix
196 DBPassword=westos
#由于server2主机配置了java,所以也要修改java网关,否则监测JMX会失败
329 JavaGateway=192.168.17.1
337 JavaGatewayPort=10052
345 StartJavaPollers=10

  • Import Data

zcat /usr/share/doc/zabbix-proxy-mysql-4.0.27/schema.sql.gz | mysql -uzabbix -pwestos zabbix_proxy

  • Open proxy service

systemctl enable --now zabbix-proxy

4.4 Agent configuration


server2:192.168.17.2


  • Modify server to proxy server IP

vim /etc/zabbix/zabbix_agentd.conf

 98 Server=192.168.17.3
139 ServerActive=192.168.17.3

  • Restart service

systemctl restart zabbix-agent.service

4.5 server configuration


  • Re-read zabbix configuration file

zabbix_server -R config_cache_reload

  • Restart the service on the proxy side

systemctl restart zabbix-proxy.service

  • Server side view log

cat /var/log/zabbix/zabbix_server.log

Insert picture description here

  • Proxy view log

cat /var/log/zabbix/zabbix_proxy.log

Insert picture description here

4.6 View monitoring results


Insert picture description here



5. Cloud Alert


Intelligent alarm platform: http://onealert.com/

The intelligent alarm platform CA can quickly access all kinds of alarm information, realize alarm noise reduction through automatic deduplication, rule compression, and algorithm noise reduction, and help the operation and maintenance team reduce alarms and avoid alarm storms; at the same time, through dispatch, scheduling, and notification And other functions, quickly realize the process-based management of alarms, help the operation and maintenance team respond to alarms faster, restore alarms, and improve alarm management capabilities


Zabbix integration steps

5.1 Alarm platform configuration


  • Create zabbix application, get key

Insert picture description here

  • Create a notification strategy, select the notification method as WeChat (bind WeChat in advance)

Insert picture description here



5.2 Install CA Probe on Server


  • Download package

wget https://download.aiops.com/ca_agent/zabbix/ca_zabbix_release-2.1.0.tar.gz

  • Unzip to the specified location

tar zxf ca_zabbix_release-2.1.0.tar.gz -C /usr/lib/zabbix/alertscripts/

  • Install to the specified location

cd /usr/lib/zabbix/alertscripts/cloudalert/bin/

./install.sh 获取的key

Insert picture description here
Insert picture description here

  • It is found that alert media, users, triggers, etc. are automatically added to the front end

Insert picture description here
Insert picture description here
Insert picture description here

5.3 Testing


  • Turn off the agent service

Insert picture description here

  • Front end view

Insert picture description here
Insert picture description here

  • Open the agent service, the front-end view problem is solved

Insert picture description here

  • WeChat display alert

Insert picture description here

  • Alarm platform display

Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_46069582/article/details/112853192