当前位置:网站首页>Advanced use of ZABBIX monitoring

Advanced use of ZABBIX monitoring

2020-12-07 11:12:01 itread01

1. Zabbix Based on SNMP Monitoring

1.1 zabbix-web The monitoring mode that can be specified

ssh/telnet

agent:master/agent

SNMP:Simple Network Management Protocol 

IPMI:Intelligent Platform Management Interface  Smart platform management interface 
#  It was originally a kind of Interl An industrial standard used for peripheral devices of enterprise system architecture 
# IPMI It's also an open, free standard , Users can use this standard at no extra cost 

JMX:Java Management eXtension (Java Manage extensions )
#  Used to pass through Java Its own interface to java Program to monitor 
#  Monitoring JVM Virtual machines 
# zabbix-java-gateway Used to obtain monitoring data 

#  If defined on the server side Type For Trapper, Then the client can send any type of data to the server 
#  The server receives it and saves it 

1.2 SNMP summary

1)snmp The purpose of the agreement is

SNMP:Simple Network Management Protocol Simple network management protocol ( A very old agreement )

  • A protocol used in network management
  • SNMP For the management of network devices : Switch 、 Router

edition :

  • v1:1989
  • v2c:1993
  • v3:1998

2)snmp The elements of

MIB:Management Information Base Manage information base ( Every one of them agent All have one MIB Ku )

  • Defines the set of all manageable partners , It also defines the name of the managed object 、 Access permission 、 Data type, etc
  • A component that can define the acceptable monitoring element and the data storage format in the monitoring element is implemented
  • It can also implement the management of each object ID (Object ID,OID) Corresponding to the name conversion

MIB Look at :MIB A subset of the library

  • Authorization : Will some MIB Examine with sth Community Bind to implement

SMI:MIB It means the symbol

SNMP The agreement itself

3)snmp Means of communication

# NMS End 
“ Read ”(get,getnext)  operation : The administrator obtains information from the device 
“ Write ” (set) operation : The administrator performs setting operations on the device 
“Trap”(trap) operation : The device needs to change when important conditions , Inform the administrator of the incident 

# Agent End 
Response: Returns one or more arguments 

4) The port used

  • Agent:161/udp
  • NMS:162/dup

5) Working mode

  • NMS To the end agent Data collection at the end of (NMS Indicates the monitoring node )
  • agent To the end NMS End report data
  • NMS Ask for agent Modify the configuration

1.3 Linux Enable on snmp

#  Install related packages 
yum install -y net-snmp net-snmp-utils net-snmp-libs

#  Define profile 
vim /etc/snmp/snmpd.conf
#  For the convenience of , Dry and crisp is defined as  .1.3.6.1.2.1   , Put the last one 1 Get rid of 

#  Start the service 
systemctl start snmpd      #  Services opened by the monitored end , Monitor in  161/udp  On 
systemctl start snmptrapd  #  Monitoring the services opened by the terminal ( If the monitored end is allowed to start active monitoring, enable )

1.4 snmp Configuration file

1) Profile Overview

  1. Define the authenticator , Name the community "public" The opposite is " Security name "
  2. Map the security name to a group name
  3. Create a view for us , Let our team have rights

2)OID(Object ID)

  • 1.3.6.1.2.1

The last one 1 It means to follow Internet Related to , From here, define the related objects of a host , Specifically :

1:system
    # 1.3.6.1.2.1.1

2:interface
    # 1.3.6.1.2.1.2

4:ip
    # 1.3.6.1.2.1.4

6:tcp
    # 1.3.6.1.2.1.6

7:udp
    # 1.3.6.1.2.1.7

1.5 To configure SNMP Monitoring

1) Configure and start snmp

#  Modify configuration file 
[[email protected]_110 ~]# vim /etc/snmp/snmpd.conf
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.2      #  Information about the network interface 
view    systemview    included   .1.3.6.1.4.1.2021   #  System resource load ,memory, disk io, cpu load 
view    systemview    included   .1.3.6.1.2.1.25
#  If you don't want to define so much , For the convenience of , You can directly define a  .1.3.6.1.2.1

#  Then start snmp
[[email protected]_110 ~]# systemctl start snmpd

2) Add a new one snmp Interface and configure templates

 

2. Zabbix Based on JMX Monitoring

2.1 JMX summary

Java Virtual machines (JVM) With built-in plug-in , To enable the use of JMX Monitor and manage it , You can also use JMX Monitoring instrumented applications

JMX(Java Management Extensions)Java Manage extensions

2.2 JMX Monitoring the configuration process

1)zabbix-java-gateway Host settings

#  On some host ( It doesn't have to be in Zabbix_Server On ) Install zabbix-java-gateway Program package 
yum install -y zabbix-java-gateway

#  Yes zabbix-java-gateway Configure , You don't need to configure it , Direct start 
vim /etc/zabbix/zabbix_java_gateway.conf
  Listen_IP=10.0.0.110  #  Monitor address , It can be modified to 0.0.0.0
  Listen_PORT=10052     #  Monitoring zabbix_java The port of the program , The default is 10052
  TIMEOUT=10            # zabbix_java Time out of 

