设为首页 收藏本站
查看: 806|回复: 0

[经验分享] Install ZABBIX agent on Linux (CentOS)

[复制链接]

尚未签到

发表于 2015-11-23 14:01:01 | 显示全部楼层 |阅读模式
  

  This was tested on Centos5, but should just about work on any similar OS.


  

  1. Install the Zabbix-Agent on the Linux server that you want to monitor.
  

  [iyunv@mail]#
  [iyunv@mail]# tar -xzvf zabbix-1.6.2.tar.gz
  [iyunv@mail]# cd zabbix-1.6.2     #the version should be suit for your current software
  [iyunv@mail zabbix-1.6.2]#./configure --enable-agent --prefix=/usr/local/zabbix [iyunv@mail zabbix-1.6.2]# make install
  

  Possible errors = error: no acceptable C compiler found in $PATH
The solution depends on what has already been installed on the server. Usually ‘yum install gcc’ is all that is required.


  • yum install gcc
  • Still not working? Try ‘yum update yum’, then ‘yum remove gcc gcc.x86_64’ then ‘yum install gcc’. It should work!

  

  2. Configure the Zabbix-Agent.

  First we need to add the zabbix user.

  [iyunv@mail zabbix-1.6.2]#
  [iyunv@mail zabbix-1.6.2]# adduser zabbix
  

  Add the zabbix agent ports to your /etc/services file.
  

  [iyunv@mail zabbix-1.6.2]#
  [iyunv@mail zabbix-1.6.2]# echo ‘zabbix_agent 10050/tcp’ >> /etc/services [iyunv@mail zabbix-1.6.2]# echo ‘zabbix_trap 10051/tcp’ >> /etc/services
  [iyunv@mail zabbix-1.6.2]#
  

  Copy the sample configs to /etc/zabbix for the agentd.
  

  [iyunv@mail zabbix-1.6.2]#
  [iyunv@mail zabbix-1.6.2]# mkdir /etc/zabbix
  [iyunv@mail zabbix-1.6.2]# cp misc/conf/zabbix_agentd.conf /etc/zabbix
  [iyunv@mail zabbix-1.6.2]#
  

  Now go to /etc/zabbix/zabbix_agentd.conf, and edit:

Server=192.168.0.69[Example IP address of the Zabbix Server]Hostname=Mail_Server[Exactly the same name as our zabbix host name – See #1 above. NOTE:This name is case sensitive!]  
  Next, configure /etc/init.d/

  Note: If you are not using a redhat OS, look in zabbix-1.6.2/misc/init.d/ and choose a more appropriate directory before executing the following command.

  [iyunv@mail zabbix-1.6.2]#
  [iyunv@mail zabbix-1.6.2]# cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/zabbix_agentd
  [iyunv@mail zabbix-1.6.2]#
  

  Now go to /etc/init.d/zabbix_agentd, and edit
Just below #!/bin/sh: add these two lines, including the # hash marks.

  # chkconfig: 345 95 95 # description: Zabbix Agentd
  

  Then edit these two lines, to read as shown below:
BASEDIR=/usr/local/zabbix ZABBIX_AGENTD=$BASEDIR/sbin/zabbix_agentd [change bin to sbin]
  Configure automatic starting and stopping of services.

  [iyunv@mail zabbix-1.6.2]#
  [iyunv@mail zabbix-1.6.2]# chkconfig --level 345 zabbix_agentd on
  [iyunv@mail zabbix-1.6.2]#
  

  Next, edit /etc/hosts.allow on the Linux agent to allow the Zabbix Server IP address.


  3. Dealing with the Firewall.

  If using Webmin, you need to insert a line such as this:
If protocol is
TCP and source is <IPofZabbix-Server> and destination port is 10050
This will result in a line in iptables as follows:
ACCEPT tcp – <IPofZabbix-Server> 0.0.0.0/0 tcp dpt: 10050

  If you don’t have Webmin, you may need to ‘man iptables’ to check the commands necessary to insert that line in your iptables.

  Almost there now:

  [iyunv@mail]#
  [iyunv@mail]# /etc/init.d/zabbix_agentd start
  [iyunv@mail]#
  

  Check the zabbix_agentd log to see if all is okay!

  [iyunv@mail]# cat /tmp/zabbix_agentd.log 5392:20090202:115848 zabbix_agentd started. ZABBIX 1.6.2. 5393:20090202:115848 zabbix_agentd collector started 5394:20090202:115848 zabbix_agentd listener started 5395:20090202:115848 zabbix_agentd listener started 5396:20090202:115848 zabbix_agentd listener started 5397:20090202:115848 zabbix_agentd active check started [192.168.0.69:10051]
  Log looks ok!

  Now go back to the Zabbix Server web-interface and enable the Mail_Server(by default is zabbix_server) host. After a few moments you should be able to see data in Monitoring –> Latest data.

  Before enabling the Triggers, check Configuration –> Items and disable any item that is shown as ‘Unsupported’, and any item that you don’t need (e.g. FTP server, etc.).
  
  PS: If the zabbix server still cannot monitor the host, you should check out the outgoing IPaddr in you zabbix_server.conf.
  
  cited from: http://www.zabbix.com/wiki/howto/monitor/os/linux/agentinstallonlinux and made a little revision
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-142690-1-1.html 上篇帖子: Zabbix使用-1 下篇帖子: Zabbix 历史记录处出现问号乱码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表