Archive for 4月 2020

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

Zabbix 4.4试用(四):通过SNMP监控Windows 2008R2

ZABBIX支持通过zabbix agent或SNMP来添加和监控WINDOWS服务器,本次将以WINDOWS 2008R2为例 ,通过SNMP来实现WINDOWS服务器的监控,操作如下:

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

zabbix4.4config_12

选择SNMP服务,如下图

zabbix4.4config_13

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

zabbix4.4config_14

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

zabbix4.4config_15

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

zabbix4.4config_16

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

zabbix4.4config_17

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

zabbix4.4config_18

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

zabbix4.4config_19

Zabbix 4.4试用(三):通过SNMP监控华为交换机S5700

zabbix支持通过SNMP或ZABBIX AGENT采集设备信息,交换机自带SNMP,且不能安装ZABBIX AGENT组件,故交换机一般通过SNMP来管理,首先配置交换机,启用SNMP,操作如下:

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

zabbix4.4config_06

启用SNMP后,在zabbix中添加此交换机,开始监控,操作如下:

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

zabbix4.4config_07

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

zabbix4.4config_08

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

zabbix4.4config_09

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

zabbix4.4config_10

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

zabbix4.4config_11

至此,交换机添加完成。

Zabbix 4.4试用(二):将图形界面中的乱码修复为中文显示

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

zabbix4.4config_01

操作如下:

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

zabbix4.4config_02

然后在服务器上操作zabbix-web-nginx-mysql容器,通过docker ps查看zabbix-web-nginx-mysql容器的ID,如下图,这里为48a2c96acc9c

zabbix4.4config_03

通过docker exec进入进入zabbix-web-nginx-mysql容器进行操作,首先查询需要修改的DejaVuSans.ttf和defines.inc.php两个文件的位置,操作如下:

[root@localhost zabbix]# docker exec -it 48a2c96acc9c bash
bash-5.0# find / -name DejaVuSans.ttf
/usr/share/zabbix/assets/fonts/DejaVuSans.ttf
bash-5.0#
bash-5.0# find / -name defines.inc.php
/usr/share/zabbix/include/defines.inc.php
bash-5.0#

然后将刚才本地电脑上的黑体字体文件simhei.ttf复制到/usr/share/zabbix/assets/fonts/目录下,然后通过vi修改defines.inc.php文件,将红框位置中原DejaVuSans修改为simhei,如下图,完成后保存退出。

zabbix4.4config_04

再次刷新图形,已能显示中文,如下图所示。至此修改完成。

zabbix4.4config_05

Zabbix 4.4试用(一):在Centos7上通过Docker方式安装Zabbix 4.4

之前采用一步步安装方式完成了zabbix4.0.2的安装,最近有4.4新版本,且想通过Docker方式安装,操作步骤简洁好多,准备一试。

首先在VMware vSphere平台上完成Centos7.5.1804虚拟机的安装,配置IP地址。然后完成如下步骤的安装:

1、关闭并禁用防火墙

[root@localhost etc]# firewall-cmd –state
running
[root@localhost etc]#
[root@localhost etc]# systemctl stop firewalld.service
[root@localhost etc]#
[root@localhost etc]#
[root@localhost etc]# 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 etc]#
[root@localhost etc]#
[root@localhost etc]# firewall-cmd –state
not running
[root@localhost etc]#

zabbixdocker4.4_01

2、关闭SELINUX

将配置文件/etc/selinux/config的SELINUX设置为disabled,操作如下:

[root@localhost etc]# sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g’ /etc/selinux/config
[root@localhost etc]#
[root@localhost etc]#
[root@localhost etc]# grep "SELINUX=disabled" /etc/selinux/config
SELINUX=disabled
[root@localhost etc]#

zabbixdocker4.4_02

配置完成后reboot重启,再使用getenforce命令查看是否关闭SELINUX:

[root@localhost ~]# getenforce
Disabled
[root@localhost ~]#

zabbixdocker4.4_03

3、安装docker

开始安装docker,首先安装docker-ce所需的依赖包:

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
  * base: mirrors.163.com
  * extras: mirrors.aliyun.com
  * updates: mirrors.163.com
base

zabbixdocker4.4_04

设置docker-ce在线存储库,这里设置为阿里云在线存储库,操作如下:

[root@localhost ~]# yum-config-manager –add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]#
[root@localhost ~]#

zabbixdocker4.4_05

开始安装docker,

[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base docker-ce-stable extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost ~]#
[root@localhost ~]# yum makecache fast
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
  * base: mirrors.cn99.com
  * extras: mirrors.cn99.com
  * updates: mirrors.cn99.com
