Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

Recommended Posts

zabbix介绍

  1. zabbix是由Alexei Vladishev 开发的一种网络监视、管理系统,基于Server-Client架构。可用于监视各种网络服务、服务器和网络机器等状态。
  2. 使用各种Database-end 如 MySQL,PostgreSQL,SQlite,Oracle 或IBMDB2储存资料。Server端基于C语言、Web管理端frontend则是基于PHP所制作的。
  3. zabbix可以使用多种方式监视。可以只使用Simple Check不需要安装
    Client端,亦可基于SMTP或HTTP… 各种协议定制监视。
  4. 在客户端如UNIX,Windows 中安装zabbix Agent之后,可监视CPULoad、网络使用状况、硬盘容量等各种状态。而就算没有安装Agent 在监视对象中,zabbix 也可以经由SNMP、TCP、ICMP、利用IPMI、SSH、telnet 对目标进行监视。
  5. zabbbix自带的Item足够满足普通小公司的监控需求,对于大公司也可以设定自定义的Item,自动生成报表,也有API可以和其他系统集成。
  6. zabbix由2部分构成,zabbix server与可选组件zabbix agent。

zabbix特点

zabbix的主要特点:
安装与配置简单,学习成本低
支持多语言(包括中文)
免费开源
自动发现服务器与网络设备
分布式监视以及WEB集中管理功能
可以无agent监视
用户安全认证和柔软的授权方式
通过WEB界面设置或查看监视结果
email等通知功能
zabbix主要功能:
CPU负荷
内存使用
磁盘使用
网络状况
端口监视
日志监视

为何是zabbix不是其他监控

zabbix就是可以满足理想化的监控系统需求
支持自定义监控脚本,提供需要输出的值即可
zabbix存储的数据库表结构稍有复杂但是逻辑清晰
zabbix存在模板的概念,可以方便的将一组监控项进行部署
zabbix每一个item也就是监控项,都可以看到历史记录,且web界面友好
zabbix有强大的Trigger(触发器)定义规则,可以定义复杂的报警逻辑
zabbix提供了ack报警确认机制
zabbix支持邮件,短信,微信等告警
zabbix在触发告警后,可以远程执行系统命令
zabbix有原生的PHP绘图模块

部署zabbix时为什么服务端也要安装部署zabbix
因为服务端在监控其他主机的时候,如果自己出了啥子问题是无法进行自我反应的,所以在监控其他主机的时候,也要进行自我监控,及时反应问题。

zabbix程序组件

zabbix_server,服务端守护进程
zabbix_agentd,agent守护进程
zabbix_proxy,代理服务器
zabbix_database,存储系统,mysql,pgsql
zabbix_web,web GUI图形化界面
zabbix_ get,命令行工具,测试向agent发起数据采集请求
zabbix_sender,命令行工具,测试向server发送数据
zabbix_ java_ gateway,java网关

zabbix配置文件

zabbix配置文件有两种:
服务器端配置文件(/usr/local/etc/zabbix_server.conf)
客户端配置文件(/usr/local/etc/zabbix_agentd.conf)
zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)
img
img

部署zabbix

因为zabbix是用php语言开发的,所以必须先部署lamp架构,使其能够支持运行php网页
需要提前搭建好lamp架构,可以查看 下面的搭建方法

[lamp架构的搭建](部署LAMP - 姜翎 - 博客园 (cnblogs.com))
mysql官网
此处需要使用的mysql8mysql源码包
php官网
此处需要使用的php源码包
zabbix官网
zabbix源码包

zabbix服务端安装

[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget    https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
//下载源码包
--2022-09-01 22:12:50--  https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
Resolving cdn.zabbix.com (cdn.zabbix.com)... 172.67.69.4, 104.26.6.148, 104.26.7.148, ...
...
[root@localhost src]# ls
debug  kernels  zabbix-6.2.2.tar.gz
[root@localhost src]# tar xf zabbix-6.2.2.tar.gz  //解压
[root@localhost src]# cd zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# dnf -y install net-snmp-devel libevent-devel   //安装依赖包
....
tpm2-tss-2.3.2-4.el8.x86_64                                                                          
  unzip-6.0-45.el8_4.x86_64                                                                            
  zip-3.0-23.el8.x86_64                                                                                

Complete!
[root@localhost zabbix-6.2.2]# useradd -r -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
//创建zabbix系统用户
[root@localhost zabbix-6.2.2]# mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
//创建zabbix用户的家目录
[root@localhost zabbix-6.2.2]# chown -R zabbix.zabbix /usr/lib/zabbix/
//使其属主属组都是zabbix
[root@localhost zabbix-6.2.2]# mysql -uroot -p'lnh123'  //登录数据库,配置数据库
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.02 sec)

mysql> create user 'zabbix'@'localhost' identified by 'zabbix123!';
Query OK, 0 rows affected (0.03 sec)

mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql>  SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@localhost zabbix-6.2.2]# cd /usr/src/zabbix-6.2.2/database/mysql/
[root@localhost mysql]# ls
Makefile.am  Makefile.in  data.sql  double.sql  history_pk_prepare.sql  images.sql  schema.sql  
//将此处数据进行导入
[root@localhost mysql]# mysql -uroot -p'lnh123' zabbix < schema.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uroot -p'lnh123' zabbix < images.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uroot -p'lnh123' zabbix < data.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uroot -p'lnh123'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SET GLOBAL log_bin_trust_function_creators = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables from zabbix;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
....
| widget_field               |
+----------------------------+
176 rows in set (0.03 sec)
//查看zabbix数据库下有哪些表,没有问题的话是176张表
[root@localhost mysql]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# ./configure --enable-server --enable-agent --with-mysql  --with-net-snmp --with-libcurl --with-libxml2
//编译zabbix
...
***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************
[root@localhost zabbix-6.2.2]# make install

