zabbix2.0.4下载
http://sourceforge.net/projects/zabbix/files/ZABBIX Latest Stable/2.0.4/zabbix-2.0.4.tar.gz/download
http://www.zabbix.com/download.php 里面有很多插件下载
yum安装时候出现错误
echo "alias yum='yum --disableplugin=fastestmirror'" >> /root/.bashrc
rm -f /var/run/yum.pid
退出后重新启动 或者 reboot
一些基本的关联的应用包
1、安装LAMP环境及依赖包
yum install mysql-server mysql-devel libcurl-devel net-snmp-devel php php-gd php-xml php-mysql php-mbstring php-bcmath httpd
yum install gcc c++ gcc-c++ curl-devel xmlrpc (毕竟接下来也是用GCC编译的)
2、添加用户并设置启动项
[root@localhost ~]# groupadd zabbix
[root@localhost ~]# useradd zabbix -g zabbix
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig snmpd on
3、创建数据库,添加用户授权
[root@localhost ~]# /etc/init.d/mysqld start
[root@localhost ~]# mysql -e "create database zabbix character set utf8;"
[root@localhost ~]# mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'abc123';"
4、编译安装zabbix
[root@localhost ~]# cd /root/Desktop/ (我当时下载到桌面,FlashFXP一款很强大的工具,windows下载传输给linux)
[root@localhost Desktop]# tar zxf zabbix-2.0.4.tar.gz
[root@localhost Desktop]# cd zabbix-2.0.4
[root@localhost zabbix-2.0.4]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
编译成功后出现的图片(可能在编译时出现错误,请根据错误安装相对应的包)
[root@localhost zabbix-2.0.4]# make install
5、导入数据库
[root@localhost zabbix-2.0.4]# mysql -uzabbix -p'abc123' zabbix < database/mysql/schema.sql
[root@localhost zabbix-2.0.4]# mysql -uzabbix -p'abc123' zabbix < database/mysql/images.sql
有可能报错
ERROR 1062 (23000) at line 1: Duplicate entry '1' for key 'PRIMARY'
删掉zabbix库 从新再来一次
drop database 库名字;
[root@localhost zabbix-2.0.4]# mysql -uzabbix -p'abc123' zabbix < database/mysql/data.sql
6、拷贝、修改配置文件
[root@localhost zabbix-2.0.4]# sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@localhost zabbix-2.0.4]# sed -i 's/^.*DBPassword=.*$/DBPassword=abc123/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@localhost zabbix-2.0.4]# cp -r frontends/php /var/www/html/zabbix
[root@localhost zabbix-2.0.4]# cp misc/init.d/fedora/core/zabbix_server /etc/init.d/(将zabbix服务拷贝到 /etc/init.d/下,方便而已)
[root@localhost zabbix-2.0.4]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/(将zabbix_agentd服务拷贝到 /etc/init.d/下,方便而已)
[root@localhost zabbix-2.0.4]#sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server
[root@localhost zabbix-2.0.4]#sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
7、添加服务端口
[root@localhost ~]# cat >>/etc/services <<EOF
zabbix-agent 10050/tcp Zabbix Agent
zabbix-agent 10050/udp Zabbix Agent
zabbix-trapper 10051/tcp Zabbix Trapper
zabbix-trapper 10051/udp Zabbix Trapper
EOF
8、修改php.ini(这里必须修改的,否则没办法进入zabbix的web界面的部署)
[root@localhost ~]#sed -i 's/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g' /etc/php.ini
[root@localhost ~]#sed -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /etc/php.ini
[root@localhost ~]#sed -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /etc/php.ini
[root@localhost ~]#sed -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /etc/php.ini
9、启动服务
[root@localhost ~]# /etc/init.d/zabbix_server start
[root@localhost ~]# /etc/init.d/zabbix_agentd start
启动 zabbix_agentd 报错faile
vi /etc/init.d/zabbix_agentd
修改 # Zabbix-Directory
BASEDIR="/usr/local/zabbix/"
10、进入WEB界面
在搭建的服务器,首先查看IP地址
点击NEXT
之前都已经配置好了,所以都是OK。直接NEXT
1:Database type :mysql
2:Database host : localhost
3: Database port : 0(以默认为主)
4:Database name : zabbix
5: User : zabbix(当时添加时zabbix用户名)mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'abc123';"
6:Password : abc123
点击test connection
点击NEXT
点击NEXT
点击NEXT
到这里终于出现红色的错误。没关系,这里有提示
点击download,保存到/var/www/html/zabbix/conf/文件夹里,FlashFXP传到zabbix服务器上。
然后点击RETRY,通过了。
Finish,完成了。终于大功告成了。
默认账号密码
Username:admin
Password:zabbix
查看监听端口:
lsof -i:10051 #Zabbix Trapper
lsof -i:10050 #Zabbix Agent
查看运行状态:
service zabbix_agentd status
service zabbix_server status
很醒目的首页,一切正常。如果英文不好的朋友头疼的话,没关系。右上角点击profile
选择chinese(zh_cn),点击save.
开机启动项
vi /etc/rc.d/rc.local
添加
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start
查看日志:
tail -f /tmp/zabbix_server.log
httpd 配置文件
vi /etc/httpd/conf/httpd.conf
针对 zabbix报错
http://blog.csdn.net/jiusifeng/article/details/7413377
selinux 日志:
tail -f /var/log/audit/audit.log
get测试连接
ln -s /usr/local/zabbix/bin/zabbix_get /usr/bin/
zabbix_get -s 192.168.64.131 -k system.uname
zabbix中文显示乱码
http://blog.chinaunix.net/uid-11121450-id-3296646.html
=================================================================================================================================================================
被监控主机:
====================================================================================================================================================================
Zabbix需要在被监控的host上安装agent,在zabbix官网上下载相应平台的agent包到各被监控端,
按如下方式在被监控上运行agent。(注:官网上下载的agent包里没有运行agentd所必须的配置文件,
可以从zabbix server上拷贝一份zabbix_agentd.conf,这个conf文件是所有平台都通用的)
相关目录
sbin/zabbix_agent
sbin/zabbix_agentd
bin/zabbix_get
bin/zabbix_sender
conf/zabbix_agent.conf
conf/zabbix_agentd.conf
conf/zabbix_agentd/userparameter_examples.conf
conf/zabbix_agentd/userparameter_mysql.conf
#useradd zabbix
取一份server上的zabbix_agnetd.conf到本地,然后按说明修改,一般我们只需修改如下5个参数:
Hostname=本机名
Server=Zabbix Server IP
LogFile=本机agentd日志保存文件
SourceIP=本机IP
ListenPort=10050
serveractive=serverip
懒得进入文本编辑
sed -i 's/^Hostname=.*$/Hostname=10.50.12.31/g' /usr/local/zabbix/conf/zabbix_agentd.conf
sed -i 's/^Server=.*$/Server=10.50.12.39/g' /usr/local/zabbix/conf/zabbix_agentd.conf
sed -i 's/^serveractive=.*$/serveractive=10.50.12.39/g' /usr/local/zabbix/conf/zabbix_agentd.conf
agent启动
#ln -s /usr/local/zabbix/conf/zabbix_agentd.conf /usr/local/etc/
# scp root@10.50.12.39:/etc/init.d/zabbix_agentd /etc/init.d/zabbix_agentd
# chmod +x /etc/init.d/zabbix_agentd
#chkconfig zabbix_agentd on
# chkconfig --list |grep zabbix
# /etc/init.d/zabbix_agentd start
==========================================================================================================================
Zatree for zabbix 2.0.x 安装
===========================================================================================================================
1:下载文件
git clone https://github.com/spide4k/zatree.git zatree
2:复制相关文件
假如zabbix web目录位置在/var/www/zabbix,定义zabbix目录
ZABBIX_PATH=/var/www/zabbix
复制相关文件和目录
cp -rf zatree/zabbix-2.0.x $ZABBIX_PATH/zatree
cd $ZABBIX_PATH/zatree/addfile
cp class.cchart_zabbix.php class.cgraphdraw_zabbix.php class.cimagetexttable_zabbix.php $ZABBIX_PATH/include/classes/
cp zabbix.php zabbix_chart.php $ZABBIX_PATH/
cp CItemValue.php $ZABBIX_PATH/api/classes/
3:支持web interface,修改配置文件
vi $ZABBIX_PATH/zatree/zabbix_config.php
'user'=>'xxx', //web登陆的用户名
'passowrd'=>'xxx', //web登陆的密码
4:导航增加Zatree入口,修改menu.inc.php,main.js
vi $ZABBIX_PATH/include/menu.inc.php
添加285行到294行内容
285 'zatree'=>array(
286 'label' => _('Zatree'),
287 'user_type' => USER_TYPE_ZABBIX_USER,
288 'default_page_id' => 0,
289 'force_disable_all_nodes' => true,
290 'pages' =>array(
291 array('url' => 'zabbix.php','label' => _('Zatree'),)
292 )
293
294 ),
295
296 'login' => array(
297 'label' => _('Login'),
298 'user_type' => 0,
299 'default_page_id' => 0,
vi $ZABBIX_PATH/js/main.js
替换106行
menus: {'empty': 0, 'view': 0, 'cm': 0, 'reports': 0, 'config': 0, 'admin': 0, 'zatree':0},
6:增加封装的api类
vi $ZABBIX_PATH/include/classes/api/API.php
在74行下添加75行'itemvalue'=>'CItemValue',
74 'usermedia' => 'CUserMedia',
75 'itemvalue'=>'CItemValue',
76 'webcheck' => 'CWebCheck'
77 );
7:登陆zabbix,在导航里可以看到一个Zatree的菜单,使用方法是傻瓜的
8: 如果你的主机名都是ip,并且向排序显示,解决方法: 编辑zabbix_ajax.php
43行代码注释44打开,不支持ip排序,43行代码打开44行注释,支持ip排序
43 $new_list[ip2long($each_host->host)]=$each_host;
44 //$new_list[] = $each_host;
交流
==================================
QQ讨论群:216490997
常见问题
==================================
1:如何排错?
可以打开php的显示错误,看看什么原因
vi /etc/php.ini
display_errors = On
重启web server,然后监控web日志
2:Fatal error: Call to undefined function json_encode() in /var/www/html/zabbix/zatree/ZabbixApiAbstract.class.php on line 220
需要php encode支持
yum install php-pecl-json
如果上面这个方法不行,找不到php-pecl-json,试试下面这个方法
yum install php-pear
pecl install json
echo "extension=json.so" > /etc/php.d/json.ini
3:如果右侧显示一行2个图,说明你分辨率不够,叫老板给你换个机器,或者修改graph.php文件这行的width值
181 <img src="<?php echo $small_graph; ?>" width="357" height="211" style="float:left;padding-top:4px;padding-left:4px;" /> </a>
4:如果想在小图里显示时间段,编辑文件include/classes/class.cchart_zabbix.php,打开2363行
2363 // $this->drawDate();
5:报以下错误
Warning: array_key_exists() expects parameter 2 to be array, null given in zatree/ZabbixApiAbstract.class.php on line 255
Notice: Trying to get property of non-object in zatree/ZabbixApiAbstract.class.php on line 262
Warning: Invalid argument supplied for foreach() in zatree/graph.php online 130
内存溢出,修改php.ini调整大小为XXX
memory_limit = XXXM
6:是否支持搜索多个关键字?
支持,关键字用逗号分隔
7:搜索选项的差值是什么意思?
在一段时间里,最大值减去最小值得到一个结果,然后用这个结果排序,这个选项对一段时间内的突发增长查看非常有用
8: 解决分组只显示一个ip的问题,因为我们单位的主机名都写的是ip,你们的主机名是字符串,所以就显示不出来了
解决方法:
编辑zabbix_ajax.php,注释以下几行,并且保证画圈的变量名一致
![image](https://raw.github.com/spide4k/zatree/master/zabbix-2.2.x/screenshots/3.jpg)
技术支持
==================================
http://weibo.com/spider4k
http://weibo.com/chinahanna
http://weibo.com/678236656
小额捐款
==================================
如果你觉得zatree插件对你有帮助, <a href="http://me.alipay.com/spider4k">点击这里</a>可以对作者进行小额捐款
祝玩的愉快
=====================================================================================================================================================================
Items 解释
https://www.zabbix.com/documentation/2.0/manual/config/items/itemtypes/zabbix_agent