base
docker-ce-stable
extras
updates
(1/6): docker-ce-stable/x86_64/updateinfo
(2/6): docker-ce-stable/x86_64/primary_db
(3/6): base/7/x86_64/group_gz
(4/6): extras/7/x86_64/primary_db
(5/6): base/7/x86_64/primary_db
(6/6): updates/7/x86_64/primary_db
Metadata Cache Created
[root@localhost ~]#
[root@localhost ~]#yum install -y docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
  * base: mirrors.cn99.com
  * extras: mirrors.cn99.com
  * updates: mirrors.cn99.com
Resolving Dependencies
–> Running transaction check
—> Package docker-ce.x86_64 3:19.03.8-3.el7 will be installed

zabbixdocker4.4_06

启动并开机自启动docker,操作如下:

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

zabbixdocker4.4_07

docker版本号及信息查看:

[root@localhost ~]# docker version
Client: Docker Engine – Community
  Version:           19.03.8
  API version:       1.40
  Go version:        go1.12.17
  Git commit:        afacb8b
  Built:             Wed Mar 11 01:27:04 2020
  OS/Arch:           linux/amd64
  Experimental:      false

Server: Docker Engine – Community
  Engine:
   Version:          19.03.8
   API version:      1.40 (minimum version 1.12)
   Go version:       go1.12.17
   Git commit:       afacb8b
   Built:            Wed Mar 11 01:25:42 2020
   OS/Arch:          linux/amd64
   Experimental:     false
  containerd:
   Version:          1.2.13
   GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
  runc:
   Version:          1.0.0-rc10
   GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
  docker-init:
   Version:          0.18.0
   GitCommit:        fec3683
[root@localhost ~]# docker info
Client:
  Debug Mode: false

Server:
  Containers: 0
   Running: 0
   Paused: 0
   Stopped: 0
  Images: 0
  Server Version: 19.03.8
  Storage Driver: overlay2
   Backing Filesystem: <unknown>
   Supports d_type: true
   Native Overlay Diff: true
  Logging Driver: json-file
  Cgroup Driver: cgroupfs
  Plugins:
   Volume: local
   Network: bridge host ipvlan macvlan null overlay
   Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
  Swarm: inactive
  Runtimes: runc
  Default Runtime: runc
  Init Binary: docker-init
  containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
  runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
  init version: fec3683
  Security Options:
   seccomp
    Profile: default
  Kernel Version: 3.10.0-862.el7.x86_64
  Operating System: CentOS Linux 7 (Core)
  OSType: linux
  Architecture: x86_64
  CPUs: 4
  Total Memory: 7.639GiB
  Name: localhost.localdomain
ID: RFQ5:YIQ2:LDAJ:WVSG:OIWX:KJDP:OFS4:YZOX:OT6V:AIXQ:Y5XT:EC7B
  Docker Root Dir: /var/lib/docker
  Debug Mode: false
  Registry: https://index.docker.io/v1/
  Labels:
  Experimental: false
  Insecure Registries:
   127.0.0.0/8
  Live Restore Enabled: false

4、安装zabbix

启动一个mysql实例,操作如下:

[root@localhost ~]# docker run –name mysql-server -t -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_ROOT_PASSWORD="zabbix" -d mysql:5.7  –character-set-server=utf8 –collation-server=utf8_bin
Unable to find image ‘mysql:5.7’ locally
5.7: Pulling from library/mysql
c499e6d256d6: Downloading [=>                                                 ]  833.9kB/27.09MB
22c4cdf4ea75: Download complete
6ff5091a5a30: Downloading [===================>                               ]  1.661MB/4.178MB
2fd3d1af9403: Download complete
0d9d26127d1d: Download complete
54a67d4e7579: Downloading [=========>                                         ]  2.603MB/13.44MB
fe989230d866: Waiting
466a91a95e2f: Waiting
3e4554c238f1: Waiting
603b48ead88c: Waiting

zabbixdocker4.4_08

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                 NAMES
e7f3382c954d        mysql:5.7           "docker-entrypoint.s鈥   About a minute ago   Up About a minute   3306/tcp, 33060/tcp   mysql-server
[root@localhost ~]#

完成后启动ZABBIX JAVA GATEWAY实例,操作如下:

[root@localhost ~]# docker run –name zabbix-java-gateway -t –restart unless-stopped -d zabbix/zabbix-java-gateway:latest
Unable to find image ‘zabbix/zabbix-java-gateway:latest’ locally
latest: Pulling from zabbix/zabbix-java-gateway
aad63a933944: Pull complete
d3ba7323f78e: Pull complete
116fee55b2cb: Pull complete
008031baaa1a: Pull complete
759297fddc58: Pull complete
bdc3c870522b: Pull complete
Digest: sha256:d71da91fc4bb197070724cb2937ebb6548dee73de9df9e7747db895f488c2174
Status: Downloaded newer image for zabbix/zabbix-java-gateway:latest
b6dd2a948eb1076da5ddeacf322f06099aad653987ee344cbc79c0869eee780d
[root@localhost ~]#

