Chinaunix首页 | 论坛 | 博客
  • 博客访问: 243542
  • 博文数量: 32
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 414
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-22 11:22
个人简介

.....

文章分类

全部博文(32)

文章存档

2016年(1)

2015年(12)

2014年(19)

我的朋友

分类: LINUX

2014-07-01 11:06:07

# 安装Fping工具

  1. scp root@110.110.110.110:/root/fping-3.4.tar.gz /opt/fping-3.4.tar.gz

  2. tar -zxvf fping-3.4.tar.gz

  3. cd /fping-3.4/

  4. ./configure

  5. Make install

# 安装扩展

  1. yum install -y net-snmp curl curl-devel net-snmp net-snmp-devel perl-DBI libxml libxml2-devel


#
创建组与用户

  1. groupadd zabbix
  2. useradd -g zabbix zabbix -s /sbin/nologin


#
进入MYSQL

  1. /opt/lampp/bin/mysql -u root -p

#创建数据库

  1. mysql>create database zabbix default charset utf8

# 创建用户

  1. mysql> GRANT ALL ON zabbix.* TO zabbix@'localhost' IDENTIFIED BY 'zabbixpass'


#
解压ZABBIX

  1. tar –zxvf zabbix.tar.gz


#导入表

  1. cd /opt/zabbix-2.2.0/database/mysql/

! 代理服务器就导入这一个表就可以。

  1. cat schema.sql |/opt/lampp/bin/mysql -uroot -p zabbix

# 编译

  1. ./configure --prefix=/usr/local/zabbix --enable-agent --enable-proxy --with-mysql=/opt/lampp/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
  2. make && make install


#
修改proxy.conf

  1. vi /usr/local/zabbix/etc/zabbix_proxy.conf
  2. ! 服务器地址
  3. Server=192.168.0.1
  4. ! 主机名
  5. Hostname=82-proxy
  6. ! 数据库名
  7. DBName=zabbix
  8. ! 数据库用户名
  9. DBUser=zabbix
  10. ! 数据库密码
  11. DBPassword=zabbixpass
  12. ! MYSQL的Socket位置
  13. DBSocket=/opt/lampp/var/mysql/mysql.sock
  14. ! 多长时间同步一次。
  15. ConfigFrequency=60
  16. ! 添加Fping
  17. FpingLocation=/usr/local/sbin/fping

# 修改agentd.conf

  1. vi /usr/local/zabbix/etc/zabbix_agentd.conf
  2. ! 本机IP地址,不是SRVER的。
  3. Server=192.168.0.2
  4. ! 本机IP地址
  5. ServerActive=192.168.0.2
  6. ! 与之前的proxy的配置文件里面的主机名保持一致
  7. Hostname=82-proxy

# 添加服务

  1. vi /etc/services
  2. zabbix-agent 10050/tcp # Zabbix Agent
  3. zabbix-agent 10050/udp # Zabbix Agent
  4. zabbix-trapper 10051/tcp # Zabbix Trapper
  5. zabbix-trapper 10051/udp # Zabbix Trapper

# 手动启动

  1. /usr/local/zabbix/sbin/zabbix_proxy -c /usr/local/zabbix/etc/zabbix_proxy.conf
  2. /usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.con


# 新建守护进程
  1. vi /etc/init.d/zabbix_proxy
  2. vi /etc/init.d/zabbix_agentd


#
给予权限与服务

  1. chmod a+x /etc/init.d/zabbix_proxy
  2. chmod a+x /etc/init.d/zabbix_agentd
  3. service zabbix_proxy start
  4. service zabbix_agentd start


# init.d
下的zabbix_Proxy脚本

点击(此处)折叠或打开

  1. #!/bin/sh
  2. # chkconfig: 345 95 95
  3. # desctription: Zabbix Proxy
  4. # Zabbix
  5. # Copyright (C) 2001-2013 Zabbix SIA
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. # Start/Stop the Zabbix agent daemon.
  21. # Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
  22. SERVICE="Zabbix proxy"
  23. DAEMON=/usr/local/zabbix/sbin/zabbix_proxy
  24. PIDFILE=/tmp/zabbix_agentd.pid
  25. BASEDIR=/usr/local/zabbix/
  26. ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_proxy
  27. case $1 in
  28.   'start')
  29.     if [ -x ${DAEMON} ]
  30.     then
  31.       $DAEMON
  32.       # Error checking here would be good...
  33.       echo "${SERVICE} started."
  34.     else
  35. echo "Can't find file ${DAEMON}."
  36.       echo "${SERVICE} NOT started."
  37.     fi
  38.   ;;
  39.   'stop')
  40.     if [ -s ${PIDFILE} ]
  41.     then
  42.       if kill `cat ${PIDFILE}` >/dev/null 2>&1
  43.       then
  44.         echo "${SERVICE} terminated."
  45.         rm -f ${PIDFILE}
  46.       fi
  47.     fi
  48.   ;;
  49.   'restart')
  50.     $0 stop
  51.     sleep 10
  52.     $0 start
  53.   ;;
  54.   *)
  55.     echo "Usage: $0 start|stop|restart"
  56.     ;;
  57. esac

# init.d下的zabbix_agentd脚本

点击(此处)折叠或打开

  1. #!/bin/sh
  2. #chkconfig: 345 95 95
  3. #description:Zabbix agent
  4. # Zabbix    
  5. # Copyright (C) 2001-2013 Zabbix SIA
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. # Start/Stop the Zabbix agent daemon.
  21. # Place a startup script in /sbin/init.d, and link to it from /sbin/rc[023].d
  22. SERVICE="Zabbix agent"
  23. DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
  24. PIDFILE=/tmp/zabbix_agentd.pid
  25. BASEDIR=/usr/local/zabbix
  26. ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_agentd
  27. case $1 in
  28.   'start')
  29.     if [ -x ${DAEMON} ]
  30.     then
  31.       $DAEMON
  32.       # Error checking here would be good...
  33.       echo "${SERVICE} started."
  34.  else
  35.       echo "Can't find file ${DAEMON}."
  36.       echo "${SERVICE} NOT started."
  37.     fi
  38.   ;;
  39.   'stop')
  40.     if [ -s ${PIDFILE} ]
  41.     then
  42.       if kill `cat ${PIDFILE}` >/dev/null 2>&1
  43.       then
  44.         echo "${SERVICE} terminated."
  45.         rm -f ${PIDFILE}
  46.       fi
  47.     fi
  48.   ;;
  49.   'restart')
  50.     $0 stop
  51.     sleep 10
  52.     $0 start
  53.   ;;
  54.   *)
  55.     echo "Usage: $0 start|stop|restart"
  56.     ;;
  57. Esac

# 服务器上添加代理

! 依次进入

! Administration->DM->Creat Proxy

! proxy name填写,我们之前在代理上设置的82-proxy

! 点击save


! 新建一个主机

!  Monitored by proxy 这个选项选择成82-proxy

! 这样就已经将新建的主机添加进代理了!









阅读(4229) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~