#  Start zabbix-java-gateway
systemctl start zabbix-java-gateway.service

2) To configure zabbix-server Visit java-gateway

JavaGateway=10.0.0.110   # namely  zabbix server IP Address 
JavaGatewayPort=10052
StartJavaPollers=5  #  The number of polling with the boot program 

# After the configuration is completed, you need to restart zabbix-server

3) Turn on JMX Remote monitoring

vim /usr/local/tomcat/bin/catalina.sh  #  If it is yum Installed tomcat, To be in /etc/sysconfig/tomcat Revision in China 
# Enable JVM Interface , Default not enabled 
export CATALINA_OPTS=$CATALINA_OPTS "-Djava.rmi.server.hostname=10.0.0.110 
    -Djavax.management.builder.initial= -Dcom.sun.management.jmxremote=true   
    -Dcom.sun.management.jmxremote.port=12345   #  It may need to be modified here     
    -Dcom.sun.management.jmxremote.ssl=false  
    -Dcom.sun.management.jmxremote.authenticate=false"    

###
jmx[object_name,attribute_name]
object name        #  It represents MBean Object name of 
attribute name -   #  One MBean Property name , Optional compound field names are separated by dots 
#  Example :jmx["java.lang:type=Memory","HeapMemoryUsage.used"]

#  After the configuration is completed, you need to restart tomcat

4) stay web Above definition JMX Monitoring

and SNMP identical , Just define one JMX Interface that will do , Then add a new JMX Of templates, The other operations are exactly the same

2.3 Import from the outside Templates Templates

  • Search for relevant monitoring templates :https://share.zabbix.com/

3. Zabbix Decentralized monitoring  

3.1 Overview of Distributed Monitoring

1)Zabbix The three architectures of

  • Server-agent
  • Server-Node-agent: Using nodes (node)
  • Server-Proxy-agent: Using agents (proxy)

zabbix It can effectively monitor decentralized IT Architecture , In a large environment zabbix Offer two solutions :proxy and node

2) Proxy or Node

agent (proxy) For data collection in this area , And send the data to server

Node (node) Provide complete zabbix server It is used to establish the hierarchy in decentralized monitoring

3.2 Using nodes (node)

Node (node) Provide complete Zabbix Server It is used to establish the hierarchy in decentralized monitoring

Node It's a server, It has whole web Page , Complete database , It sends data sources to Master

  • To solve host Too many single stations Server Facing the problem of performance bottleneck
  • Use multiple instance, Every instance It's a separate set zabbix, Yes database and Frontent(optional)
  • Hot support ,Node and Server Can be disconnected at any time , But it doesn't affect Node The normal execution of
  • Node Give it regularly Server Transmit configuration、history、event
  • Server Give it regularly Node Transmit configuration
  • All configuration changes can only be made in Node Node operation , Can't be in Server operation
  • Support tree structure ,Node It could be another Server

3.3 Using agents (proxy)

agent (proxy) For local data phones , And send the data to server

Proxy Only one proxy Of daemon Program ,Proxy It also has its own database , But its database only stores data for a certain period of time , It is associated with Master Communication is to package and send a batch of information to Master,Master Put this information merge Such as Master Database

  • Proxy Not to Server Sync configuration , Only accept
  • Proxy The database will send data to the Server,Proxy The local database only stores data that has not been sent recently

Master-Proxy comparison Master-Node First of all :

  • Proxy Less pressure , The database only stores data for a certain period of time
  • Master Less pressure , Information is not constantly available , Reduce IO Pressure
  • The architecture is clearer , Easy to maintain

3.4 Server-Proxy-agent Configuration example

1) stay proxy Install the software package on the host

yum install -y zabbix-proxy zabbix-proxy-mysql zabbix-get zabbix-agent zabbix-sender

2) For proxy Set up a database and authorize

#  Build a database 
create database zabbix_proxy character set utf8;

#  Create users and authorize 
grant all on zabbix_proxy.* to [email protected]'10.0.%.%' identified by 'woshiniba'

#  Reorganize the license rights 
flush privileges

3) Import sql Archives

  • zabbix-proxy-mysql The bag contains

#  Copy and unzip 
cp /usr/share/doc/zabbix-proxy-mysql-3.4.4/schema.sql.gz ./  
gzip -d schema.sql.gz 

#  Import data , Import to just built zabbix_proxy In Library 
mysql -root -p zabbix_proxy < schema.sql 

4) Configure and enable zabbix-proxy

###  To configure zabbix-proxy
vim /etc/zabbix/zabbix_proxy.conf

Server=10.0.0.202             # server  Of IP
ServerPort=10051              # server  The port of 

Hostname=zbxproxy.hgzero.com  #  Host name 
ListenPort=10051              # proxy My own monitoring port 
EnableRemoteCommands=1        #  Allow remote commands 
LogRemoteCommands=1           #  Log remote commands 

#  Data configuration 
DBHost=10.0.0.88             
DBName=zabbix_proxy 
DBUser=zbxuser
DBPassword=woshiniba

