zabbix的安装(centos)

 

1、yum部署lamp环境
[root@web02 ~]# yum -y install httpd httpd-devel mysql mysql-server mysql-devel php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml php-bcmath
[root@web02 ~]# rpm -qa php
php-5.3.3-49.el6.x86_64

升级php版本(zabbix要结合新版本的php运行):
[root@zabbix ~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm   #下载安装epel源
[root@zabbix ~]# rpm -ivh epel-release-6-8.noarch.rpm
[root@zabbix ~]# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm    #下载安装remi源
[root@zabbix ~]# rpm -ivh remi-release-6.rpm
[root@zabbix ~]# vim /etc/yum.repos.d/remi.repo
# Repository: http://rpms.remirepo.net/
# Blog: http://blog.remirepo.net/
# Forum: http://forum.remirepo.net/

[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
#mirrorlist=https://rpms.remirepo.net/enterprise/6/remi/httpsmirror
mirrorlist=http://cdn.remirepo.net/enterprise/6/remi/mirror
enabled=1         #此选项默认值为0,需要修改为1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[root@zabbix ~]# yum install php-ldap    #centos上安装php-ldap模块

[root@zabbix ~]# vim /var/www/html/index.php  #用浏览器打开http://ip/index.php就能看看php的信息以及ldap模块信息
<?php
phpinfo();
?>

防止提示zabbix-server is no running

setenforce 0  关闭selinux   

vim /etc/zabbix/web/zabbix.conf.php

$ZBX_SERVER      = '172.29.13.43';  改为本机IP

service httpd restart

service zabbix-server restart

service zabbix-agent restart

2、安装zabbix3.2
[root@zabbix ~]# rpm -i http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm
[root@zabbix ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
[root@zabbix ~]# mysql
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> quit;
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
[root@zabbix ~]# service zabbix-server start
[root@zabbix ~]# service zabbix-agent start
[root@zabbix ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
[root@zabbix ~]# service httpd restart
[root@zabbix ~]# cd /var/www/html/
[root@zabbix html]# ln -s /usr/share/zabbix zabbix 
[root@zabbix ~]# sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini
[root@zabbix ~]# sed -i 's/max_input_time = 60/max_input_time = 300/g' /etc/php.ini
[root@zabbix ~]# sed -i 's/post_max_size = 8M/post_max_size = 16M/g' /etc/php.ini
[root@zabbix ~]#service zabbix-server restart

3、解决zabbix部分乱码(改成中文时部分显示乱码)
1)进入windows 的 fonts目录,拷贝宋体的字体文件simsun.ttc到/var/www/html/zabbix/fonts 目录下(注意文件名必需改为simsun.ttf,权限改为777)
2)修改zabbix 的页面管理设置
[root@zabbix ~]# vim /var/www/html/zabbix/include/defines.inc.php
#修改下面2个配置
45 define( 'ZBX_GRAPH_FONT_NAME', 'simsun')
93 define( 'ZBX_FONT_NAME', 'simsun ')

4、zabbix 邮件告警设置

(1)、邮件发送配置
[root@Zabbix ~]# yum -y install mail         #如有mail命令则不用安装
[root@Zabbix ~]# vim /etc/mail.rc
# Display the recipients of messages sent by the user himself in
# header summaries.
set showto
# Automatically check for new messages at each prompt, but avoid polling
# of IMAP servers or maildir folders.
set newmail=nopoll
# If threaded mode is activated, automatically collapse thread.
set autocollapse
# Hide some header fields which are uninteresting for most human readers.
ignore received in-reply-to message-id references
ignore mime-version content-transfer-encoding
# Only include selected header fields when forwarding messages.
fwdretain subject date from to
# For Linux and BSD, this should be set.
set from=zabbix@eascs.com                            #发送的邮件地址
set smtp=smtp1.eascs.com                              #外部smtp服务器的地址
set smtp-auth-user=hu.li@eascs.com              #外部smtp服务器认证的用户名
set smtp-auth-password=123456                     #外部smtp服务器认证的用户密码(如用163或qq邮箱则为授权码)
set smtp-auth=login                                          #邮件认证的方式
[root@Zabbix ~]# echo "邮件正文"|mail -s "邮件主题" 收件人地址           #发送邮件测试命令

(2)、告警脚本内容
[root@Zabbix ~]# yum -y install dos2unix
[root@Zabbix ~]# vim /usr/lib/zabbix/alertscripts/mail.sh
#!/bin/bash
# use mailx to send mail
# 20141127 carl 1st
# PATH
file=/tmp/zabbix_mail.txt
echo "$3" > $file
dos2unix -k $file
/bin/mail -s "$2" $1 < $file
# echo "$3" | mail -s "$2" $1
#注:使用dos2unix工具是为解决zabbix发送邮件出现乱码和收到的邮件是*.bin的情况
#$3 是前端定义的邮件内容,$2是前端定义的主题,$1是前端定义的收件人
[root@Zabbix alertscripts]# chmod 777 mail.sh
[root@Zabbix alertscripts]# chown zabbix.zabbix mail.sh

(3)、zabbix配置脚本告警内容

管理-->交警媒介类型-->创建媒介类型

 {ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}

 

配置-->动作-->(动作)(操作)(恢复操作)

A 触发器示警度 = 警告
B 触发器示警度 = 灾难
C 触发器示警度 = 严重
D 触发器示警度 = 一般严重

告警主机: {HOSTNAME1}
告警项目:{TRIGGER.KEY1}
当前状态: {TRIGGER.STATUS}
告警信息: {TRIGGER.NAME }
告警等级: {TRIGGER.SEVERITY}
告警时间: {EVENT.DATE} {EVENT.TIME}
问题详情: {ITEM.NAME1}({ITEM.VALUE1})

事件 ID: {EVENT.ID }

 

 

Zabbix使用ICMP ping监控网络状况

[root@lihu install]# wget http://www.fping.org/dist/fping-4.0.tar.gz
[root@lihu install]# tar xf fping-4.0.tar.gz
[root@lihu install]# cd fping-4.0
[root@lihu fping-4.0]# ./configure --prefix=/usr/local/fping/
[root@lihu fping-4.0]# make && make install

修改属主属组及权限

[root@lihu fping-4.0]# chown root:zabbix /usr/local/fping/sbin/fping
[root@lihu fping-4.0]# chmod 4710 /usr/local/fping/sbin/fping

vim /etc/zabbix/zabbix_server.conf

FpingLocation=/usr/local/fping/sbin/fping

测试OK

[root@lihu_centos ~]# /usr/local/fping/sbin/fping www.baidu.com
www.baidu.com is alive

添加Template ICMP Ping 模块图形

 

posted @ 2018-05-14 15:01  Me-lihu  阅读(10)  评论(0编辑  收藏  举报