Zabbix-build + email alarm

Zabbix3.4.7 deployment
System environment: CentOs7.2
1. Turn off selinux
1.1 [root@localhost ~]# setenforce 0 #Temporary shutdown
1.2 [root@localhost ~]# vi /etc/selinux/config #Change selinux=enforcing to SELINUX=disabled #Permanent shutdown
 
2. Turn off the firewall
2.1 [root@localhost ~]# systemctl stop firewalld.service #Stop the firewall
2.2 [root@localhost ~]# systemctl disable firewalld.service #Disable self-start at boot
 
3.zabbix3.4 program installation
3.1 Configure the yum source of zabbix
[root@localhost ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
3.2 Install the zabbix package, install mysql, zabbxi-agent
[root@localhost ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server
3.3 Start mariadb and set startup, create database instance, authorize
[root@localhost ~]# systemctl start mariadb #启动mariadb
[root@localhost ~]# systemctl enable mariadb #Set boot up
[root@localhost ~]# mysql #Log in to the database
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
#Create database instance
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';
#Authorize all hosts to access the database instance zabbix, username/password: zabbix/zabbix
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
#Authorize the localhost hostname to access the database instance zabbix, username/password: zabbix/zabbix
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by 'zabbix'; #Authorize localhost.localdomain host to access database instance zabbix, username/password: zabbix/zabbix
Query OK, 0 rows affected (0.00 sec)
 
4. Import initial schema and data
4.1 Enter the directory where create.sql.gz is located
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.4/
4.2 Import accident mode
[root@localhost zabbix-server-mysql-3.4.4]# zcat create.sql.gz |mysql -uroot zabbix
 
5. Start the zabbix-server service
5.1 Start the zabbix-server service
[root@localhost zabbix-server-mysql-3.4.4]# systemctl start zabbix-server
5.2 Set the zabbix-server service to start automatically at boot
[root@localhost zabbix-server-mysql-3.4.4]# systemctl enable zabbix-server
Where
6. Edit the Apache configuration file, uncomment to set the correct time zone
[root@localhost zabbix-server-mysql-3.4.4]# vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
 
7. Start the httpd service, and set the boot to start the httpd service
7.1 Start httpd service
[root@localhost ~]# systemctl start httpd
7.2 Set the boot to start the httpd service
[root@localhost ~]# systemctl enable httpd
 
8.zabbix web page installation
8.1 Enter the address http://server ip/zabbix/setup.php in the browser, the welcome interface appears, click Next;
8.2 The necessary condition detection interface appears, normally it is OK, click Next;
 
8.3 Configure the DB connection, which is consistent with the host, database name, user name, and password in the zabbix_server.conf file, and click Next;
8.4 zabbix server details, click Next;
 
8.5 Summary before installation, check the information is correct, click Next to install;
 
8.6 The installation is successful;
Congratulations! You have successfully installed Zabbix frontend.
config file directory
Configuration file "/etc/zabbix/web/zabbix.conf.php" created.
8.7 Enter http://zabbix server ip/zabbix/index.php in the browser, enter the administrator username Admin (case-sensitive), the default password zabbix, and click to log in.
 
 
 
 
Solve the garbled characters in the graphical interface
1. Control Panel-->Fonts-->Select a Chinese font such as "Kaiti" (simkai.ttf)
2. Upload our downloaded fonts to the /usr/share/zabbix/fonts directory on the zabbix server side
3. Modify the font configuration in the /usr/share/zabbix/include/defines.inc.php file and replace the graphfont inside with simkai
 
4. After saving and exiting, refresh the interface to display normally
 
 
 
zabbix email alarm
1. Install the package
[root@localhost ~]# yum -y install mailx
2. Set permissions for the /bin directory
[root@localhost ~]# Chown -R zabbix.zabbix /bin/mail
3. Edit /etc/mail.rc
[root@localhost ~]# vim /etc/mail.rc
set smtp=smtp.163.com
set [email protected] #Email account
set smtp-auth-password=cheng12345 #Client authorization code
set smtp-auth=login
4. Test whether there is a problem with the mailx configuration
[root@localhost ~]# echo test | mail -s "my name is chengwangan" [email protected] #This inbox is for receiving mail
5. Edit zabbix_server.conf, configure the script storage directory
[root@localhost zabbix]# cd /etc/zabbix/
[root@localhost zabbix]# vim zabbix_server.conf
AlertScriptsPath=/usr/lib/zabbix/alertscripts #Here I choose the default directory
6. Edit Email Script
[root@localhost zabbix]# vim /usr/lib/zabbix/alertscripts/mailx.sh
#!/bin/bash
messages=`echo $3 | tr '\r\n' '\n'`
subject=`echo $2 | tr '\r\n' '\n'`
echo "${messages}" | mail -s "${subject}" $1 >>/tmp/mailx.log 2>&1
7. Increase the executable permission and test, the mail log can be seen in /tmp/mailx.log
[root@localhost ~]# touch /tmp/mailx.log
[root@localhost ~]# chmod 777 /tmp/mailx.log
[root@localhost ~]# chown -R zabbix.zabbix /tmp/mailx.log
[root@localhost ~]# chmod -x /usr/lib/zabbix/alertscripts/mailx.sh
[root@localhost ~]# chown -R zabbix.zabbix /usr/lib/zabbix/
8. Test whether the script mail can be sent normally
[root@localhost alertscripts]# sh mailx.sh [email protected]
9. zabbix web interface configuration
Manage-->Alarm Media Type-->Create Media Type
Three necessary parameters:
{ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}
 
10. User Alarm Configuration
Admin-->Users-->Admin-->Alarm Media-->Add
 
 
11. Add alarm action
Configure --> Actions --> Create Action
Default recipient: {TRIGGER.STATUS}: {TRIGGER.NAME}
Host: {HOST.NAME}
IP:{HOST.IP}
Trigger:{TRIGGER.NAME}
Trigger status:{TRIGGER.STATUS}
Trigger severity:{TRIGGER.SERERITY}
Original event ID:{EVENT.ID}
 
Recovery operation:
Default recipient: {TRIGGER.STATUS}: {TRIGGER.NAME}
Host: {HOST.NAME}
IP:{HOST.IP}
Trigger:{TRIGGER.NAME}
Trigger status:{TRIGGER.STATUS}
Trigger severity:{TRIGGER.SERERITY}
Original event ID:{EVENT.ID}
 
 
12. Testing
After we close zabbix_agentd, see if we can receive an email alert
[root@localhost alertscripts]# systemctl stop zabbix-agent.service
An error is reported here, the script does not have permission to execute, we need to give the script 555 permission
[root@localhost alertscripts]# chmod 555 mailx.sh
Start zabbix-agent, stay for a minute, then close and re-trigger
[root@localhost alertscripts]# systemctl start zabbix-agent.service
[root@localhost alertscripts]# systemctl stop zabbix-agent.service
 
The email has been sent, we log in to 163 mailbox to check
 
 
 
zabbix-agent client installation
1. Install zabbix-agent
#Agent side
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-agent-3.0.4-1.el7.x86_64.rpm
2. Backup and change the zabbix-agent configuration file
[root@localhost ~]#cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_$(date +%F)
[root@localhost ~]# sed -i 's/Server=127.0.0.1/Server=192.168.0.125/g' /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]# sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.0.125/g' /etc/zabbix/zabbix_agentd.conf
4. Modify zabbix-agent.conf information
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.4.182 #Fill in the Server IP
ServerActive=192.168.4.182 #Fill in the monitor IP
Hostname=zabbix server #Fill in the username when the monitor side created the host
5. Set up self-start at boot and start the zabbix client
systemctl start zabbix-agent
systemctl enable zabbix-agent
#Server side
1. Add the identity information of the monitored host
Interface operation: Configuration-->Host-->Create host
Fill in the Agent information
The hostname must be the same as the Hostname on the Agent side
The Agent port must be the same as the Server=XXX.XXX.XXX.XXX on the Agent side
2. Click on the template next to the host to add the following
Template App Zabbix Server
Template OS Linux
 
3. When ZBX turns green, it means we have successfully monitored this host
4. Monitor-->Graphics-->Select the host you just created, let's take a look at its network card traffic trend
 
This article is from https://note.youdao.com/share/?id=ae959d5e9dcb4fe26ec7139f48c5b108&type=note#/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325861739&siteId=291194637