monicazhang 发表于 2017-10-6 19:44:38

关于企业级监控zabbix3.2的部署及使用手册的讲述

部署环境介绍

第一部分:在zabbix服务端的操作1. 初始化yum install gcc gcc-c++ vim-enhanced glibc make unzip openssl openssl-devel openssh-server openssh-clients wget -y2. 配置时间同步yum install ntp -y/usr/sbin/ntpdate cn.pool.ntp.orgcrontab -e* */1 * * * /usr/sbin/ntpdate cn.pool.ntp.org &> /dev/null一:给Zabbix安装mysql数据库(yum装即可)yum list installed | grep mysqlyum remove mysql* -yrpm -ivh get/mysql-community-release-el6-5.noarch.rpmyum install mysql-server -yvim /etc/my.cnf1. 在mysqld下添加如下配置:innodb_file_per_tablecharacter-set-server = utf8service mysqld start初始化,设置密码:mysql_secure_installation(一直回车即可,碰到输入密码时键入密码,继续回车)2. 登录数据库mysql -u root -p1111113. 创建数据库CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'your_password';show databases;4. 显示如下,即可,说明zabbix数据库创建成功二:准备zabbix的web环境rpm -ivh yum/el6/latest.rpmyum install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldapvim /etc/php.ini把几个参数的修改成如下所示post_max_size=16Mmax_execution_time=300max_input_time=300date.timezone= Asia/Shanghaialways_populate_raw_post_data=-1service httpd startiptables -I INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPTiptables-save > /etc/sysconfig/iptables在网页输入:显示如下,说明安装成功三:下载及安装zabbixgroupadd zabbixuseradd -g zabbix zabbixmkdir /home/zabbix/downloadscd /home/zabbix/downloadstar -zxvf zabbix-3.2.6.tar.gz(官网可下载)cd /home/zabbix/downloads/zabbix-3.2.6/database/mysqlmysql -u zabbix -p zabbix < schema.sql(Enter password: your_password)mysql -u zabbix -p zabbix < images.sql(Enter password: your_password)mysql -u zabbix -p zabbix < data.sql(Enter password: your_password)yum install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel -ycd /home/zabbix/downloads/zabbix-3.2.6./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl显示如下:************************************************************ Now run 'make install' ** Thank you for using Zabbix! ** <h > *开始编译安装make install在启动Zabbix服务器之前,我们需要修改其配置文件才能连接到数据库。vim /usr/local/etc/zabbix_server.confDBName=zabbixDBUser=zabbixDBPassword=your_passwordmkdir /var/www/html/zabbix移动到下载的Web界面源cd /home/zabbix/downloads/zabbix-3.2.6/frontends/php/将所有文件复制到服务器Web目录cp -a . /var/www/html/zabbix/chcon -Rv --type=httpd_sys_content_t /var/www/htmlsetsebool -P httpd_can_network_connect=1setsebool -P zabbix_can_network=1chown -R apache:apache /var/www/html/zabbixchmod +x /var/www/html/zabbix/conf/cp /home/zabbix/downloads/zabbix-3.2.6/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_servercp /home/zabbix/downloads/zabbix-3.2.6/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentdchkconfig --add /etc/init.d/zabbix_serverchkconfig --add /etc/init.d/zabbix_agentdchkconfig httpd onchkconfig mysqld onchkconfig zabbix_server onchkconfig zabbix_agentd onservice zabbix_server startservice zabbix_agentd start四:在web界面操作zabbix在浏览器输入:192.169.199.173/zabbix显示如下:
点击next step,显示如下继续点击nextstep,显示如下
此处的密码输入我们之前在配置文件里的密码:your_password继续点击next step,出现如下:
继续点击next step:知道出现finish,点击finish出现如下:
用户名为Admin,密码为zabbix点击Sign in则可以登录到zabbix的web界面了第二部分:在zabbix客户端的操作rpm -ivh zabbix-agent-3.2.6-1.el6.x86_64.rpmcp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bakmkdir /usr/local/zabbixcd /usr/local/zabbixvim service.sh#!/bin/bashDISKSIZE=`df -h|grep '9%'`DISKSIZE2=`df -h|grep '100%' | grep -v 'media'`if [ ! -z "$DISKSIZE" ] || [ ! -z "$DISKSIZE2" ]thenecho 1elseecho 0fichmod +x /usr/local/zabbix/service.shvim /etc/zabbix/zabbix_agentd.conf修改如下值:Server=192.168.199.173ServerActive=192.168.199.173UserParameter=service.disk,/usr/local/zabbix/service.sh/etc/init.d/zabbix-agent start第三部分:在zabbix的web界面添加监控的主机通过本地浏览器访问http://ZabbixServerIP/zabbix来配置和使用zabbix,这里我输入的是192.168.199.173,一次完整的监控流程可以简单描述为:Host Groups(设备组)->Host(设备)->Applications(监控项组)->Items(监控项)->Tiggers(触发器)->Actions(告警动作)->Medias(告警方式)->User Groups(用户组) ->User(用户)1. 添加Host groep
2添加 HostHost是Zabbix监控的基本载体,所有的监控项都是基于host的。通过Configuration->Host-s>Create Host来创建监控设备点击create host之后显示如下:
点击最下面的添加即可3. 创建一个自己的template(1)创建template(2)创建application
(3)创建itens(key值时要跟被监控端的service.sh里面的一致,下面会说到)(4)创建triggers
在zabbix被监控端(192.168.199.176)vim /usr/localzabbix/service.sh修改为入下所示:#!/bin/bashDISKSIZE=`df -h|grep '9%'`DISKSIZE2=`df -h|grep '100%' | grep -v 'media'`if [ ! -z "$DISKSIZE" ] || [ ! -z "$DISKSIZE2" ]thenecho 0elseecho 1Fi在zabbix的web端看到如下说明成功了:4.测试
第三部分 实现邮件报警yum install sendmail -yservice sendmail startchkconfig sendmail onyum install -y postfixservice postfix startchkconfig postfix on移除旧的组件yum remove mailx -y源码安装新版组件wget project/heirloom/heirloom-mailx/12.4/mailx-12.4.tar.bz2wget patches/blfs/7.6/mailx-12.4-openssl_1.0.0_build_fix-1.patchtar -xvf mailx-12.4.tar.bz2mv mailx-12.4-openssl_1.0.0_build_fix-1.patch mailx-12.4cd mailx-12.4yum install patch -y需要打补丁patch -Np1 -i mailx-12.4-openssl_1.0.0_build_fix-1.patchmakemake install UCBINSTALL=/usr/bin/install需要做软连接ln -s /usr/local/bin/mailx /bin/mailln -s /etc/nail.rc /etc/mail.rc查看安装路径whereis mailx查看版本信息mailx -V配置外部邮箱地址vim /etc/mail.rc# Only include selected header fields when forwarding messages.fwdretain subject date from toset from=15011572657@163.comset smtp=smtp.163.comset smtp-auth-user=xxxxxxset smtp-auth-password=xxxxxxset smtp-auth=login测试email发送echo "zabbix test mail 4" |mail -s "ys zabbix 6" 1980570647@qq.com在zabbix控制端(1)设置告警方式Admininistrator-Mediatypes-Email(设置smtp,username:xxxxxxxx,password:xxxxxxxx)-update(2)添加actionConfiguration-Actions-create actionAction部分:Name:Action-EmailNew condition:Host group=测试Operations部分:Configuration-Actions-OperationsDefault operation step duration:60Default subject:故障{TRIGGER.STATUS},服务器:{HOSTNAME1}发生: {TRIGGER.NAME}故障!Default messages:告警主机:{HOSTNAME1}主机IP:{HOST.IP}告警时间:{EVENT.DATE} {EVENT.TIME}告警等级:{TRIGGER.SEVERITY}告警信息: {TRIGGER.NAME}告警项目:{TRIGGER.KEY1}问题详情:{ITEM.NAME}:{ITEM.VALUE}当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}事件ID:{EVENT.ID}Recovery operations:Default subject:恢复{TRIGGER.STATUS}, 服务器:{HOSTNAME1}: {TRIGGER.NAME}已恢复!Default messages:告警主机:{HOSTNAME1}主机IP:{HOST.IP}告警时间:{EVENT.DATE} {EVENT.TIME}告警等级:{TRIGGER.SEVERITY}告警信息: {TRIGGER.NAME}告警项目:{TRIGGER.KEY1}问题详情:{ITEM.NAME}:{ITEM.VALUE}当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}事件ID:{EVENT.ID}(3)添加报警用户:Configuration-users-media至此,zabbix的部署及报警就可以实现了,还有自定义的一些监控项并未提及,后续还有更新!!



原创:韩先超



页: [1]
查看完整版本: 关于企业级监控zabbix3.2的部署及使用手册的讲述