Automatic installation of Zabbix client shell scripts

Source: Internet
Author: User

General work to deploy a new server, deployment completed also add Zabbix monitoring, so install Zabbix client is very frequent, I wrote here a simple automatic installation script, not very perfect, but also can be used in peacetime.

The script may come up with some errors when it is run, you can see the error message at the time of termination, it is likely that the relevant package is missing and can be re-run according to the information installation package.

Attention to modify the contents of the configuration, according to the actual situation to make the corresponding changes, such as server and Hostname,server is the service side of the IP, according to the actual situation configuration, hostname I set here is the client's own IP, can also be modified according to their own circumstances. In the acquisition of local IP, this is not the most stringent, because there are several network cards on the machine, and the network segment of the network card may also be the same network segment, such a situation with the syntax of this script is not normally obtained, so or before running to look at the situation of their network card.



#/bin/bash# source automatically installs Zabbix client script.    #检查zabbix用户是否存在grep   "^zabbix"  /etc/passwdif [ $? -ne 0 ]then    useradd zabbix -s /sbin/nologinfi  #检测函数check () {  if[ $?  -ne 0 ] then     echo  "Error,please check again."      exit 1  fi}  #下载源码包cd  /home/zabbix[ -f  zabbix-2.2.10.tar.gz ] | |  wgethttps://sourceforge.net/projects/zabbix/files/zabbix%20latest%20stable/2.2.10/ zabbix-2.2.10.tar.gzcheck[ -d zabbix-2.2.10 ] | |  tar zxfzabbix-2.2.10.tar.gzcheck  #检查原有zabbix服务, if any, stop Ps -elf |grep zabbix|grep  -v grepif [ $? -eq 0 ]then   /etc/init.d/zabbix-agent  stop | |  /etc/init.d/zabbix-agentd stopfi  #编译安装cd  zabbix-2.2.10 ./configure --prefix=/ Usr/local/zabbix--sysconfdir=/usr/local/zabbix/conf --enable-agent check make check make  install  checkchown -r zabbix:zabbix /usr/local/zabbix  #添加到init进程/bin/cpmisc/ init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix-agentdchmod 755 /etc/init.d/ zabbix-agentdgrep  "Basedir=/usr/local/zabbix"/etc/init.d/zabbix-agentdif [ $? -ne 0  ]then   sed -r -i  ' S#basedir=/usr/local#basedir=/usr/local/zabbix#g '/etc/ init.d/zabbix-agentdficheck  #修改配置文件sed  -r -i ' s#server=127.0.0.1#server=x.x.x.x#g '/usr/local/ Zabbix/conf/zabbix_agentd.confchecksed -r -i ' s/serveractive=127.0.0.1/#ServerActive =127.0.0.1/g '/usr /local/zabbix/conf/zabbix_agentd.confcheckip= '/sbin/ifconfig |grep "addr" |grep  "192.168." | awk  ' {print $2} ' |awk -f ': '   ' {print$2} ' sed -r -i  ' s#hostname=zabbixserver# Hostname= $ip #g " /usr/local/zabbix/conf/zabbix_agentd.confcheck chkconfig --add zabbix-agentdchkconfig zabbix-agentd onservice  zabbix-agentd start netstat -lnp |grep zabbixif [ $? -eq 0  ]then   echo  "zabbix agent install have completed." Fi


This article is from the "I am not my" blog, please be sure to keep this source http://wangwq.blog.51cto.com/8711737/1843864

Automatic installation of Zabbix client shell scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.