zabbix服务端配置

[root@localhost zabbix-6.2.2]# cd /usr/local/etc/
[root@localhost etc]# ls
zabbix_agentd.conf  zabbix_agentd.conf.d  zabbix_server.conf  zabbix_server.conf.d
[root@localhost etc]# vim zabbix_server.conf.d/
# DBPassword=      //在这行下面添加前面设置的mysql里面用户密码
DBPassword=zabbix123!    //添加

zabbix配置web界面

[root@localhost etc]# cd
[root@localhost ~]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# ls
AUTHORS    Makefile     README      compile       config.status  database    m4       sass
COPYING    Makefile.am  aclocal.m4  conf          config.sub     depcomp     man      src
ChangeLog  Makefile.in  bin         config.guess  configure      include     misc     ui
INSTALL    NEWS         build       config.log    configure.ac   install-sh  missing
[root@localhost zabbix-6.2.2]# vim /usr/local/apache/conf/extra/httpd-vhosts.conf 
//配置apache虚拟主机,可以注释之前的配置
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix"
    ServerName zabbix.example.com
    ErrorLog "logs/zabbix.example.com-error_log"
    CustomLog "logs/zabbix.example.com-access_log" common
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs/zabbix">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
[root@localhost zabbix-6.2.2]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# ls
AUTHORS    Makefile     README      compile       config.status  database    m4       sass
COPYING    Makefile.am  aclocal.m4  conf          config.sub     depcomp     man      src
ChangeLog  Makefile.in  bin         config.guess  configure      include     misc     ui
INSTALL    NEWS         build       config.log    configure.ac   install-sh  missing
[root@localhost zabbix-6.2.2]# cd ui/
[root@localhost ui]# ls    //此处是php代码
actionconf.php      composer.lock                imgstore.php     report2.php
api_jsonrpc.php     conf                         include          report4.php
app                 data                         index.php        robots.txt
assets              disc_prototypes.php          index_http.php   setup.php
audio               favicon.ico                  index_sso.php    sysmap.php
auditacts.php       graphs.php                   items.php        sysmaps.php
browserwarning.php  history.php                  js               templates.php
chart.php           host_discovery.php           jsLoader.php     toptriggers.php
chart2.php          host_prototypes.php          jsrpc.php        tr_events.php
chart3.php          hostinventories.php          local            trigger_prototypes.php
chart4.php          hostinventoriesoverview.php  locale           triggers.php
chart6.php          httpconf.php                 maintenance.php  vendor
chart7.php          httpdetails.php              map.php          zabbix.php
composer.json       image.php                    modules
[root@localhost ui]# cd -
/usr/src/zabbix-6.2.2
[root@localhost zabbix-6.2.2]# cd
[root@localhost ~]# cd /usr/src/zabbix-6.2.2/
[root@localhost zabbix-6.2.2]# mkdir /usr/local/apache/htdocs/zabbix   //创建zabbix的web站点目录
[root@localhost zabbix-6.2.2]# cp -a /usr/src/zabbix-6.2.2/ui/* /usr/local/apache/htdocs/zabbix/
//将zabbix的web界面php代码复制到站点目录
[root@localhost zabbix-6.2.2]# chown -R apache.apache /usr/local/apache/htdocs/
//使其属主属组是apache
[root@localhost zabbix-6.2.2]# ll /usr/local/apache/htdocs/
total 8
-rw-r--r--.  1 apache apache   45 Jun 12  2007 index.html
drwxr-xr-x.  2 apache apache   23 Sep  1 21:29 runtime
drwxr-xr-x. 13 apache apache 4096 Sep  1 23:19 zabbix
[root@localhost zabbix-6.2.2]# chmod 777 /usr/local/apache/htdocs/zabbix/conf/
//设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php
[root@localhost zabbix-6.2.2]#  ll -d /usr/local/apache/htdocs/zabbix/conf/
drwxrwxrwx. 3 apache apache 94 Aug 29 15:05 /usr/local/apache/htdocs/zabbix/conf/
[root@localhost zabbix-6.2.2]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@localhost zabbix-6.2.2]# systemctl restart httpd.service 
//重启httpd
[root@localhost zabbix-6.2.2]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@localhost zabbix-6.2.2]#  sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@localhost zabbix-6.2.2]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@localhost zabbix-6.2.2]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
//修改/etc/php.ini的配置
[root@localhost zabbix-6.2.2]# service php-fpm restart 
Gracefully shutting down php-fpm . done
Starting php-fpm  done
//重启php-fpm
[root@localhost ~]# zabbix_server 
[root@localhost ~]# zabbix_agentd 
//启动zabbix_server和zabbix_agentd

在物理机上做hosts域名映射

在我的电脑里面进行映射(C:\Windows\System32\drivers\etc)

2844305-20220902020603966-2104371907.png

去浏览器访问,输入zabbix.example.com,看到如下页面,然后点击next step

2844305-20220902020219607-2007866068.png

2844305-20220902020227854-875202525.png

2844305-20220902020234117-780866655.png

2844305-20220902020242571-458998542.png2844305-20220902020258518-540829422.png

2844305-20220902020250751-721120113.png

2844305-20220902020309025-209433582.png

2844305-20220902020314236-1174534781.png

部署完成

[root@localhost ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf/
[root@localhost ~]# ll -d /usr/local/apache/htdocs/zabbix/conf/
drwxr-xr-x. 3 apache apache 117 Sep  1 23:41 /usr/local/apache/htdocs/zabbix/conf/
//恢复zabbix/conf目录的权限为755
Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...