zabbixdocker4.4_09

完成后开始启动zabbix server实例,并关联这个实例到刚才已创建的MYSQL服务器实例,操作如下:

[root@localhost ~]# docker run –name zabbix-server-mysql -t -e DB_SERVER_HOST="mysql-server" -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_ROOT_PASSWORD="zabbix" –link mysql-server:mysql -p 10051:10051 -d zabbix/zabbix-server-mysql:latest
Unable to find image ‘zabbix/zabbix-server-mysql:latest’ locally
latest: Pulling from zabbix/zabbix-server-mysql
aad63a933944: Already exists
dc473403998d: Pull complete
3f3f207b0d86: Pull complete
4278aa9ace68: Pull complete
Digest: sha256:8bc24ef87310170a581f5b5881e36e6464062d17f2f2b30e6520281d07e8366f
Status: Downloaded newer image for zabbix/zabbix-server-mysql:latest
c9c0e158a93f541c5a50ae92cd1c5ff82cda5043813fa74d1938e0fe9b5d76de
[root@localhost ~]#

zabbixdocker4.4_10

最后启动ZABBIX WEB接口,并将它与MYSQL服务器实例和ZABBIX SERVER实例关联,操作如下:

[root@localhost ~]# docker run –name zabbix-web-nginx-mysql -t -e DB_SERVER_HOST="mysql-server" -e MYSQL_DATABASE="zabbix" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_ROOT_PASSWORD="zabbix" –link mysql-server:mysql –link zabbix-server-mysql:zabbix-server -p 8080:80 -d zabbix/zabbix-web-nginx-mysql:latest
Unable to find image ‘zabbix/zabbix-web-nginx-mysql:latest’ locally
latest: Pulling from zabbix/zabbix-web-nginx-mysql
aad63a933944: Already exists
f4eabf890618: Pull complete
39f7583adc90: Pull complete
7776e04aff55: Pull complete
fb275d4b4f50: Pull complete
2614dbe8b3f3: Pull complete
8d65f383f456: Pull complete
1b9047914505: Pull complete
be585e988008: Pull complete
ad312041223c: Pull complete
94362bde1339: Pull complete
Digest: sha256:0685485848ce4f759b207f888c4870f936072e4bcf8e5934c3cad62fa5ea4410
Status: Downloaded newer image for zabbix/zabbix-web-nginx-mysql:latest
48a2c96acc9c22ca77dc487a410863487234ad17afe26dafd8c4843b0cf5c46e
[root@localhost ~]#

zabbixdocker4.4_11

查看状态:

[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE                                  COMMAND                  CREATED              STATUS              PORTS                           NAMES
48a2c96acc9c        zabbix/zabbix-web-nginx-mysql:latest   "docker-entrypoint.sh"   About a minute ago   Up About a minute   443/tcp, 0.0.0.0:8080->80/tcp   zabbix-web-nginx-mysql
c9c0e158a93f        zabbix/zabbix-server-mysql:latest      "/sbin/tini — /usr/鈥   6 minutes ago        Up 6 minutes        0.0.0.0:10051->10051/tcp        zabbix-server-mysql
b6dd2a948eb1        zabbix/zabbix-java-gateway:latest      "docker-entrypoint.s鈥   10 minutes ago       Up 10 minutes       10052/tcp                       zabbix-java-gateway
e7f3382c954d        mysql:5.7                              "docker-entrypoint.s鈥   15 minutes ago       Up 15 minutes       3306/tcp, 33060/tcp             mysql-server
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
zabbix/zabbix-java-gateway      latest              660ab57f1078        6 days ago          82MB
zabbix/zabbix-web-nginx-mysql   latest              2cc114aa7b9c        6 days ago          167MB
zabbix/zabbix-server-mysql      latest              2bb0dd73957d        6 days ago          64.7MB
mysql                           5.7                 413be204e9c3        2 weeks ago         456MB
[root@localhost ~]#

zabbixdocker4.4_13

至此,DOCKER方式安装ZABBIX已经安装,输入网址http://IP:8080,即可打开ZABBIX,用户名Admin,密码zabbix,如下:

zabbixdocker4.4_12

zabbixdocker4.4_14

VMware vSphere 7.0正式版发布

下载地址。(提取码:5g6t)

1、VMware-VMvisor-Installer-7.0.0-15843807.x86_64.iso
2、VMware-ESXi-7.0.0-15843807-depot.zip
3、VMware-VCSA-all-7.0.0-15952498.iso