Linux scripts that automatically install the Zabbix agent

Source: Internet
Author: User

To install the Zabbix Agent script:

#!/bin/bash#the zabbix path you want to installprefix= "/usr/local/zabbix"   Configfile= "/etc/zabbix/zabbix_agentd.conf" # list of comma delimited ip  addresses  (or hostnames)  of zabbix servers. Server= "ServerName" #Required  for active checks and must match hostname  as configured on the server. Hostname= ' Hostname ' function checkreturn {  if [ $1 -ne 0 ];  then     echo  "Fail: $2"      echo  "$ $"       exit  else     echo  "Pass: $2"    fi  sleep 3}[ -n  "$ (pidof -s zabbix_agentd)"  ] &&  {  echo  "Zabbix_agentd process is already running ..."    exit 1}[ -n  " $ (which zabbix_agentd 2> /dev/null) " ] && {  echo " Zabbix_agentd program has been installed ... "  exit 1}# check  selinuxif [  "'/usr/sbin/sestatus|awk  '/status/{print $3} '"  ==  "Enabled"  ];  then   checkReturn 1  "Disable selinux and then retry" firpm  -q gcc make | |  {yum install gcc makeRETVAL=$?checkReturn  $RETVAL   "Package install"}if  [ -z  "$ (id -u zabbix 2> /dev/null)"  ]then     useradd zabbix -s /sbin/nologinfiwget http://sourceforge.net/projects/zabbix/files/zabbix% 20latest%20stable/2.0.8/zabbix-2.0.8.tar.gzretval=$?checkreturn  $RETVAL   "Downloading source"   "Check mirror might be down" TAR&NBSP;XVF&NBSP;ZABBIX-2.0.8.TAR.GZCD zabbix-2.0.8./configure --prefix=${PREFIX} --enable-agentRETVAL=$?checkReturn  $RETVAL   "Configure" makeretval=$?checkreturn  $RETVAL   "Compile" Make installretval=$?checkreturn   $RETVAL   "Make install" echo  "zabbix agentd install ok....!" mkdir -p /var/log/zabbixchown zabbix.zabbix /var/log/zabbixecho  "configure  zabbix startup script.....! " Cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/chmod 755 /etc/init.d/zabbix_ agentdsed -i  ' s#basedir=/usr/local#&/zabbix# '  /etc/init.d/zabbix_agentdchkconfig -- level 345 zabbix_agentd onecho  "copy the configuration file to  zabbix installion directory.....! " if [ -d ${prefix}/etc ]     then         /bin/rm -rf ${prefix}/etc/*        cp conf/zabbix_agentd.conf ${prefix}/etcfiecho  "Add link file .....!" Ln -s /usr/local/zabbix/etc /etc/zabbixln -s /usr/local/zabbix/bin/* /usr/bin/ln  -s /usr/local/zabbix/sbin/* /usr/sbin/[ -f  "$ConfigFile"  ] &&  {sed -i  "/^server=/s#.* #Server = $Server #"   $ConfigFilesed  -i  "/^serveractive/s#.* #ServerActive = $Server: 10051# "  $ConfigFilesed  -i  '/^logfile=/s#.* #LogFile =/var/log/zabbix/zabbix _agentd.log# '   $ConfigFilesed  -i  '/unsafeuserparameters=0/aunsafeuserparameters=1 '  $ configfileif [ -n  $Hostname  ]   then    sed -i   "/^hostname=/c\hostname=${hostname}"   $ConfigFilefi}echo  '/etc/services add service  port.....! ' cat >> /etc/services << eof#zabbix agentdzabbix-agent     10050/tcp                         #Zabbix  Agentzabbix-agent    10050/udp                          #Zabbix  Agentzabbix-trapper  10051/tcp                        # zabbix trapperzabbix-trapper  10051/udp                         #Zabbix  trappereof


* Change the following to the server of your own Zabbix

Server= "ServerName"


This article is from the "Margin with Wish" blog, please be sure to keep this source http://281816327.blog.51cto.com/907015/1618036

Linux scripts that automatically install the Zabbix agent

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.