zabbix

zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。

zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

zabbix由2部分构成,zabbix server与可选组件zabbix agent。

zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Ubuntu,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。

zabbix server可以单独监视远程服务器的服务状态;同时也可以与zabbix agent配合,可以轮询zabbix agent主动接收监视数据(agent方式),同时还可被动接收zabbix agent发送的数据(trapping方式)。

另外zabbix server还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。

  1. zabbix特点

zabbix的主要特点:

  • 安装与配置简单,学习成本低
  • 支持多语言(包括中文)
  • 免费开源
  • 自动发现服务器与网络设备
  • 分布式监视以及WEB集中管理功能
  • 可以无agent监视
  • 用户安全认证和柔软的授权方式
  • 通过WEB界面设置或查看监视结果
  • email等通知功能

监控指标

  • 系统监控
  • 内存使用率
  • 硬盘使用率
  • cpu使用率
  • 网络监控
  • 流量
  • 网卡
  • 硬件监控
  • 电源
  • cpu温度
  • 硬盘温度
  • 业务监控

zabbix主要功能:

  • cpu负荷
  • 内存使用
  • 磁盘使用
  • 网络状况
  • 端口监视
  • 日志监视

  • zabbix配置文件

zabbix配置文件有两种:

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

服务器配置文件zabbix_server.conf常用配置参数

参数 作用 LogFile 设置服务端日志文件存放路径 ListenIP 设置服务端监听 IPListenPort 设置服务端监听的端口号 PidFile 设置服务端进程号文件存放路径 DBHost 指定zabbix的数据库服务器I PDBName 指定zabbix使用的数据库库名 DBUser 指定zabbix数据库登录用户 DBPassword 指定zabbix数据库登录密码 DBPort 指定zabbix数据库端口号 User 设置zabbix以什么用户的身份运行 AlertScriptsPath 设置告警脚本存放路径 ExternalScripts 外部脚本存放路径

客户端配置文件zabbix_agentd.conf常用配置参数:

参数 作用 Server 指定zabbix服务器的IP或域名 ServerActive 指定zabbix服务器的IP或域名 Hostname 指定本机的主机名,此项必须与web界面配置项一致 UnsafeUserParameters 是否启用自定义监控项,可选值为{1 UserParameter 指定自定义监控脚本参数 LogFile 设置客户端日志文件存放路径

  1. 部署zabbix

环境说明:

环境 IP 要安装的应用 服务器 lamp架构,zabbix server zabbix agent 客户端 zabbix agent

基于lamp

[root@mr ~]# cd /etc/yum.repos.d/
[root@mr yum.repos.d]# ls
CentOS-Stream-AppStream.repo  CentOS-Stream-HighAvailability.repo
CentOS-Stream-BaseOS.repo     CentOS-Stream-Media.repo
CentOS-Stream-Debuginfo.repo  CentOS-Stream-PowerTools.repo
CentOS-Stream-Extras.repo     CentOS-Stream-RealTime.repo
[root@mr yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2495  100  2495    0     0   7252      0 --:--:-- --:--:-- --:--:--  7231
[root@mr yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@mr yum.repos.d]# ls
CentOS-Base.repo              CentOS-Stream-HighAvailability.repo
CentOS-Stream-AppStream.repo  CentOS-Stream-Media.repo
CentOS-Stream-BaseOS.repo     CentOS-Stream-PowerTools.repo
CentOS-Stream-Debuginfo.repo  CentOS-Stream-RealTime.repo
CentOS-Stream-Extras.repo
[root@mr yum.repos.d]# dnf clean all
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
36 files removed
[root@mr yum.repos.d]# dnf makecache
Failed to set locale, defaulting to C.UTF-8
Repository extras is listed more than once in the configuration
CentOS-8.5.2111 - Base - mirrors.aliyun.com   204 kB/s | 4.6 MB     00:22
CentOS-8.5.2111 - Extras - mirrors.aliyun.com  18 kB/s |  10 kB     00:00
CentOS-8.5.2111 - AppStream - mirrors.aliyun. 105 kB/s | 8.4 MB     01:22
CentOS Stream 8 - AppStream                   8.4 MB/s |  25 MB     00:02
CentOS Stream 8 - BaseOS                      4.1 MB/s |  25 MB     00:06
Last metadata expiration check: 0:00:01 ago on Thu Sep  1 16:17:43 2022.

Metadata cache created.

[root@mr ~]# dnf -y module install mariadb*
[root@mr ~]# dnf -y module install php:7.4
[root@mr ~]# dnf install -y httpd
[root@mr ~]# cp /usr/share/doc/httpd/httpd-vhosts.conf /etc/httpd/conf.d/
[root@mr ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf

    DocumentRoot "/var/www/html/zabbix.example.com"
    ServerName zabbix.example.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/zabbix.example.com/$1

        Options none
        AllowOverride none
        Require all granted

    ErrorLog "/var/log/httpd/zabbix.example.com-error_log"
    CustomLog "/var/log/httpd/zabbix.example.com-access_log" common

[root@mr ~]# vim /etc/httpd/conf/httpd.conf
DirectoryIndex indexphp index.html
 AddType application/x-httpd-php .php
 AddType application/x-httpd-php-source .phps
 [root@mr ~]# cd /var/www/html/
[root@mr html]# mkdir zabbix.example.com
[root@mr html]# ls
doudizhu  zabbix.example.com  zhuawawa
[root@mr html]# cd zabbix.example.com/
[root@mr zabbix.example.com]# vim index.php

[root@mr zabbix.example.com]# cd
[root@mr ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

[root@mr ~]# systemctl enable --now mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.

Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.

Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

[root@mr ~]# systemctl enable --now php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.

[root@mr ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3
Server version: 10.5.9-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> set password = password ('123456');
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> quit
Bye
[root@mr ~]# vim /etc/php-fpm.d/www.conf
listen = 0.0.0.0:9000
[root@mr ~]# systemctl restart php-fpm
[root@mr ~]# ss -antl
State     Recv-Q     Send-Q         Local Address:Port         Peer Address:Port    Process
LISTEN    0          128                  0.0.0.0:22                0.0.0.0:*
LISTEN    0          128                  0.0.0.0:9000              0.0.0.0:*
LISTEN    0          128                        *:80                      *:*
LISTEN    0          128                     [::]:22                   [::]:*
LISTEN    0          80                         *:3306                    *:*
[root@mr ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@mr ~]# setenforce 0
[root@mr ~]# vim /etc/selinux/config
SELINUX=disabled

zabbix
部署zabbix
[root@mr ~]# dnf install -y net-snmp-devel libevent-devel gcc gcc-c++ make libxml2-devel libcurl-devel pcre-devel openssl openssl-devel mysql-devel php-bcmath php-gd php-mysqlnd wget
[root@mr ~]# cd /usr/src/
[root@mr src]# wget https://cdn.zabbix.com/zabbix/sources/stable/6.2/zabbix-6.2.2.tar.gz
[root@mr src]# useradd -r -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
[root@mr src]#  mkdir -p /usr/lib/zabbix
[root@mr src]# chmod 770 /usr/lib/zabbix
[root@mr src]# chown -R zabbix.zabbix /usr/lib/zabbix
[root@mr src]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 4
Server version: 10.5.9-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.010 sec)

MariaDB [(none)]> create user 'zabbix'@'localhost' identified by 'zabbix123!'
    -> ;
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> quit
Bye
[root@mr src]# cd zabbix-6.2.2/database/mysql/
[root@mr mysql]# mysql -uroot -p123456 zabbix < schema.sql
[root@mr mysql]# mysql -uroot -p123456 zabbix < images.sql
[root@mr mysql]# mysql -uroot -p123456 zabbix < data.sql
[root@mr mysql]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 8
Server version: 10.5.9-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>
[root@mr ~]# cd /usr/src/zabbix-6.2.2
[root@mr zabbix-6.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2
.....

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*                                  *
***********************************************************

[root@mr zabbix-6.2.2]# make install
[root@mr zabbix-6.2.2]# cd /usr/local/etc/
[root@mr etc]# vim zabbix_server.conf
DBPassword=zabbix123!

[root@mr etc]# zabbix_server
[root@mr etc]# zabbix_agentd
[root@mr etc]# ss -antl
State     Recv-Q    Send-Q         Local Address:Port          Peer Address:Port    Process
LISTEN    0         128                  0.0.0.0:22                 0.0.0.0:*
LISTEN    0         128                  0.0.0.0:10050              0.0.0.0:*
LISTEN    0         128                  0.0.0.0:10051              0.0.0.0:*
LISTEN    0         128                  0.0.0.0:9000               0.0.0.0:*
LISTEN    0         128                        *:80                       *:*
LISTEN    0         128                     [::]:22                    [::]:*
LISTEN    0         80                         *:3306                     *:*
[root@mr ~]# cd /usr/src/zabbix-6.2.2
[root@mr zabbix-6.2.2]# cp -a ui/* /var/www/html/zabbix.example.com/
cp: overwrite '/var/www/html/zabbix.example.com/index.php'? y
[root@mr zabbix-6.2.2]# chown -R apache.apache /var/www/html
[root@mr zabbix-6.2.2]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@mr zabbix-6.2.2]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@mr zabbix-6.2.2]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@mr zabbix-6.2.2]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@mr zabbix-6.2.2]# systemctl restart php-fpm

zabbix
zabbix
zabbix
zabbix

Original: https://www.cnblogs.com/marymary/p/16648306.html
Author: 溜溜威
Title: zabbix

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/581529/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • android系统中常见问题及分类

    版本: v0.2作者:河东希望日期:2022-7-6 对Android系统和应用来说,用户体验的基本目标是: 运行稳定 交互响应快 耗电少 启动快 所有违背这几个基本原则的问题,都…

    Linux 2023年6月7日
    086
  • 聊聊客户档案模型的设计与管理

    可以简单,更需要复杂; 一、基础描述 围绕客户管理通常分为售前、售中、售后、三个核心阶段,即营销、销售、服务三个核心流程与策略,在之前的文章中有聊过CDP系统的设计,本篇从客户档案…

    Linux 2023年6月14日
    078
  • SQL44 将id=5以及emp_no=10001的行数据替换成id=5以及emp_no=10005

    本题链接表结构如下所示。 +—-+——–+—————–+————+————+ | id | emp_no | t…

    Linux 2023年6月13日
    095
  • 1.1 操作系统是什么,操作系统概述

    好的开始是成功的一半。学习 Linux 的第一个问题是搞明白 Linux 是什么,了解其来龙去脉、前世今生,知道其发展趋势、应用前景,弄清楚为什么学习它,以及如何掌握它和使用它,知…

    Linux 2023年5月27日
    073
  • 宝塔配置vnc+wine实现Q群机器人

    图形界面必备 X Window System yum -y groupinstall "X Window System" 安装epel源 yum -y inst…

    Linux 2023年5月27日
    086
  • KindEditor配置和使用

    1下载kindeditor包,目前最新版本是kindeditor-3.5.5。下载地址:http://www.kindsoft.net/ 2.解压之后,解压目录kindeditor…

    Linux 2023年6月13日
    090
  • python_base

    1.查看可用函数dir() dir()可以用于查看某个包中可以使用的对象 import math dir(math) 2.查看使用帮助help() 用于查看帮助,用法是具体到函数名…

    Linux 2023年6月7日
    085
  • OS模块中获取当前文件的绝对路径的相关方法

    os.path.realpath(file) 作用:获取当前执行py脚本的绝对路径(在当前工作目录下的绝对路径) file : 表示当前文件的本身,一般值是当前文件的相对路径 例如…

    Linux 2023年6月7日
    084
  • Linux编译安装、压缩打包与定时任务服务

    一、编译安装 即使用源代码编译安装的方式,编译打包软件。特点: 可以自定制软件; 可以按需构建软件; 编译安装案例 1、下载源代码包(这里以Nginx软件包源代码为例) wget …

    Linux 2023年5月27日
    087
  • linux开机自动挂载(/etc/fstab)

    fatab 介绍 通常情况,Linux 的 /etc/fstab 文件可能有如下内容: # /etc/fstab Created by anaconda on Fri Aug 18…

    Linux 2023年6月7日
    0108
  • 前端基础之JavaScript(二)

    一、函数 1.1 函数定义 JavaScript中的函数和Python中的非常相似,只是定义方式有点区别。 // 普通函数定义 function f1() { console.lo…

    Linux 2023年6月14日
    090
  • ASP.NET Core 2.2 : 二十七. JWT与用户授权(细化到Action)

    上一章分享了如何在ASP.NET Core中应用JWT进行用户认证以及Token的刷新,本章继续进行下一步,用户授权。涉及到的例子也以上一章的为基础。(ASP.NET Core 系…

    Linux 2023年6月7日
    095
  • Shell实现:基本功能

    独立博客阅读地址:https://panqiincs.me/2017/02/26/write-a-shell-basic-functionality/ Shell的功能 Shell…

    Linux 2023年6月7日
    0130
  • 图解固件、驱动、软件的区别

    大家好,我是良许。 不管我们使用什么操作系统,无论是 Windows、macOS 还是 Linux ,里面都安装了许多软件、驱动程序和固件。但是,这三者概念有区别呢? 我在朋友圈做…

    Linux 2023年5月27日
    085
  • springboot redis key乱码

    原写法: 写入redis后,查看key值 解决方式: 调整后查看redis key值: Original: https://www.cnblogs.com/janes/p/8796…

    Linux 2023年5月28日
    090
  • 拓扑排序

    拓扑排序 简介 拓扑排序是将偏序的数据线性化的一种排序方法。复习下偏序和全序的概念: 全序关系是偏序关系的一个子集。 全序是集合内任何一对元素都是可比较的,比如数轴上的点都具有一个…

    Linux 2023年6月13日
    0107
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球