ConfigFrequency=30      #  How long , Go to the server to drag once and have its own monitoring operation configuration ; For the experiment to work faster , It's set here 30 second , Presupposition 3600s
DataSenderFrequency=1   #  Every second to server  Send data once , Transmission frequency 

###  Start zabbix-proxy
systemctl start zabbix-proxy

5) Through proxy Operation on the agent's node

  • Suppose you have a node node2, Through proxy agent
#  stay node2 Of zabbix_agent Fill in the configuration file Zabbix Server and Proxy The address of 
vim /etc/zabbix/zabbix_agentd.conf
    Server=10.0.0.88,10.0.0.202
    ServerActive=10.0.0.88,10.0.0.202

6) stay web Create configuration on agent agent

  •   This is the time to build Host When , You can see just configured proxy 了 , You can choose whether to pass proxy To monitor

4. Zabbix Send alarm information through wechat

4.1 Register enterprise wechat and configure

1) Registered enterprise wechat

  • Registered address :https://work.weixin.qq.com/wework_admin/register_wx

  •   After successful registration, enter the background for configuration

2) Add alarm group and add members

3) Record the business ID

4) Create the application and fill in the relevant information

 

 

4.2 To configure Zabbix Server

1) Confirm the information just recorded

The account number of the alarm group user 、 Enterprise ID、 Building applications Secret、Agentld

2) Download message push scripts and test

  • Script address :https://github.com/OneOaaS/weixin-alert
  • You can also choose other instruction code or develop your own instruction code

After downloading the script , Store the instruction code in  /usr/lib/zabbix/alertscripts After , Modify permission and ownership group :

chmod 755 wechat
chown zabbix.zabbix wechat

Test code :

[[email protected]_node_02 alertscripts]# ./wechat --corpid=wwd43fee2ab4dbfb21 
    --corpsecret=pa2dgtdf8V0lFWwYaoG62345g_R39dodmK37RPJeOMOs 
    --msg=" Now the alarm test is in progress " 
    --user=hgzerowzh 
    --agentid=1000002
{"errcode":0,"errmsg":"ok","invaliduser":""}


#  The argument says 
-corpid=  In our enterprise id
--corpsecret=  Here we are Secret Inside id
-msg=  Content 
-user= We invite the user's account 
  • Be careful : After the instruction code is placed , To restart zabbix-server

3) stay Zabbix Server Add alarm media on

4) Add alarm media to the corresponding user

5) establish Action

establish Action When , stay “ operation ” Middle selection “Send Message”, And through “ Wechat alarm ” To the user

 

#  Operation information content 
 The fault happened :{TRIGGER.NAME}
 Failure host :{HOSTNAME1}
IP Address :{HOST.CONN} 
 Alarm time :{EVENT.DATE}{EVENT.TIME} 
 Alarm level :{TRIGGER.SEVERITY} 
 Warning information :{TRIGGER.NAME} 
 Alarm Project :{TRIGGER.KEY1} 
 Details of the question :{ITEM.NAME} : {ITEM.VALUE} 
 The current state :{TRIGGER.STATUS} : {ITEM.VALUE1} 
 event ID:{EVENT.ID}

#  Restore operation information content 
 Fault recovery :{HOSTNAME1}  Has recovered !
IP Address :{HOST.CONN} 
 Alarm time :{EVENT.DATE}{EVENT.TIME} 
 Alarm level :{TRIGGER.SEVERITY} 
 Warning information :{TRIGGER.NAME} 
 Alarm Project :{TRIGGER.KEY1} 
 Details of the question :{ITEM.NAME} : {ITEM.VALUE} 
 The current state :{TRIGGER.STATUS} : {ITEM.VALUE1} 
 event ID:{EVENT.ID}

6) Wechat accepts information review

After an active trigger event , To check whether wechat can receive information

5. Zabbix Tuning related

5.1 Zabbix Tuning

1)Database

Don't store historical data for too long ;

Try to cache the data in the memory of the database server ;

2) Trigger expression

Reduce the use of aggregate functions min(), max(), avg(); Try to use last(),nodata(), Because the aggregate function , To calculate

Data collection :polling Slow ( Reduce the use of SNMP/agentless/agent); Try to use trapping(agent(active) Active monitoring );

Data type : The processing speed of text data is slow ; Try to collect as few types as possible text or string Type data ; Multi use type is numeric Numerical data Of ;

5.2 zabbix Server procedures

1) Number of server components

alerter, discoverer, escalator, http poller, hourekeeper, icmp pinger, ipmi polller, poller, trapper, configration syncer, ...

StartPollers=60
StartPingers=10
  ...
StartDBSyncer=5
  ...

2) Set a reasonable cache size

CacheSize=8M
HistoryCacheSize=16M
HistoryIndexCacheSize=4M
TrendCacheSize=4M
ValueCacheSize=4M

3) Database optimization

#  table :
    history_*

    trends*

    events*

5.3 Other solutions

#  Other solutions ,grafana+collectd+influxdb
grafana: Exhibition 
collectd: collect 
influxdb: Store 

# prometheus
exporter: collect 
alertmanager:
grafana: Exhibition 

 

 

 

版权声明
本文为[itread01]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201207110945461e.html