Posts tagged ‘zabbix-server’

Zabbix5.0+Grafana可视化试用(九):在Grafana上安装常用插件Plugins

默认Grafana7.0.3已自带一些插件,包括Graph、Stat、Gauge等常用插件,如下图:

zabbix5.0_58

可通过官网选择需要的其它插件:https://grafana.com/grafana/plugins,如下

zabbix5.0_59

点击需要安装的插件名称,以Clock为例,Installation选项栏中写着如何安装此插件,一般只需通过grafana-cli plugins install来安装插件,如下图为grafana-cli plugins install grafana-cli plugins install grafana-clock-panel:

zabbix5.0_60

在Grafana服务器中执行grafana-cli plugins install grafana-clock-panel,如下:

[root@localhost ~]# grafana-cli plugins install grafana-clock-panel
installing grafana-clock-panel @ 1.1.1
from: https://grafana.com/api/plugins/grafana-clock-panel/versions/1.1.1/download
into: /var/lib/grafana/plugins

鉁[0m Installed grafana-clock-panel successfully

Restart grafana after installing plugins . <service grafana-server restart>

[root@localhost ~]#

如上提示,完成安装后,需重启grafana:

[root@localhost ~]# systemctl restart grafana-server.service

完成后,即可看到插件列表中已有Clock插件,如下图所示。

zabbix5.0_61

grafana-cli常用命令:

List available plugins–列出可用插件
grafana-cli plugins list-remote

Install the latest version of a plugin–安装插件
grafana-cli plugins install <plugin-id>

Install a specific version of a plugin–安装指定版本插件
grafana-cli plugins install <plugin-id> <version>

List installed plugins–列出已安装插件
grafana-cli plugins ls

Update all installed plugins–升级所有插件
grafana-cli plugins update-all

Update one plugin–升级指定插件
grafana-cli plugins update <plugin-id>

Remove one plugin–删除一个插件
grafana-cli plugins remove <plugin-id>

Admin commands
Admin commands are only available in Grafana 4.1 and later.
Show all admin commands
grafana-cli admin

Reset admin password
grafana-cli admin reset-admin-password <new password> resets the password for the admin user using the CLI. You might need to do this if you lose the admin password.

至此,一个插件安装完成,可以从官网https://grafana.com/grafana/plugins处下载并安装更多插件。

以下为我安装的插件列表:

1、Datatable Panel
网址:https://grafana.com/grafana/plugins/briangann-datatable-panel
安装命令:grafana-cli plugins install briangann-datatable-panel

2、Progress List
网址:https://grafana.com/grafana/plugins/corpglory-progresslist-panel
安装命令:grafana-cli plugins install corpglory-progresslist-panel

3、Blendstat
网址:https://grafana.com/grafana/plugins/farski-blendstat-panel
安装命令:grafana-cli plugins install farski-blendstat-panel

4、Cock
网址:https://grafana.com/grafana/plugins/grafana-clock-panel
安装命令:grafana-cli plugins install grafana-clock-panel

5、Pie Chart
网址:https://grafana.com/grafana/plugins/grafana-piechart-panel
安装命令:grafana-cli plugins install grafana-piechart-panel

6、Polystat
网址:https://grafana.com/grafana/plugins/grafana-polystat-panel
安装命令:grafana-cli plugins install grafana-polystat-panel

7、Worldmap Panel
网址:https://grafana.com/grafana/plugins/grafana-worldmap-panel
安装命令:grafana-cli plugins install grafana-worldmap-panel

8、Diagram
网址:https://grafana.com/grafana/plugins/jdbranham-diagram-panel
安装命令:grafana-cli plugins install jdbranham-diagram-panel

9、Analytics Panel
网址:https://grafana.com/grafana/plugins/macropower-analytics-panel
安装命令:grafana-cli plugins install macropower-analytics-panel

10、Multistat
网址:https://grafana.com/grafana/plugins/michaeldmoore-multistat-panel
安装命令:grafana-cli plugins install michaeldmoore-multistat-panel

11、Status Panel
网址:https://grafana.com/grafana/plugins/vonage-status-panel
安装命令:grafana-cli plugins install vonage-status-panel

全部安装完成后如下。

zabbix5.0_62

Zabbix5.0+Grafana可视化试用(八):在CentOS7上安装Grafana7.0.1并添加Zabbix数据源

Grafana 是一款采用 go 语言编写的开源应用,主要用于大规模指标数据的可视化展现,是网络架构和应用分析中最流行的时序数据展示工具,目前已经支持绝大部分常用的时序数据库。

开始安装Grafana,首先完成CentOS7的安装,关闭防火墙及SELINUX:

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]#
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]#
[root@localhost ~]# sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g’ /etc/selinux/config
[root@localhost ~]#
[root@localhost ~]# grep “SELINUX=disabled” /etc/selinux/config
SELINUX=disabled
[root@localhost ~]#
[root@localhost ~]#

