zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix由zabbix server与可选组件zabbix agent两部门组成。

zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视。
 zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。
zabbix的主要特点:

- 安装与配置简单,学习成本低 

- 支持多语言(包括中文)

- 免费开源

- 自动发现服务器与网络设备

- 分布式监视以及WEB集中管理功能

- 可以无agent监视

- 用户安全认证和柔软的授权方式

- 通过WEB界面设置或查看监视结果

- email等通知功能

等等
Zabbix主要功能:

- CPU负荷

- 内存使用

- 磁盘使用

- 网络状况

- 端口监视

请看我用dockerfile构建zabbix agent
FROM docker.io/centos:latest
MAINTAINER zailing <huzailingcom@gmail.com>
RUN yum clean all
RUN yum install -y yum-plugin-fastestmirror yum-utils epel-release
RUN yum update -y
# utils
RUN yum install -y git hostname sudo less iproute psmisc net-tools \
bash unzip which tar passwd ed m4 patch rsync wget curl tcpdump telnet \
tar bzip2 unzip strace supervisor openssl openssh openssh-server \
openssh-clients util-linux inotify-tools
# dev
RUN yum install -y gcc-c++ libtool make gdb mariadb-devel snappy-devel \
boost-devel lz4-devel zlib-devel libcurl-devel libevent-devel \
libesmtp-devel libuuid-devel libcsv-devel cyrus-sasl-devel \
bzip2-devel libpqxx-devel libxml2-devel libxslt-devel libxslt-python \
libpng-devel jemalloc-devel fontconfig-devel pcre-devel
# deps
RUN yum install -y redis sqlite mariadb mariadb-server postgresql
# python
RUN yum install -y python-pip python-devel python-lxml python-setuptools
RUN mkdir /var/run/sshd
RUN ssh-keygen -t rsa -q -f /etc/ssh/ssh_host_rsa_key -P ""
RUN ssh-keygen -t dsa -q -f /etc/ssh/ssh_host_dsa_key -P ""
RUN ssh-keygen -t rsa -q -f /root/.ssh/id_rsa -P ""
RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys
RUN echo 'root:123123’ | chpasswd
RUN sed -i 's/.*session.*required.*pam_loginuid.so.*/session optional pam_loginuid.so/g' /etc/pam.d/sshd
RUN echo -e "LANG=\"en_US.UTF-8\"" > /etc/default/local
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
RUN cp /usr/lib64/mysql/libmysqlclient* /usr/lib64/
RUN rm -rf etc/localtime && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "bind '\"\e[A\":history-search-backward'" >> /root/.bashrc
RUN echo "bind '\"\e[B\":history-search-forward'" >> /root/.bashrc
RUN echo "export HISTTIMEFORMAT='%F %T '" >> /root/.bashrc
EXPOSE 22
RUN chmod u+s /usr/bin/ping
RUN rpm -ivh zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
RUN yum install -y zabbix-agent
EXPOSE 10050
ENV ZABBIX_SERVER=127.0.0.1 \
HOSTNAME=zabbix.agent
VOLUME ["/data/proc"]
VOLUME ["/data/dev"]
VOLUME ["/data/sys"]
RUN yum clean all
ADD container-files /
RUN chmod +x /config/bootstrap.sh
RUN chmod +x -f /config/init/*.sh; exit 0
ENTRYPOINT ["/config/bootstrap.sh"]
docker-compose的书写格式如下 docker-compose.yml
version: '2'
services:
zabbix-agent:
build: .
image: zailing/zabbix-agent
container_name: zabbix-agent
hostname: zabbix-agent
privileged: true
read_only: false
tty: false
network_mode: "bridge"
ulimits:
nofile:
soft: 102400
hard: 102400
ports:
- "127.0.0.1:2222:22"
- "10050:10050"
volumes:
- /proc:/data/proc
- /dev:/data/dev
- /sys:/data/sys
environment:
- ZABBIX_SERVER=172.17.0.1
- HOSTNAME=172.17.0.2
原创:钟春细
|