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

CentOS 7.7 yum installation and configuration Zabbix 4.0 LTS details (2)

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

First, add Linux hosts, customize monitoring items, triggers and use built-in templates for monitoring:

1. Node-122 node deploys Zabbix Agent:

(1) install zabbix-agent package: # yum-y install zabbix-agent

(2) modify the zabbix_agentd.conf configuration file:

# cd / etc/zabbix

# cp zabbix_agentd.conf {, .bak}

# vim zabbix_agentd.conf

Before modification

After modification

PidFile=/var/run/zabbix/zabbix_agentd.pid

Keep the default

# LogType=file

LogType=file

LogFile=/var/log/zabbix/zabbix_agentd.log

Keep the default

LogFileSize=0

Keep the default

# EnableRemoteCommands=0

EnableRemoteCommands=1

Server=127.0.0.1

Server=192.168.0.120

# ListenPort=10050

ListenPort=10050

# ListenIP=0.0.0.0

ListenIP=192.168.0.122

ServerActive=127.0.0.1

ServerActive=192.168.0.120

Hostname=Zabbix server

Hostname=node-122

# AllowRoot=0

AllowRoot=0

# User=zabbix

User=zabbix

Include=/etc/zabbix/zabbix_agentd.d/*.conf

Keep the default

# UnsafeUserParameters=0

UnsafeUserParameters=1

(3) start Zabbix Agent:

# systemctl start zabbix-agent

# systemctl status zabbix-agent

# ps aux | grep zabbix_agent

# ss-tunlp | grep-w 10050

# tail-100 / var/log/zabbix/zabbix_agentd.log

(4) configure self-boot: # systemctl enable zabbix-agent

2. Configure Zabbix Web:

Configuration-- > Hosts-- > Create host-- > Add

Because you do not use a template to define monitoring items, the icon for "ZBX" does not turn green

3. Node-122 node defines monitoring items:

(1) Monitor whether port 21 of TCP is listening (built-in Key):

Create Item:

Description: specific usage of Key see synonyms at specific

Https://www.zabbix.com/documentation/4.0/manual/config/items/itemtypes/zabbix_agent

(2) Monitor the root partition disk TPS of the server (custom Key without parameters):

A. Install sysstat package: # yum-y install sysstat

B. Use the awk command to get the value of the server root partition disk TPS: # iostat | awk'$1percent / ^ dm-0 $/ {print $2}'

C. Create a disk_tps.conf configuration file:

# vim / etc/zabbix/zabbix_agentd.d/disk_tps.conf

UserParameter=disk.tps,iostat | awk'$1bn / ^ dm-0 $/ {print $2}'

# systemctl restart zabbix-agent

Note: the command # zabbix_agentd-p | less for Zabbix Agent to view all Key

D, zabbix-server node installs zabbix-get software package and attempts to obtain monitoring data:

# yum-y install zabbix-get

# zabbix_get-s 192.168.0.122-k disk.tps

E. Create monitoring items:

(3) Monitoring server memory usage (customized with parameter Key):

A. Use the awk command to get the server memory usage:

# free-h | awk'$1bn / ^ Mem:$/ {print $2}'

# free-h | awk'$1bn / ^ Mem:$/ {print $3}'

# free-h | awk'$1bn / ^ Mem:$/ {print $4}'

# free-h | awk'$1bn / ^ Mem:$/ {print $NF}'

B. Write the awk command as a script:

# mkdir-pv / scripts

# vim / scripts/check_mem.sh

#! / bin/bash

Case "$1" in

"total")

Free-h | awk'$1bn / ^ Mem:$/ {print $2}'

"used")

Free-h | awk'$1bn / ^ Mem:$/ {print $3}'

"free")

Free-h | awk'$1bn / ^ Mem:$/ {print $4}'

"available")

Free-h | awk'$1bn / ^ Mem:$/ {print $NF}'

*)

Echo "Usage: {total | used | free | available}"

Esac

# chmod + x / scripts/check_mem.sh

C. Create a check_mem.conf configuration file:

# vim / etc/zabbix/zabbix_agentd.d/check_mem.conf

UserParameter=mem.check [*], / scripts/check_mem.sh $1

# systemctl restart zabbix-agent

D. Zabbix-server node attempts to obtain monitoring data:

# zabbix_get-s 192.168.0.122-k mem.check [total]

# zabbix_get-s 192.168.0.122-k mem.check [used]

# zabbix_get-s 192.168.0.122-k mem.check [free]

# zabbix_get-s 192.168.0.122-k mem.check [available]

E. Create monitoring items:

Note: the result obtained from the value of the script, such as 3.8g is neither integer nor floating point, is a string, so Type of information selects "Character". If the free-m command is used in the script, Type of information selects "Numeric (unsigned)" when creating Item, and enter "MB" in Units.

The same cloning Item,Key is mem.check [used], mem.check [free] and mem.check [available], respectively.

View the latest data: Monitoring-- > Latest data

4. Node-122 node defines triggers:

(1) Check TCP 21:

Create trigger:

(2) tps of the root partition: an alarm is triggered when the average value in the last 3 minutes is greater than 1

5. Node-122 nodes use built-in templates for monitoring:

It is too tedious to customize monitoring items and triggers according to the above method

(1) Clone "Template OS Linux" template to "Template OS Linux Active", modify the default type of monitoring items to "Zabbix agent (active)", and use active mode to monitor:

Enter linux in Configuration-- > Templates-- > Name

(2) node-122 node links "Template OS Linux Active" template:

View the latest data:

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

Servers

Wechat

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

12
Report