Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7 teaches you how to set up zabbix monitoring by hand.

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Centos7 installation and deployment zabbix3.4

Centos system version:

1. Close selinux and firewall before installation.

1.1

[root@zabbix ~] # vi / etc/selinux/config

Change SELINUX=enforcing to SELINUX=disabled

Restart is required to take effect after setting.

[root@zabbix ~] # setenforce 0 # temporarily shut down

[root@zabbix ~] # getenforce # check whether selinux is closed, and Disabled is closed

1.2

[root@zabbix ~] # firewall-cmd-- state # View default firewall status

Not running # shows not running when turned off and running when turned on

[root@zabbix ~] # systemctl stop firewalld.service # temporarily shut down firewall

[root@zabbix ~] # systemctl disable firewalld.service # prohibit firewall from booting

2. Configure zabbix program installation

2.1 configure the yum source for zabbix

[root@zabbix ~] # rpm-ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

2.2 install zabbix package, install mysql, zabbix-agent

[root@zabbix ~] # yum install-y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server

2.3Startup mariadb (database) and set boot, create database instance, authorize

[root@zabbix ~] # systemctl start mariadb # start mariadb

[root@zabbix ~] # systemctl enable mariadb # start mariadb when booting

[root@zabbix ~] # mysql # log in to the database

MariaDB [(none)] > create database zabbix character set utf8 collate utf8_bin

# create a 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, user name / 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 localhost hostname to access database instance zabbix, user name / password: zabbix/zabbix

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)] > grant all privileges on zabbix.* to zabbix@localhost.localdomain identified by 'zabbix'

# authorize localhost.localdomain host to access database instance zabbix. Username / password: zabbix/zabbix

Query OK, 0 rows affected (0.00 sec)

Import initial schema and data

[root@zabbix ~] # cd / usr/share/doc/zabbix-server-mysql-3.4.5/ # enter the directory where create.sql.gz is located

[root@zabbix zabbix-server-mysql-3.4.5] # zcat create.sql.gz | mysql- uroot zabbix # Import accident mode

Note: there is no password set in the database here.

2.4. start zabbix-server

2.4.1 configure zabbix-server r profile zabbix-server.conf

[root@zabbix zabbix-server-mysql-3.4.5] # vi / etc/zabbix/zabbix_server.conf

DBHost=localhost # data hostname

DBName=zabbix # database instance

DBUser=zabbix # user name

DBPassword=zabbix # password

Modify the configuration file

2.4.2 start the zabbix-server service

[root@zabbix ~] # systemctl start zabbix-server # start the zabbix-server service

[root@zabbix ~] # systemctl enable zabbix-server # boot up the zabbix-server service.

2.5 Edit the configuration file of Apache and uncomment the correct time zone

[root@zabbix ~] # 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

Modify the configuration file

Start the httpd service and set it to boot to start the httpd service

[root@zabbix ~] # systemctl start httpd # start the httpd service

[root@zabbix ~] # systemctl enable httpd # set boot to start the httpd service

3. Start zabbix-agent and set Boot self-boot

[root@zabbix ~] # systemctl start zabbix-agent # start the zabbix-agent service

[root@zabbix ~] # systemctl enable zabbix-agent # set the zabbix-agent service to boot automatically

4. Install the zabbix web web page

4.1. Enter the address http:// server ip/zabbix/setup.php in the browser, and the welcome screen appears, and click next.

4.2. The necessary condition detection interface appears. Normally, it is OK. Click next.

4.3. Configure the DB connection to be consistent with the host, database name, user name and password in the zabbix_server.conf file, and click next.

For 4.4.zabbix server details, click next.

4.5. Summarize before installation, check the information is correct, and click next to install.

4.6. Installation succeeded

Congratulations! You have successfully installed Zabbix frontend.

Configuration file directory

Configuration file "/ etc/zabbix/web/zabbix.conf.php" created.

5. Log in to the zabbix web page

Enter the http://zabbix server ip/zabbix/index.php in the browser, enter the administrator user name Admin (case sensitive), the default password zabbix, and click Login.

6. Set up zabbix in Chinese

7. Solve the garbled code of Chinese on the graphical interface

7.1 in general, there will still be garbled codes in Chinese.

7.2 because zabbix's own support for simplified Chinese is not perfect, we need to manually upload new fonts for replacement:

Copy the desired font with the suffix ttf in C:\ Windows\ Fonts, and copy the file to the desktop.

Upload the files to the / usr/share/zabbix/fonts directory of the zabbix server and upload the files to the linux system. We can use the software winSCP. Here I directly use the rz-y command to upload.

[root@zabbix fonts] # yum install lrzsz-y # installation command

[root@zabbix fonts] # rz-y

[root@zabbix fonts] # mv graphfont.ttf graphfont.ttf.bak # back up graphfont.ttf

[root@zabbix fonts] # mv simkai.ttf graphfont.ttf # rename simkai.ttf to graphfont.ttf

Then refresh the web page.

8. Zabbix-agent client installation and configuration (windows operating system)

Now that the zabbix-server server is installed, we need to add the operation of the client.

