In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Zabbix server side: centos7.6
Turn off the firewall and selinux, set the time zone and time synchronization
~] # systemctl stop firewalld
~] # systemctl disable firewalld
~] # setenforce 0
~] # vim / etc/sysconfig/selinux
SELINUX=disabled # change enforcing to disabled
# timedatectl set-timezone Asia/Shanghai
~] # yum-y install chrony
~] # vim / etc/chrony.conf
Server ntp1.aliyun.com iburst # modified to ntp server of Aliyun
~] # systemctl restart chronyd
Replace the yum source with Ali Cloud Source
~] # mv / etc/yum.repos.d/CentOS-Base.repo / etc/yum.repos.d/CentOS-Base.repo.backup
~] # curl-o / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
~] # curl-o / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
~] # yum makecache
Third, install the LAMP environment
~] # yum-y install mariadb mariadb-server httpd php php-mysql
~] # systemctl start httpd mariadb
~] # systemctl enable httpd mariadb
~] # mysql_secure_installation
Fourth, install the zabbix program, choose 3.0LTS (long-term maintenance version)
~] # rpm-Uvh https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
~] # yum clean all
~] # yum-y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
Initialize the database:
~] # mysql-uroot-p
MariaDB [(none)] > create database zabbix character set utf8 collate utf8_bin
MariaDB [(none)] > grant all privileges on zabbix.* to zabbix@localhost identified by 'password'; # where password is the database password of zabbix, set it by yourself
MariaDB [(none)] > quit
~] # zcat / usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql-uzabbix-p zabbix # enter the password of zabbix user
~] # vim / etc/zabbix/zabbix_server.conf
DBPassword=password # enter the password of the zabbix user
~] # vim / etc/httpd/conf.d/zabbix.conf
Php_value date.timezone Asia/Shanghai # enter the correct time zone information
~] # systemctl restart zabbix-server zabbix-agent httpd
~] # systemctl enable zabbix-server zabbix-agent httpd
5. The browser initializes the web of zabbix
~] # vim / etc/httpd/conf/httpd.conf
DocumentRoot "/ usr/share/zabbix"
~] # systemctl restart httpd
To access http://server-ip, the default account is Admin and the password is zabbix. Attention to production environment: 1, modify Admin password; 2, shut down guest users.
Sixth, due to many template support problems in 3.0, so upgrade to 4.0LTS here.
Aliyun's zabbix repository source package:
Https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
Please refer to the official upgrade guide:
Https://www.zabbix.com/documentation/4.0/zh/manual/installation/upgrade/packages/rhel_centos
7. Add Chinese support to avoid Chinese garbled problems: the difference between 3.0and 4.0path: / usr/share/zabbix/fonts/ 4.0path: / usr/share/zabbix/assets/fonts/
The following example is the 4.0LTS version
Find a windows host: win+R, enter fonts (that is, C:\ Windows\ Fonts), and select a font (here example: Arial routine)
Upload font file to zabbix-server by dragging: premise ~] # yum-y install lrzsz
~] # mv simsun.ttc / usr/share/zabbix/assets/fonts/song.ttf
~] # chmod adepx / usr/share/zabbix/assets/fonts/song.ttf
~] # vim / usr/share/zabbix/include/defines.inc.php
Define ('ZBX_GRAPH_FONT_NAME',' song'); # modify the font graphfont to song
Common monitoring methods:
First, monitor through agent:
1. Install the zabbix-agent program and set the configuration file
Centos 7
~] # rpm-Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.15-1.el7.x86_64.rpm
~] # vim / etc/zabbix/zabbix_agentd.conf
Server=172.20.120.214 # set server IP
# ServerActive=172.20.120.214 # active mode is not enabled here, so comments (active mode is where the client actively sends data to the server)
Hostname=172.20.120.182 # sets the name of the client
~] # systemctl start zabbix-agent
~] # systemctl enable zabbix-agent
Centos6
~] # sudo rpm-Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/6/x86_64/zabbix-agent-4.0.15-1.el6.x86_64.rpm
~] # hostip= `ip addr l | grep eth0 | grep inet | awk-F "/"'{print $1}'| awk'{print $2}'`# the network card obtained here is eth0. Please modify it as needed.
[] # sudo sed-I-e Universe 127.0.0.1Universe 172.20.120.214 g'-e s/Hostname=Zabbix server/Hostname=$hostip/g / etc/zabbix/zabbix_agentd.conf
~] # sudo service zabbix-agent start
~] # sudo chkconfig zabbix-agent on
2. Add the mode to web monitoring:
A, add manually
Access web http://server-ip: configure-CVM-create CVM-set CVM related information: as shown in figure
B, automatic discovery
Steps:
1. Set the actions to be taken after automatic discovery
Access web http://server-ip: configure-Action-event Source (Auto-Discovery)-create Action
2. Set auto-discovery rules
Access http://server-ip on the web: configure-automatically discover-create discovery rules
Zabbix monitors nginx performance
1. Check whether there is a with-http_stub_status_module for this module.
~] # nginx-V
2. Configure the nginx status page
~] # vim / etc/nginx/nginx.conf
Location / ngx_status {
Stub_status on
Access_log off
Allow 127.0.0.1
}
~] # systemctl reload nginx
Test whether you can get the status page
~] # curl http://127.0.0.1/ngx_status
The fields are explained as follows:
Active connections: indicates the number of active connections being processed by Nginx.
Server: indicates how many connections have been processed by Nginx since its startup
Accepts: indicates how many handshakes have been successfully created since Nginx was launched
Handled requests: indicates the total number of requests processed
Reading: the number of Header messages read by Nginx to the client
Writing: the number of Header messages returned by Nginx to the client
Waiting: Nginx has finished processing the resident link waiting for the next request instruction (when keep-alive is turned on, this value is equal to Active- (Reading+Writing))
Therefore, when the access efficiency is high and the request is processed quickly, it is normal to have a large number of Waiting. If there are a large number of reading + writing, the concurrent traffic is very large and is in the process of being processed.
3. Write a monitoring script
~] # vim / etc/zabbix/ngx_status.sh
#! / bin/bash
HOST= "127.0.0.1"
PORT= "80"
# detect whether the nginx process exists
Function ping {
/ sbin/pidof nginx | wc-l
}
# testing nginx performance
Function active {
/ usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2 > / dev/null | grep 'Active' | awk' {print $NF}'
}
Function reading {
/ usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2 > / dev/null | grep 'Reading' | awk' {print $2}'
}
Function writing {
/ usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2 > / dev/null | grep 'Writing' | awk' {print $4}'
}
Function waiting {
/ usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2 > / dev/null | grep 'Waiting' | awk' {print $6}'
}
Function accepts {
/ usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2 > / dev/null | awk NR==3 | awk'{print $1}'
}
Function handled {
/ usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2 > / dev/null | awk NR==3 | awk'{print $2}'
}
Function requests {
/ usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2 > / dev/null | awk NR==3 | awk'{print $3}'
}
# execute function
, 1
~] # chmod adepx / etc/zabbix/ngx_status.sh
Test script
~] # bash / etc/zabbix/ngx_status.sh requests
4. Zabbix-agent configuration file
~] # vim / etc/zabbix/zabbix_agentd.conf
UnsafeUserParameters=1
UserParameter=nginx.status [*], / etc/zabbix/ngx_status.sh $1
~] # systemctl restart zabbix-agent
~] # systemctl enable zabbix-agent
Zabbix server side test
~] # yum-y install zabbix-get
~] # zabbix_get-s 172.20.120.56-k 'nginx.status [accepts]' #-s followed by agent-ip,-k followed by custom key
5. Zabbix web terminal
Download template: https://pan.baidu.com/s/1CCaIURk-kXAcEXJ6BD-TEA
Import template
Host configuration
Host add template (Template App NGINX)
Second, monitor through snmp:
Zabbix Monitoring Dell Server hardware (iDRAC)
1. Dell server
Log in to iDRAC by browser
Enable SNMP
Click "iDRAC"-- "Network"-- "Service"-- "SNMP Agent"
Check "enabled" and click "apply"
2. Zabbix web terminal
Download template: https://pan.baidu.com/s/1CCaIURk-kXAcEXJ6BD-TEA
Import template
Host configuration SNMP interfaces
Host add template Dell iDRAC; Note: the setting of the macro needs to correspond (that is, the value of SNMP community should correspond).
Zabbix monitors Huawei switches and firewall devices
1. Enable the snmp function in the switch and firewall, and set SNMP community
2. Zabbix web terminal
Download template: https://pan.baidu.com/s/1CCaIURk-kXAcEXJ6BD-TEA
Import template
Host configuration SNMP interfaces
Host add template (Template Net Huawei VRP SNMPv2) Note: the setting of the macro needs to correspond (that is, the value of SNMP community should correspond).
Monitoring of windows server:
1. Install the agent client; download address https://assets.zabbix.com/downloads/4.0.15/zabbix_agents-4.0.15-win-amd64-openssl.zip on the official website
Decompress zabbix_agents-4.0.15-win-amd64-openssl.zip
The conf directory is an agent configuration file
Bin files are stored in windows programs.
Modify the zabbix_agentd.conf file in the conf directory
LogFile=c:\ zabbix_agentd.log / / Log location
EnableRemoteCommands=1 / / allows local execution of remote commands
LogRemoteCommands=1 / / whether the operation log is saved when executing remote commands
Server=172.20.120.214 / / zabbix_server host IP address
# ServerActive=192.168.1.10 / / since active mode is not enabled, you can simply comment
Hostname=* / / monitored hostname, own hostname
Open a command prompt to install
C:\ zabbix\ bin\ zabbix_agentd.exe-I-c c:\ zabbix\ conf\ zabbix_agentd.conf
C:\ zabbix\ bin\ zabbix_agentd.exe-s-c c:\ zabbix\ conf\ zabbix_agentd.conf
After the installation, the zabbix-agent service is available in the service.
Finally, remember to set up a firewall to allow zabbix-agent interconnection
Windows supplement points:
There is no cpu usage monitoring item in the default windows template, which is added as follows:
Name: CPU usage%
Key value: perf_counter [\ Processor (_ Total)\% Processor Time]
Information type: floating point number
Unit:%
Problem: unable to get cpu utilization. Server log: Collector is not started
Solution: rebuild the performance counter settings: the administrator can execute the lodctr / R command
Set the alarm mode:
1. Email alarm:
1. Management-alarm media type-create media type
2. Management-user-alarm medium-add
3. Configure-Action-event Source: trigger-create Action
The operation contents are as follows:
Failure {TRIGGER.STATUS}, server: {HOSTNAME1} occurred: {TRIGGER.NAME} failure!
Alarm message:
Alarm host: {HOSTNAME1}
Alarm time: {EVENT.DATE} {EVENT.TIME}
Alarm level: {TRIGGER.SEVERITY}
Alarm message: {TRIGGER.NAME}
Alarm item: {TRIGGER.KEY1}
Question details: {ITEM.NAME}: {ITEM.VALUE}
Current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
Event ID: {EVENT.ID}
The restore operation is as follows:
Restore {TRIGGER.STATUS}, server: {HOSTNAME1}: {TRIGGER.NAME} has been restored!
Recovery information:
Alarm host: {HOSTNAME1}
Alarm time: {EVENT.DATE} {EVENT.TIME}
Alarm level: {TRIGGER.SEVERITY}
Alarm message: {TRIGGER.NAME}
Alarm item: {TRIGGER.KEY1}
Question details: {ITEM.NAME}: {ITEM.VALUE}
Current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
Event ID: {EVENT.ID}
The update operation is as follows:
Update information: {EVENT.NAME}
Update information:
{USER.FULLNAME} {EVENT.UPDATE.ACTION} problem at {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.
{EVENT.UPDATE.MESSAGE}
Current problem status is {EVENT.STATUS}, acknowledged: {EVENT.ACK.STATUS}.
Finally, a fault test is carried out to verify whether the transmission is successful. Viewing: report-Action Log
2. Aliyun SMS alarm: here is an example of using python3.6+ (there is garbled code in Chinese SMS messages in python2)
1. CentOS7 upgrade Python2.x to 3.x
~] # python-V # View the current python version
~] # yum-y install python3
~] # mv / usr/bin/python / usr/bin/python.bak
~] # ln-sv / usr/bin/python3 / usr/bin/python
To be compatible with yum: modify the / usr/bin/yum and / usr/libexec/urlgrabber-ext-down files, change #! / usr/bin/python to #! / usr/bin/python2.7
2. Install Aliyun SDK core library:
~] # pip3 install aliyun-python-sdk-core
3. Aliyun SMS service, apply for SMS signature and template: pass three parameters here: ${host}, ${time}, and ${item}.
4. Write python scripts and test
~] # vim / usr/lib/zabbix/alertscripts/sendsms.py
#! / usr/bin/env python
#-*-coding: utf-8-*-
From aliyunsdkcore.client import AcsClient
From aliyunsdkcore.request import CommonRequest
Import sys
Client = AcsClient ('','', 'default') # fill in the accesskey information here, and the obtained address is https://usercenter.console.aliyun.com
Request = CommonRequest ()
Request.set_accept_format ('json')
Request.set_domain ('dysmsapi.aliyuncs.com')
Request.set_method ('POST')
Request.set_protocol_type ('https') # https | http
Request.set_version ('2017-05-25')
Request.set_action_name ('SendSms')
# the first parameter passed by zabbix is the sender number, and the second parameter message information is cut into three variables: host, time, item
String = sys.argv [2]
Phone_number = sys.argv [1]
Message = string.split (";")
Dict1 = {}
Dict1 ['host'] = message [0]
Dict1 ['time'] = message [1]
Dict1 ['item'] = message [2]
Request.add_query_param ('RegionId', "cn-hangzhou")
Request.add_query_param ('PhoneNumbers',phone_number)
Request.add_query_param ('SignName', "signature name") # fill in the signature name of the application
Request.add_query_param ('TemplateCode', "template CODE") # fill in the applied template CODE
Request.add_query_param ('TemplateParam',dict1)
Response = client.do_action (request)
# python2: print (response)
Print (str (response, encoding = 'utf-8'))
~] # chmod adepx / usr/lib/zabbix/alertscripts/sendsms.py
~] # python / usr/lib/zabbix/alertscripts/sendsms.py Mobile phone number 'official website; 18Drex03Test' # Parameter 1: mobile phone number; Parameter 2:3 parameters are separated by;
5. Zabbix web settings
Management-alarm media type-create media type
Management-user-alarm medium-add
Configure-Action-event Source: trigger-create Action
Message content:
{TRIGGER.NAME}: {TRIGGER.KEY1}; {EVENT.TIME}; {TRIGGER.STATUS}
Finally, a fault test is carried out to verify whether the transmission is successful. Viewing: report-Action Log
Third, the nail group alarms:
Official reference document: https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq
1. Nail group, add custom webhook robot, copy webhook address; note that the new version of nail has security settings. Example Select Custom keywords: monitorin
2. Create a script
~] # vim / usr/lib/zabbix/alertscripts/dingding.sh
#! / bin/bash
To=$1
Subject=$2
Text=$3
Curl 'webhook address'\ # the address here is the webhook address of the robot
-H 'Content-Type: application/json'\
-d'
{"msgtype": "text"
"text": {
"content": "" $text ""
}
"at": {
"atMobiles": ["" $1 ""]
"isAtAll": false
}
}'
~] # chmod adepx / usr/lib/zabbix/alertscripts/dingding.sh
~] # chown zabbix:zabbix / usr/lib/zabbix/alertscripts/dingding.sh
~] # bash / usr/lib/zabbix/alertscripts/dingding.sh 1 2 Monitoring # the third parameter must contain a custom keyword, otherwise it fails
3. Set alarm media, users and actions as above.
Script parameters in order are: {ALERT.SENDTO}, {ALERT.SUBJECT}, {ALERT.MESSAGE}
The content of the message is consistent with the email alarm.
The recipient can fill in the mobile phone number.
Finally, a fault test is carried out to verify whether the transmission is successful. Viewing: report-Action Log
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.