监控服务部署!

1. agent的部署!

    1.1   监控配置流程!!!

在要监控的主机上安装agent
在agentd. conf文件中配置server地址和hostname启动agent
在web界面上添加主机/主机组
添加监控项
         手动创建监控项
         模板添加监控项
添加触发器(定义阈值)
定义媒介(即通知人的方式)
不同的用户选择媒介
为触发器配置动作
手动触发问题
验证

实验环境

 zabbix sever端zabbix agent端
ip192.168.180.129192.168.180.131
主机名cong2lzz

2. 将sever端的zabbix文件传到agent端!

[root@localhost src]# scp zabbix-4.0.30.tar.gz 192.168.180.131:/root/
The authenticity of host '192.168.180.131 (192.168.180.131)' can't be established.
ECDSA key fingerprint is SHA256:MY9S8r/GzYnf3JOQlPTeWKTnR36jcDwfckYHvvBj92Q.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.180.131' (ECDSA) to the list of known hosts.
root@192.168.180.131's password: 
zabbix-4.0.30.tar.gz                                   100%   17MB  77.1MB/s   00:00   

   2.1  在agent端安装!

[root@cong2 ~]# ls
anaconda-ks.cfg       mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
initial-setup-ks.cfg  zabbix-4.0.30.tar.gz
[root@cong2 ~]# groupadd -r zabbix           (创建用户和组!!!)
[root@cong2 ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix



[root@cong2 ~]# yum install -y gcc* make pcre*   (安装插件包!!!)
CentOS Stream 8 - AppStream                              3.6 kB/s | 4.4 kB     00:01    
CentOS Stream 8 - BaseOS                                 3.4 kB/s | 3.9 kB     00:01    
CentOS Stream 8 - Extras                                 2.1 kB/s | 1.5 kB     00:00    
软件包 pcre-8.42-4.el8.x86_64 已安装。
软件包 pcre2-10.32-2.el8.x86_64 已安装。
依赖关系解决。
......
完毕!
[root@cong2 ~]# 




[root@cong2 ~]# tar xf zabbix-4.0.30.tar.gz     (解压文件!!!)
[root@cong2 ~]# ls
anaconda-ks.cfg       mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz  zabbix-4.0.30.tar.gz
initial-setup-ks.cfg  zabbix-4.0.30
[root@cong2 ~]# cd zabbix-4.0.30/
[root@cong2 zabbix-4.0.30]# ./configure --enable-agent
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
configure: Configuring Zabbix 4.0.30
checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for cc... cc
......
......
  LDAP support:          no
  IPv6 support:          no

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

[root@cong2 zabbix-4.0.30]# make install
Making install in src
make[1]: 进入目录“/root/zabbix-4.0.30/src”
Making install in libs
make[2]: 进入目录“/root/zabbix-4.0.30/src/libs”
Making install in zbxcrypto
make[3]: 进入目录“/root/zabbix-4.0.30/src/libs/zbxcrypto”
cc -DHAVE_CONFIG_H -I. -I../../../include     -g -O2  -MT libzbxcrypto_a-md5.o -MD -MP -
......
......
make[2]: 对“install-exec-am”无需做任何事。
make[2]: 对“install-data-am”无需做任何事。
make[2]: 离开目录“/root/zabbix-4.0.30/misc”
make[1]: 离开目录“/root/zabbix-4.0.30/misc”
make[1]: 进入目录“/root/zabbix-4.0.30”
make[2]: 进入目录“/root/zabbix-4.0.30”
make[2]: 对“install-exec-am”无需做任何事。
make[2]: 对“install-data-am”无需做任何事。
make[2]: 离开目录“/root/zabbix-4.0.30”
make[1]: 离开目录“/root/zabbix-4.0.30”

                
[root@cong2 zabbix-4.0.30]# zabbix_agentd 
[root@cong2 zabbix-4.0.30]# ss -antl
State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port   Process   
LISTEN    0         128                0.0.0.0:111              0.0.0.0:*                
LISTEN    0         32           192.168.122.1:53               0.0.0.0:*                
LISTEN    0         128                0.0.0.0:22               0.0.0.0:*                
LISTEN    0         5                127.0.0.1:631              0.0.0.0:*                
LISTEN    0         128                0.0.0.0:10050            0.0.0.0:*                
LISTEN    0         128                   [::]:111                 [::]:*                
LISTEN    0         128                   [::]:22                  [::]:*                
LISTEN    0         5                    [::1]:631                 [::]:*                
LISTEN    0         80                       *:3306                   *:*   

    2.2 配置agent!!

 [root@cong2 zabbix-4.0.30]# vim /usr/local/etc/zabbix_agentd.conf


92 # Server=
 93 
 94 Server=192.168.180.129     (修改为服务端IP地址)
 95 
 96 ### Option: ListenPort




133 # ServerActive=
134 
135 ServerActive=192.168.180.129    (修改为服务端IP地址)
136  
137 ### Option: Hostname


144 # Hostname=
145 
146 Hostname=Zabbix agent1
147 
148 ### Option: HostnameItem

[root@cong2 zabbix-4.0.30]# zabbix_agentd
[root@cong2 zabbix-4.0.30]# ss -antl
State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port   Process   
LISTEN    0         128                0.0.0.0:111              0.0.0.0:*                
LISTEN    0         32           192.168.122.1:53               0.0.0.0:*                
LISTEN    0         128                0.0.0.0:22               0.0.0.0:*                
LISTEN    0         5                127.0.0.1:631              0.0.0.0:*                
LISTEN    0         128                0.0.0.0:10050            0.0.0.0:*                
LISTEN    0         128                   [::]:111                 [::]:*                
LISTEN    0         128                   [::]:22                  [::]:*                
LISTEN    0         5                    [::1]:631                 [::]:*                
LISTEN    0         80                       *:3306                   *:*   

3. 在网页上打开!

    3.1  新添加主机!!!

4. win 的 agent部署!!!

实验环境

 zabbix serverzabbix agent(windows)
ip192.168.180.129192.168.180.1
主机名c1

    4.1 下载 agent!!!

    4.2  关闭防火墙!!!

   4.3  返回网页 按照 刚刚的部署   新建一个 win的监控!!!

 

5. 手动添加监控!!!

      5.1   首先添加测试文件!!!

[root@localhost ~]# touch /opt/linjj
[root@localhost ~]# cd /opt
[root@localhost opt]# ls
linjj  rh
[root@localhost opt]# 

      5.2  在网页上找到被监控的主机,修改监控项!

              5.2.1 此时没有添加监控项,zabbix监控起不来!  (点击 ‘ltems’ 添加监控项!)

              5.2.2  手动添加监控项!

           5.2.3 在添加完监控项之后,等一下就会发现zabbix监控启动了!

6. 添加触发器!!!

       6.1   在选中的主机上添加触发器!  (点击 ‘Triggers’添加!)

       6.2   填写触发器名字,选择级别!  设置触发的级别!

         6.3  设置表达式!!!

       6.4  在之前虚拟机测试文件上面添加东西!  每隔30s更新的时候 就会有报错提示!

7. 定义媒介!!!

 

    7.1  为不同的用户选择媒介!

       7.2  为触发器配置动作!

    7.3  手动触发来进行验证!!!

[root@localhost opt]# echo '123456789876543' >> linjj

8.  本地邮箱告警配置!!!

      8.1   首先编写发送邮箱脚本!!!

[root@localhost ~]# vim /usr/local/etc/zabbix_server.conf

# Default:
AlertScriptsPath=/usr/local/share/zabbix/alertscripts

### Option: ExternalScripts




[root@localhost ~]# vim /usr/local/share/zabbix/alertscripts/sendmail.sh
[root@localhost ~]# cat /usr/local/share/zabbix/alertscripts/sendmail.sh
#/bin/bash
msg=$1
sub=$2
email=$3
echo $msg | mail -s $sub $email




[root@localhost ~]# chown -R zabbix.zabbix /usr/local/share/zabbix
[root@localhost ~]# chmod +x /usr/local/share/zabbix/alertscripts/sendmail.sh
[root@localhost ~]# ll /usr/local/share/zabbix/alertscripts/sendmail.sh 
-rwxr-xr-x. 1 zabbix zabbix 66 5月  19 01:11 /usr/local/share/zabbix/alertscripts/sendmail.sh
[root@localhost ~]# 



[root@zabbix /]# dnf -y install postfix mailx
[root@zabbix /]# systemctl start postfix
[root@zabbix /]# pkill zabbix_server
[root@zabbix /]# zabbix_server 

      8.2 定义本地邮箱警告媒介!!

      8.3  为用户添加本地邮箱警告媒介!!!!

      8.4 为触发器配置底本邮箱警告动作!!

 

      8.5 手动触发警告!

[root@localhost ~]#  echo '123456' >> /opt/linjj

      8.6 验证!!!

  

9. 第三方邮箱警告的配置!!!

    9.1  编写发送邮箱脚本!!!   (配置 mail.rc)

[root@localhost ~]# vim /etc/mail.rc
set smtp=smtp.126.com
set smtp-auth=login
set smtp-auth-user=lzz2168785215@126.com
set smtp-auth-password=LHAOQORIVTPLWMEL
set from=lzz2168785215@126.com

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值