Shell script to install Zabbix agent automatically

Source: Internet
Author: User

#!/bin/bash

#install the Zabbix Agent

#Create by Shiyong

ID Zabbix &>/dev/null | | Useradd-s/sbin/nologin Zabbix

Mkdir/etc/zabbix/var/log/zabbix

Chown zabbix.zabbix/var/log/zabbix/

Tar zxf zabbix-2.0.12.tar.gz-c/usr/src/

cd/usr/src/zabbix-2.0.12/

./configure--prefix=/usr/local/zabbix/--sysconfdir=/etc/zabbix/--enable-agent &>/dev/null && make &>/dev/null && make install &>/dev/null

CP misc/init.d/fedora/core/zabbix_agentd/etc/init.d/

cd/etc/zabbix/

CP zabbix_agentd.conf Zabbix_agentd.conf.origin

echo "Modify the Zabbix_agentd conf file"

Sleep 1

Read-p "Input the Zabbix server IP:" IP

#使用 "" Reference variable IP

Sed-i "/server=127.0.0.1/s/server=127.0.0.1/server=127.0.0.1, $IP/"/etc/zabbix/zabbix_agentd.conf

Sed-i "/serveractive=127.0.0.1/s/serveractive=127.0.0.1/serveractive= $IP: 10051/"/etc/zabbix/zabbix_agentd.conf

Sed-i '/logfile=\/tmp\/zabbix_agentd.log/[email protected]=/tmp/[email protected]=/var/log/zabbix/[email protected ] '/etc/zabbix/zabbix_agentd.conf

Sed-i '/# unsafeuserparameters=0/s/# unsafeuserparameters=0/unsafeuserparameters=1/'/etc/zabbix/zabbix_ Agentd.conf

echo "include=/etc/zabbix/zabbix_agentd.conf.d/" >>/etc/zabbix/zabbix_agentd.conf

Ln-s/usr/local/zabbix/sbin/zabbix_agentd/usr/local/sbin/

/etc/init.d/zabbix_agentd start

Chkconfig Zabbix_agentd on

echo "Zabbix install finished"

Shell script to install Zabbix agent automatically

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.