完成后,开始安装Grafana(或者使用清华大学镜像https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/),下载:

[root@localhost ~]# wget https://dl.grafana.com/oss/release/grafana-7.0.3-1.x86_64.rpm
–2020-06-07 03:03:22–  https://dl.grafana.com/oss/release/grafana-7.0.3-1.x86_64.rpm
Resolving dl.grafana.com (dl.grafana.com)… 151.101.42.217, 2a04:4e42:a::729
Connecting to dl.grafana.com (dl.grafana.com)|151.101.42.217|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 49068666 (47M) [application/x-redhat-package-manager]
Saving to: 鈥榞rafana-7.0.3-1.x86_64.rpm.1鈥

100%[=================================================>] 49,068,666   935KB/s   in 52s   

2020-06-07 03:04:15 (923 KB/s) – 鈥榞rafana-7.0.3-1.x86_64.rpm.1鈥saved [49068666/49068666]

[root@localhost ~]#

安装:

[root@localhost ~]# yum localinstall grafana-7.0.3-1.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
Examining grafana-7.0.3-1.x86_64.rpm: grafana-7.0.3-1.x86_64
Marking grafana-7.0.3-1.x86_64.rpm to be installed
Resolving Dependencies
–> Running transaction check
—> Package grafana.x86_64 0:7.0.3-1 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
  Package                        Arch                          Version                           Repository                                      Size
============================================================================
Installing:
  grafana                        x86_64                        7.0.3-1                           /grafana-7.0.3-1.x86_64                        142 M

Transaction Summary
============================================================================
Install  1 Package

Total size: 142 M
Installed size: 142 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
   Installing : grafana-7.0.3-1.x86_64                                                                                                            1/1
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
  sudo /bin/systemctl daemon-reload
  sudo /bin/systemctl enable grafana-server.service
### You can start grafana-server by executing
  sudo /bin/systemctl start grafana-server.service
POSTTRANS: Running script
   Verifying  : grafana-7.0.3-1.x86_64                                                                                                            1/1

Installed:
   grafana.x86_64 0:7.0.3-1                                                                                                                          

Complete!
[root@localhost ~]#

启动grafana并设置为开机启动:

[root@localhost ~]# systemctl start grafana-server.service
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# systemctl enable grafana-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/grafana-server.service to /usr/lib/systemd/system/grafana-server.service.
[root@localhost ~]#

使用http://192.168.10.220:3000 ,输入用户名密码,都为admin:

zabbix5.0_46

输入新密码:

zabbix5.0_47

zabbix5.0_48

完成安装后,开始添加ZABBIX数据源:

进入Grafana官网https://grafana.com/grafana/plugins/alexanderzobnin-zabbix-app页面,查看Installation安装方法

zabbix5.0_50

在Grafana服务器上使用命令grafana-cli plugins install alexanderzobnin-zabbix-app开始安装:


[root@localhost ~]# grafana-cli plugins install alexanderzobnin-zabbix-app
installing alexanderzobnin-zabbix-app @ 3.12.2
from: https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/3.12.2/download
into: /var/lib/grafana/plugins