Now the object to be monitored is the 64-bit server 2012 operating system.

8.1 download zabbix-agent Monitoring client Software installation package (windows operating system)

Official download address: http://www.zabbix.com/download

Turn off the monitoring host windows server 2008 firewall or firewall to enter and release the zabbix_agentd client number 10050 (TPC/UDP).

8.3 decompress the zabbix_agents_3.4.0.win.zip package after download. There are two folders in it, one is the bin folder, the other is the conf folder.

There are two folders in the Bin folder, one is the win32 folder that stores zabbix_agentd installers for windows 32-bit operating systems, and the other is the win64 folder for zabbix_agentd installers for windows 64-bit operating systems.

The configuration file zabbix_agentd.win.conf is stored in the Conf folder

8.4 under the windows server 2012 operating system, create a zabbix folder under the C disk directory and copy the win64 bit folder from the zabbix_agentd package you just downloaded to the zabbix folder. Copy the conf folder zabbix_agentd.win.conf to the newly created zabbix directory.

Right-click to edit the zabbix_agentd.win.conf configuration file in text format and use Notrpad++ to edit.

Modify the following items

EnableRemoteCommands=1 # allows remote commands to be executed locally

LogRemoteCommands=1 # whether to save the operation log when executing remote commands

Server=192.168.3.50 # enter the IP address of zabbix-server server

ServerActive=192.168.3.50 # enter the IP address of zabbix-server server

Hostname=server2012 # zabbix_agent client computer name (monitored host)

8.6 Open the DOS command window-enter the following two commands to install the zabbix client. (you must run as an administrator to open the DOS command window)

C:\ zabbix\ zabbix_agentd.exe-I-c C:\ zabbix\ zabbix_agentd.win.conf

# install zabbix client

C:\ zabbix\ zabbix_agentd.exe-s-c C:\ zabbix\ zabbix_agentd.win.conf

# start the zabbix service

8.7 operate on the zabbix server

8.7.1 Select configuration-host-create host.

8.7.2 enter the client computer name-visible name Custom-Group Select-enter the client computing IP address-check enabled-Select add.

8.7.3 add a zabbix_agentd client monitoring template.

8.7.3 check whether the zabbix-agent service is enabled or directly restarted the zabbix-agent service.

9. Zabbix email alarm prompt

9.1 create custom media, and mail scripts

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

AlertScriptsPath=/usr/lib/zabbix/alertscripts # modify the configuration file

[root@zabbix ~] # cd / usr/lib/zabbix/alertscripts/

[root@zabbix alertscripts] # vi zabbix-email.py

#! / usr/bin/python

# coding:utf-8

Import smtplib

From email.mime.text import MIMEText

Import sys

Mail_host = 'smtp.163.com'

Mail_user = '15626866674'

Mail_pass = '15626866674.'

Mail_postfix = '163.com'

Def send_mail (to_list,subject,content):

Me = "zabbix3.4 monitoring and alarm platform" + ""

Msg = MIMEText (content, 'plain',' utf-8')

Msg ['Subject'] = subject

Msg ['From'] = me

Msg ['to'] = to_list

Try:

S = smtplib.SMTP ()

S.connect (mail_host)

S.login (mail_user,mail_pass)

S.sendmail (me,to_list,msg.as_string ())

S.close ()

Return True

Except Exception,e:

Print str (e)

Return False

If _ name__ = = "_ _ main__":

Send_mail (sys.argv [1], sys.argv [2], sys.argv [3])

# add the above and modify the mailbox.

[root@zabbix alertscripts] # chmod + x zabbix-email.py # modify permission

9.2 Management-alarm media type-create media type

Name: zabbix-email

Type: script

Script name: zabbix-email.py

Script parameters: {ALERT.SENDTO}

{ALERT.SUBJECT}

{ALERT.MESSAGE}

{ALERT.URL}

9.3 Management-users, click admin, select alarm media and add

9.4 configuration-actions, edit actions, then add actions, add restore operations.

Operation

Time: 60s

Recipient: problem warning: {TRIGGER.NAME}

Default message: problem warning started at {EVENT.TIME} on {EVENT.DATE}

Problem warning object: {TRIGGER.NAME}

Host: {HOST.NAME}: {HOST.CONN}

Severity: {TRIGGER.SEVERITY}

Original problem ID: {EVENT.ID}

{TRIGGER.URL}

Note: remember to add and send to the user

Restore operation

Recipient: alarm restored: {TRIGGER.NAME}

Default information:

Alarm has been restored to at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}

Alarm recovery object: {TRIGGER.NAME}

Host: {HOST.NAME}: {HOST.CONN}

Severity: HEALTH

Original problem ID: {EVENT.ID}

{TRIGGER.URL}

Note: remember to add and send to the user

9.4 Test

# # ① remember that the client Server-IP points to the IP of the server

Vim / usr/local/zabbix/etc/zabbix_agentd.conf

Server=10.0.0.137

# # ② often fails to receive mail in mailbox because the POP3 service in mailbox settings is not enabled

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.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report