Zabbix Agent自动安装脚本

假设在Zabbix Server的站点目录为/var/www/zabbix  ,IP为192.168.1.254:

mkdir -p /var/www/zabbix/zabbix_agentd/32
mkdir -p /var/www/zabbix/zabbix_agentd/64

mkdir -p /var/www/zabbix/zabbix_agentd/conf

将对应版本的zabbix_agentd和conf文件复制到相应目录。

配置/etc/httpd/conf/httpd.conf文件,在zabbix server相应节点添加下列内容:

<Directory "/var/www/zabbix/zabbix_agentd/">

Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

</Directory>

这样,我们就可以浏览和获取Zabbix Server的站点zabbix_agentd目录下的文件。

创建zabbixinstall.sh脚本文件,内容如下:

#!/bin/bash

netstat -ntlp|grep zabbix_agentd
testzabbix_agentd=`netstat -ntlp|grep zabbix_agentd`
if [[ "${testzabbix_agentd}" == "" ]]
then
mkdir /usr/local/zabbix/sbin/ -p
cd /usr/local/zabbix/sbin/

testuname=`uname -m`
if [[ "${testuname}" == "x86_64" ]]
then
rm -rf /usr/local/zabbix/sbin/zabbix_agentd
wget
else
rm -rf /usr/local/zabbix/sbin/zabbix_agentd
wget
#echo "/usr/local/lib" >> /etc/ld.so.conf
#ldconfig
fi

IP="`ifconfig |grep 192.168|grep "inet addr:"|awk -F "  Bcast:" '{print $1}'|awk -F "inet addr:" '{print $2}'`"
Server="192.168.1.254"
echo "Server=${Server}" > /usr/local/zabbix/sbin/zabbix_agentd.conf
echo "Hostname=${IP}" >> /usr/local/zabbix/sbin/zabbix_agentd.conf
adduser zabbix
chmod +x /usr/local/zabbix/sbin/zabbix_agentd
echo "/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/sbin/zabbix_agentd.conf" >> /etc/rc.local
/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/sbin/zabbix_agentd.conf
rm zabbixinstall.sh -rf
netstat -ntlp|grep zabbix_agentd
else
echo "zabbix_agentd already install."
rm zabbixinstall.sh -rf
exit
fi

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/e8ef00c3c65e09bf680ff5ec66d3950d.html