鉁[0m Installed alexanderzobnin-zabbix-app successfully

Restart grafana after installing plugins . <service grafana-server restart>

[root@localhost ~]#

然后重启动Grafana服务:

[root@localhost ~]# systemctl restart grafana-server.service

完成后进入刚安装成功的Plugins菜单的Zabbix插件,点击【Enable】启动插件,如下图

zabbix5.0_51

进入Configuration->Add data source

zabbix5.0_53

点击【Selcet】

zabbix5.0_54

配置Data Sources中的Zabbix,输入ZABBIX URL:http://192.168.10.218/zabbix/api_jsonrpc.php,以及输入ZABBIX平台的用户名及密码

zabbix5.0_55

开启警告,完成后点击【Save&Test】测试并添加,如下图。

zabbix5.0_56

至此全部安装完成并设置,后期在面板中直接调用ZABBIX数据源即可。

zabbix5.0_57

Zabbix5.0+Grafana可视化试用(七):通过zabbix agent(yum安装方式)实现CentOS8数据采集及监控

首先关闭防火墙及SELinux,开始安装agent:

[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
warning: /var/tmp/rpm-tmp.nxYZKN: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Verifying…                          ################################# [100%]
Preparing…                          ################################# [100%]
Updating / installing…
   1:zabbix-release-5.0-1.el8         ################################# [100%]
[root@localhost ~]#

开始安装:

[root@localhost ~]# yum install zabbix-agent
Failed to set locale, defaulting to C.UTF-8
CentOS-8 – AppStream                          6.8 kB/s | 4.3 kB     00:00   
CentOS-8 – Base                               6.7 kB/s | 3.9 kB     00:00   
CentOS-8 – Extras                             3.2 kB/s | 1.5 kB     00:00   
Extra Packages for Enterprise Linux 8 – x86_6  13 kB/s | 8.4 kB     00:00   
Extra Packages for Enterprise Linux 8 – x86_6 102 kB/s | 6.8 MB     01:08   
nginx stable repo                             7.0 kB/s | 2.9 kB     00:00   
Zabbix Official Repository – x86_64           9.3 kB/s |  25 kB     00:02   
Zabbix Official Repository non-supported – x8 541  B/s | 1.2 kB     00:02   
Dependencies resolved.
==============================================================================
  Package              Architecture   Version             Repository      Size
==============================================================================
Installing:
  zabbix-agent         x86_64         5.0.1-1.el8         zabbix         454 k

Transaction Summary
==============================================================================
Install  1 Package

Total download size: 454 k
Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
zabbix-agent-5.0.1-1.el8.x86_64.rpm           122 kB/s | 454 kB     00:03   
——————————————————————————
Total                                         122 kB/s | 454 kB     00:03    
warning: /var/cache/dnf/zabbix-b7349cbb4866b08d/packages/zabbix-agent-5.0.1-1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Zabbix Official Repository – x86_64           1.6 MB/s | 1.7 kB     00:00   
Importing GPG key 0xA14FE591:
  Userid     : "Zabbix LLC <packager@zabbix.com>"
  Fingerprint: A184 8F53 52D0 22B9 471D 83D0 082A B56B A14F E591
  From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                      1/1
  Running scriptlet: zabbix-agent-5.0.1-1.el8.x86_64                      1/1
  Installing       : zabbix-agent-5.0.1-1.el8.x86_64                      1/1
  Running scriptlet: zabbix-agent-5.0.1-1.el8.x86_64                      1/1
  Verifying        : zabbix-agent-5.0.1-1.el8.x86_64                      1/1

Installed:
  zabbix-agent-5.0.1-1.el8.x86_64                                            

Complete!
[root@localhost ~]#

完成安装后,开始配置zabbix_agentd.conf配置文件:

Server=192.168.10.218
ServerActive=192.168.10.218
Hostname=localhost.localdomain

完成后保存退出。

配置文件修改后,开始启动服务:

启动服务:

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

添加开机启动功能:

[root@localhost ~]# systemctl enable zabbix-agent.service
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service 鈫/usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~]#

查看agent服务是否已启动:

[root@localhost ~]# ps -ef | grep zabbix
zabbix   14732     1  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix   14733 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix   14734 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix   14735 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix   14736 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix   14737 14732  0 06:32 ?        00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root     14763 26603  0 06:33 pts/1    00:00:00 grep –color=auto zabbix
[root@localhost ~]#
[root@localhost ~]# ss -tnl | grep 10050
LISTEN   0         128                 0.0.0.0:10050            0.0.0.0:*      
LISTEN   0         128                    [::]:10050               [::]:*      
[root@localhost ~]#

如上,已发现agentd进程运行,并且10050端口已启动。

开始添加至ZABBIX5.0平台中,打开zabbix server主界面,选择“配置‘->”主机“,点击右上角的”创建“按扭,创建一台主机,如下图

zabbix5.0_42

链接zabbix agent for linux模板:

zabbix5.0_44

完成后可以看到列表中已经有刚才不回的主机,过几分钟后,可用性一栏中的ZBX变绿即表示监控正常。

zabbix5.0_45

Zabbix5.0+Grafana可视化试用(六):通过zabbix agent实现Windows2012R2数据采集及监控

首先从zabbix官网下载agent包,本次为zabbix_agent-5.0.1-windows-amd64-openssl.zip,如下图

zabbix5.0_35

在Win2012 C盘建立zabbix_agent-5.0.1文件夹,并将agent安装包中的zabbix_agentd.exe和zabbix_agentd.conf复制到zabbix_agent-5.0.1文件夹中,如下图:

zabbix5.0_37

编辑zabbix_agentd.conf文件,如下:

Server=192.168.10.218
ServerActive=192.168.10.218
Hostname=WIN-3Q59OLKNB5U

保存退出。

开始安装,在命令行界面中以服务的形式安装 Zabbix Windows agent,如下:

Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。

C:\Users\Administrator>c:\zabbix_agent-5.0.1\zabbix_agentd.exe -c c:\zabbix_agent-5.0.1\zabbix_agentd.conf -i
zabbix_agentd.exe [15116]: service [Zabbix Agent] installed successfully
zabbix_agentd.exe [15116]: event source [Zabbix Agent] installed successfully

C:\Users\Administrator>

其它扩展命令如下:

c:\zabbix_agent-5.0.1\zabbix_agentd.exe -c c:\zabbix_agent-5.0.1\zabbix_agentd.win.conf -i
c:\zabbix_agent-5.0.1\zabbix_agentd.exe -c c:\zabbix_agent-5.0.1\zabbix_agentd.win.conf -s
c:\zabbix_agent-5.0.1\zabbix_agentd.exe -c c:\zabbix_agent-5.0.1\zabbix_agentd.win.conf -x
c:\zabbix_agent-5.0.1\zabbix_agentd.exe -c c:\zabbix_agent-5.0.1\zabbix_agentd.win.conf -d

-c:指定配置文件所有位置
-i:安装客户端
-s:启动客户端
-x:停止客户端
-d:卸载客户端

进入WINDOWS服务界面,对Zabbix Agent进行编辑,点击“启动”按扭,启动类型为“自动”,如下图。

zabbix5.0_38

完成后开始在ZABBIX平台中添加此主机,选择“配置‘->”主机“,点击右上角的”创建“按扭,创建一台主机,如下图

zabbix5.0_39

链接模板中选择zabbix agent for windows,如下

zabbix5.0_40

完成添加后,ZBX变绿后,即为添加成功,如下图所示。

zabbix5.0_41

Zabbix5.0+Grafana可视化试用(五):通过SNMP添加CentOS操作系统实现数据采集及监控

通过SNMP来监控LINUX服务器,首先在CENTOS服务器上安装SNMP,如下:

[root@localhost ~]# yum -y install net-snmp net-snmp-utils
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
  * base: mirrors.aliyun.com
  * extras: mirrors.aliyun.com
  * updates: mirrors.cn99.com
base

查看是否安装成功:

[root@localhost ~]# rpm -qa | grep snmp
net-snmp-agent-libs-5.7.2-48.el7_8.x86_64
net-snmp-5.7.2-48.el7_8.x86_64
net-snmp-utils-5.7.2-48.el7_8.x86_64
net-snmp-libs-5.7.2-48.el7_8.x86_64

通过SNMP查看版本:

[root@localhost ~]# snmpd -v

NET-SNMP version:  5.7.2
Web:               http://www.net-snmp.org/
Email:             net-snmp-coders@lists.sourceforge.net

开始更改团体名,更改为lsywsnmp123:

com2sec notConfigUser  default       public

更改为:

com2sec notConfigUser  default       lsywsnmp123

重启SNMP服务,并设置为开机启动,如下:

[root@localhost ~]# systemctl start snmpd.service
[root@localhost ~]# systemctl enable snmpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.
[root@localhost ~]#

接着开始ZABBIX5.0端的设置,添加这台CENTOS服务器:

输入主机名、可见名称、群组及被监控主机SNMP IP:

zabbix5.0_31

设置模板:

zabbix5.0_32

设置SNMP团体名:

zabbix5.0_33

完成后,清单中已有服务器,SNMP监控也显示绿色,正常。

zabbix5.0_34

Zabbix5.0+Grafana可视化试用(四):通过SNMP添加Windows2008R2实现数据采集及监控

zabbix5.0与4.x的添加操作方法相同,本次将以WINDOWS 2008R2为例 ,通过SNMP来实现WINDOWS服务器的监控,操作如下:

首先在WINDOWS服务器上启用SNMP,打开服务器管理器,在【功能】选项栏上,选择【添加功能】,如下图

zabbix5.0_23

选择SNMP服务,如下图

zabbix5.0_24

完成后,进入【服务】界面,在SNMP Service右键,选择【属性】,如下图

zabbix5.0_25

在安全选项中,设置相关参数,在社区名称中设置lsywsnmp123,在接受主机一栏中选择ZABBIX SERVER的IP 192.168.10.217,如下图所示,完成后点击确定。

zabbix5.0_26

接着进入ZABBIX配置界面开始添加这台服务器,方法和添加华交换机一样,选择添加主机按扭,如下图,输入主机名称、可见的名称、群组和SNMP接口信息等

zabbix5.0_27

在链接的模板中选择Template OS Windows SNMPv2,如下图

zabbix5.0_28

在宏选项栏中,宏中输入{$SNMP_COMMUNITY},值中输入lsywsnmp123,如下图

zabbix5.0_29

完成后,清单中就能看到添加的备份服务器,且SNMP监控为绿色,监控正常。

zabbix5.0_30

Zabbix5.0+Grafana可视化试用(三):通过SNMP添加华为S5700交换机实现数据采集及监控

zabbix5.0的设备添加并实现采集数据与监控的操作与4.x基本一样,首先交换机启用SNMP:

[Lan-center-s5700]snmp-agent
[Lan-center-s5700]snmp-agent community read cipher lsywsnmp123
[Lan-center-s5700]snmp-agent sys-info version all

启动SNMP后,在zabbix5.0中开始添加交换机,操作如下:

进入【配置】-【主机】配置界面,点击右上角的【创建主机】按扭,如下图所示

zabbix5.0_18

主机名称中输入全英文的名称,可见的名称中输入页面最终显示的中文名称,如下图所示,群组中选择网络群组,并移除agent代理程序的接口,SNMP接口点【添加】,并输入交换机的管理地址192.168.10.253,端口使用161默认不变。

zabbix5.0_19

再切换至模板选项栏,在Link new templates中选择【Template Net Huawei VRP SNMPv3】,如下图所示

zabbix5.0_20

切换至宏选项栏,在宏一栏中输入{$SNMP_COMMUNITY},在值一栏中输入刚才交换机设置的SNMP密码lsywsnmp123,如下图所示,完成后,点击【更新】按扭完成添加。

zabbix5.0_21

至此,交换机添加完成,过一段时间,列表中就有华为S5700核心交换机清单,监控项、触发器、图形等都有内容,如下图。

zabbix5.0_22

Zabbix5.0+Grafana可视化试用(二):将图形界面中的乱码修复为中文显示

默认zabbix在图形显示中中文显示为乱码,需要修复才能正常显示,如下图红框所示:

zabbix5.0_12

操作如下:

首先将WINDOWS FONTS文件夹中的黑体字复制至本机硬盘

zabbix5.0_13

将本地电脑上的黑体字体文件simhei.ttf复制到/usr/share/zabbix/assets/fonts/目录下,如下图

zabbix5.0_15

再通过vi修改/usr/share/zabbix/include目录下的defines.inc.php文件,将红框位置中原graphfont修改为simhei,如下图,完成后保存退出。

zabbix5.0_16

刷新图形界面,已能显示中文,如下。

zabbix5.0_17

Zabbix5.0+Grafana可视化试用(一):在CentOS8(1911)上采用二进制包安装Zabbix5.0.1

1、完成CentOS8(1911)安装

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
[root@localhost ~]# hostnamectl
   Static hostname: localhost.localdomain
          Icon name: computer-vm
           Chassis: vm
        Machine ID: f8712212dcd94fe0915ce5c9250b8d39
           Boot ID: fa1e9af220c349e4a760f3053ef4bee0
    Virtualization: vmware
  Operating System: CentOS Linux 8 (Core)
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-147.el8.x86_64
      Architecture: x86-64
[root@localhost ~]#

2、关闭防火墙及SElinux

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service

接着将SELinux关闭,运行如下命令编辑SELINUX配置文件:

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

并将SELINUX=enforcing改成SELINUX=disable,如下:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing – SELinux security policy is enforced.
#     permissive – SELinux prints warnings instead of enforcing.
#     disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted – Targeted processes are protected,
#     minimum – Modification of targeted policy. Only selected processes are protected.
#     mls – Multi Level Security protection.
SELINUXTYPE=targeted

修改完成后,重启机器,重启后运行getenforce命令查看已经关闭SELinux。

3、修改主机名hostname

[root@localhost ~]# hostnamectl –static set-hostname zabbixserver
[root@localhost ~]#
[root@localhost ~]# hostnamectl
    Static hostname: zabbixserver
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f8712212dcd94fe0915ce5c9250b8d39
           Boot ID: fa1e9af220c349e4a760f3053ef4bee0
    Virtualization: vmware
  Operating System: CentOS Linux 8 (Core)
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-147.el8.x86_64
      Architecture: x86-64
[root@localhost ~]#
[root@localhost ~]# more /etc/hostname
zabbixserver
[root@localhost ~]#
[root@localhost ~]# reboot

完成以上操作后重启系统。

4、安装依赖包

[root@zabbixserver ~]# yum install -y httpd mariadb-server mariadb php php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash

[root@zabbixserver ~]# rpm -qa httpd php mariadb
mariadb-10.3.17-1.module_el8.1.0+257+48736ea6.x86_64
httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64
php-7.2.11-2.module_el8.1.0+209+03b9a8ff.x86_64
[root@zabbixserver ~]#

5、相关配置

[root@zabbixserver ~]# vi /etc/httpd/conf/httpd.conf

将servername设置为192.168.10.218:80,在DirectoryIndex中添加index.php,如下:

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn’t have a registered DNS name, enter its IP address here.
#
ServerName 192.168.10.218:80

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
< IfModule dir_module>
    DirectoryIndex index.html index.php
< /IfModule>

接着配置php.ini,如下:

[root@zabbixserver ~]# vi /etc/php.ini

将date.timezone设置为PRC:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = PRC

开始启动http和mysql数据库:

[root@zabbixserver ~]# systemctl start httpd
[root@zabbixserver ~]# systemctl start mariadb
[root@zabbixserver ~]#
[root@zabbixserver ~]# ss -naplt | grep httpd
LISTEN   0         128                       *:80                     *:*        users:(("httpd",pid=31049,fd=4),("httpd",pid=31048,fd=4),("httpd",pid=31047,fd=4),("httpd",pid=31045,fd=4))
[root@zabbixserver ~]# ss -naplt | grep mysqld
LISTEN   0         80                        *:3306                   *:*        users:(("mysqld",pid=31397,fd=22))
[root@zabbixserver ~]#

设置开机自启动模式:

[root@zabbixserver ~]# systemctl enable httpd
[root@zabbixserver ~]#
[root@zabbixserver ~]# systemctl enable 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@zabbixserver ~]#

开始测试PHP功能:

[root@zabbixserver ~]# vi /var/www/html/index.php

输入以下内容:

<?php
phpinfo();
?>

打开http://192.168.10.218,显示如下界面说明PHP运行正常。

zabbix5.0_01

最后在centos8上安装中文语言包:

[root@zabbixserver ~]# yum install langpacks-zh_CN.noarch

6、配置并初始化数据库

设置mysql数据库root密码为zabbixroot,如下:

[root@zabbixserver ~]# mysqladmin -u root password zabbixroot
[root@zabbixserver ~]#
[root@zabbixserver ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.17-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 utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> GRANT all ON zabbix.* TO ‘zabbix’@’zabbixserver’ IDENTIFIED BY ‘zabbix123’;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>
MariaDB [(none)]> quit
Bye
[root@zabbixserver ~]#
[root@zabbixserver ~]#

7、安装依赖包

[root@zabbixserver ~]# yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel libevent-devel.x86_64

8、安装并配置zabbix5.0

[root@zabbixserver ~]# rpm -ivh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
warning: /var/tmp/rpm-tmp.3RlAnb: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Verifying…                          ################################# [100%]
Preparing…                          ################################# [100%]
Updating / installing…
   1:zabbix-release-5.0-1.el8         ################################# [100%]

[root@zabbixserver ~]# yum clean all
20 files removed
[root@zabbixserver ~]#

开始安装以下组件:

[root@zabbixserver ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent

导入初始架构和数据:

[root@zabbixserver ~]# cat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p -h 192.168.10.218 zabbix
Enter password:

输入zabbix用户的密码zabbix123,开始导入。

完成后开始配置zabbix server的配置文件,使配置文件中引用刚才创建的数据库,编辑/etc/zabbix/zabbix_server.conf文件:

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

完成如下DBHost、DBName、DBUser、DBPassword配置:

### Option: DBHost
#       Database host name.
#       If set to localhost, socket is used for MySQL.
#       If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
DBHost=zabbixserver

### Option: DBName
#       Database name.
#
# Mandatory: yes
# Default:
# DBName=

DBName=zabbix

### Option: DBSchema
#       Schema name. Used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBSchema=

### Option: DBUser
#       Database user.
#
# Mandatory: no
# Default:
# DBUser=

DBUser=zabbix

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=zabbix123

接着配置zabbix配置文件zabbix.conf:

[root@zabbixserver ~]# vi /etc/php-fpm.d/zabbix.conf

将date.timezone设置成Asia/Shanghai,如下:

php_value[date.timezone] = Asia/Shanghai

启动zabbix程序:

[root@zabbixserver ~]# systemctl restart zabbix-server zabbix-agent httpd php-fpm
[root@zabbixserver ~]#
[root@zabbixserver ~]#
[root@zabbixserver ~]# systemctl enable zabbix-server zabbix-agent httpd php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service 鈫/usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service 鈫/usr/lib/systemd/system/zabbix-agent.service.
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service 鈫/usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service 鈫/usr/lib/systemd/system/php-fpm.service.
[root@zabbixserver ~]#

查看日志文件zabbix_server.log,没有相关错误,说明运行正常

[root@zabbixserver ~]# more /var/log/zabbix/zabbix_server.log
  7323:20200531:164159.807 Starting Zabbix Server. Zabbix 5.0.1 (revision c2a0b03480).
  7323:20200531:164159.807 ****** Enabled features ******
  7323:20200531:164159.807 SNMP monitoring:           YES
  7323:20200531:164159.807 IPMI monitoring:           YES
  7323:20200531:164159.807 Web monitoring:            YES
  7323:20200531:164159.807 VMware monitoring:         YES
  7323:20200531:164159.807 SMTP authentication:       YES
  7323:20200531:164159.807 ODBC:                      YES
  7323:20200531:164159.807 SSH support:               YES
  7323:20200531:164159.807 IPv6 support:              YES
  7323:20200531:164159.807 TLS support:               YES
  7323:20200531:164159.807 ******************************
  7323:20200531:164159.807 using configuration file: /etc/zabbix/zabbix_server.conf
  7323:20200531:164159.867 current database version (mandatory/optional): 05000000/05000000
  7323:20200531:164159.867 required mandatory version: 05000000
  7323:20200531:164159.961 server #0 started [main process]
  7346:20200531:164159.962 server #1 started [configuration syncer #1]
  7349:20200531:164200.074 server #3 started [timer #1]
  7350:20200531:164200.075 server #4 started [http poller #1]
  7348:20200531:164200.076 server #2 started [housekeeper #1]
  7351:20200531:164200.077 server #5 started [discoverer #1]
  7353:20200531:164200.079 server #7 started [history syncer #2]
  7354:20200531:164200.080 server #8 started [history syncer #3]
  7352:20200531:164200.080 server #6 started [history syncer #1]
  7355:20200531:164200.081 server #9 started [history syncer #4]
  7357:20200531:164200.083 server #11 started [proxy poller #1]
  7356:20200531:164200.084 server #10 started [escalator #1]
  7362:20200531:164200.087 server #14 started [poller #1]
  7360:20200531:164200.091 server #12 started [self-monitoring #1]
  7367:20200531:164200.091 server #17 started [poller #4]
  7363:20200531:164200.099 server #15 started [poller #2]
  7361:20200531:164200.106 server #13 started [task manager #1]
  7372:20200531:164200.108 server #20 started [trapper #1]
  7364:20200531:164200.109 server #16 started [poller #3]
  7374:20200531:164200.119 server #22 started [trapper #3]
  7370:20200531:164200.124 server #18 started [poller #5]
  7373:20200531:164200.132 server #21 started [trapper #2]
  7378:20200531:164200.136 server #25 started [icmp pinger #1]
  7380:20200531:164200.137 server #26 started [alert manager #1]
  7383:20200531:164200.139 server #29 started [alerter #3]
  7371:20200531:164200.140 server #19 started [unreachable poller #1]
  7375:20200531:164200.142 server #23 started [trapper #4]
  7382:20200531:164200.150 server #28 started [alerter #2]
  7389:20200531:164200.162 server #35 started [lld worker #1]
  7390:20200531:164200.163 server #36 started [lld worker #2]
  7391:20200531:164200.164 server #37 started [alert syncer #1]
  7384:20200531:164200.164 server #30 started [preprocessing manager #1]
  7385:20200531:164200.165 server #31 started [preprocessing worker #1]
  7386:20200531:164200.166 server #32 started [preprocessing worker #2]
  7376:20200531:164200.167 server #24 started [trapper #5]
  7387:20200531:164200.184 server #33 started [preprocessing worker #3]
  7388:20200531:164200.188 server #34 started [lld manager #1]
  7381:20200531:164200.189 server #27 started [alerter #1]
  7362:20200531:164201.305 enabling Zabbix agent checks on host "Zabbix server": host became available
  7355:20200531:164242.192 item "Zabbix server:zabbix[process,ipmi poller,avg,busy]" became not supported:
No "ipmi poller" processes started.
  7354:20200531:164243.199 item "Zabbix server:zabbix[process,java poller,avg,busy]" became not supported:
No "java poller" processes started.
  7354:20200531:164247.346 item "Zabbix server:zabbix[process,snmp trapper,avg,busy]" became not supported:
  No "snmp trapper" processes started.
  7354:20200531:164247.346 item "Zabbix server:zabbix[process,ipmi manager,avg,busy]" became not supported:
  No "ipmi manager" processes started.
  7354:20200531:164248.448 item "Zabbix server:zabbix[process,vmware collector,avg,busy]" became not suppor
ted: No "vmware collector" processes started.
  7354:20200531:164255.770 item "Zabbix server:zabbix[vmware,buffer,pused]" became not supported: No "vmwar
e collector" processes started.
  7355:20200531:164320.376 item "Zabbix server:vfs.dev.read.await[sda]" became not supported: Cannot evalua
te expression: "Cannot evaluate function "last()": not enough data.".
  7355:20200531:164321.527 item "Zabbix server:vfs.dev.write.await[sda]" became not supported: Cannot evalu
ate expression: "Cannot evaluate function "last()": not enough data.".
  7353:20200531:164620.339 item "Zabbix server:vfs.dev.read.await[sda]" became supported
  7353:20200531:164621.449 item "Zabbix server:vfs.dev.write.await[sda]" became supported
  7348:20200531:171200.339 executing housekeeper
  7348:20200531:171200.360 housekeeper [deleted 0 hist/trends, 0 items/triggers, 0 events, 0 problems, 0 se
ssions, 0 alarms, 0 audit, 0 records in 0.013464 sec, idle for 1 hour(s)]

接着开始配置zabbix,输入http://192.168.10.218/zabbix,如下:

zabbix5.0_02

zabbix5.0_03

zabbix5.0_04

zabbix5.0_05

zabbix5.0_06

zabbix5.0_07

zabbix5.0_08

zabbix5.0_09

设置为中文界面,如下图。

zabbix5.0_10

zabbix5.0_11

Zabbix 4.4试用(五):通过SNMP监控CentOS7服务器

通过SNMP来监控LINUX服务器,首先在CENTOS服务器上安装SNMP,如下:

[root@localhost ~]# yum -y install net-snmp net-snmp-utils
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
  * base: mirrors.cn99.com
  * extras: mirrors.nju.edu.cn
  * updates: mirrors.nju.edu.cn
base

[root@localhost ~]# rpm -qa | grep snmp
net-snmp-libs-5.7.2-43.el7_7.3.x86_64
net-snmp-5.7.2-43.el7_7.3.x86_64
net-snmp-utils-5.7.2-43.el7_7.3.x86_64
net-snmp-agent-libs-5.7.2-43.el7_7.3.x86_64

zabbix4.4config_20

zabbix4.4config_21

通过snmpd -v查看SNMP版本:

[root@localhost ~]# snmpd -v

NET-SNMP version:  5.7.2
Web:               http://www.net-snmp.org/
Email:             net-snmp-coders@lists.sourceforge.net

[root@localhost ~]#

zabbix4.4config_22

开始更改团体名,更改为lsywsnmp123:

[root@localhost ~]# vi /etc/snmp/snmpd.conf

com2sec notConfigUser  default       public

更改为

com2sec notConfigUser  default       lsywsnmp123

重启SNMP服务,并设置为开机启动,如下:

[root@localhost ~]# systemctl start snmpd.service
[root@localhost ~]#
[root@localhost ~]# systemctl enable snmpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/snmpd.service to /usr/lib/systemd/system/snmpd.service.
[root@localhost ~]#
[root@localhost ~]#

zabbix4.4config_23

接着开始ZABBIX端的设置,添加这台CENTOS服务器:

zabbix4.4config_24

模块设置:

zabbix4.4config_27

设置宏中的团体名

zabbix4.4config_26

完成后,清单中已有服务器,SNMP监控也显示绿色,正常。

zabbix4.4config_28