#!/bin/bash
#通過命令列引數指定
if [ ! -z "$1" ];then
ip=$1
echo "手動指定ip:$ip"
else
#根據預設路由獲取ip位址
iface=`route 2>/dev/null |grep default |awk ''`
iface=$
ip=`ifconfig $iface 2>/dev/null |grep -op '(?<=inet addr:)\d*\.\d*\.\d*\.\d*'`
echo "自動獲取網絡卡$的ip為:$ip"
fi#如果兩種方式都沒獲取到ip,則退出
if [ -z "$ip" ];then
echo 'ip位址為空,程式退出'
exit
fiyum install -y zabbix-agent-3.0.1-1.el7.x86_64.rpm
if [ -e /etc/zabbix/zabbix_agentd.conf ];then
echo
echo "##########begin modify zabbix_agentd.conf##########"
sed -i 's/^server=127.0.0.1/server=10*.4*.12*.34*/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^serveractive=127.0.0.1/serveractive=10*.4*.12*.34*:21222/g' /etc/zabbix/zabbix_agentd.conf
sed -i "s/hostname=zabbix server/hostname=$/g" /etc/zabbix/zabbix_agentd.conf
sed -i '/listenport=10050$/a\listenport=21224' /etc/zabbix/zabbix_agentd.conf
sed -i "/listenip=0.0.0.0$/a\listenip=$" /etc/zabbix/zabbix_agentd.conf
sed -i '/timeout=3$/a\timeout=30' /etc/zabbix/zabbix_agentd.conf
grep -v '^#' /etc/zabbix/zabbix_agentd.conf |grep -v '^$'
echo "##########end modify zabbix_agentd.conf##########"
echo
else
echo
echo "##########zabbix_agentd.conf is not exit##########"
echo
exit 2
fiif [ -d /etc/zabbix/zabbix_agentd.d ];then
cp -r weifeng.conf /etc/zabbix/zabbix_agentd.d
else
echo "##########/etc/zabbix/zabbix_agentd.d is not exist##########"
echo
exit 3
fiecho "##########begin move scripts to /etc/zabbix/scripts##########"
if [ -d /etc/zabbix/scripts ];then
cp -r scripts/* /etc/zabbix/scripts
chmod +x /etc/zabbix/scripts/*
else
mkdir /etc/zabbix/scripts
cp -r scripts/* /etc/zabbix/scripts
chmod +x /etc/zabbix/scripts/*
fiecho "##########end move scripts to /etc/zabbix/scripts##########"
echo
echo "##########begin modify /etc/sudoers##########"
sed -i 's/\(defaults.*requiretty\)/#\1/g' /etc/sudoers
echo '...'
sed -i 's/!visiblepw/visiblepw/g' /etc/sudoers
echo '...'
echo 'zabbix all=(all) nopasswd:/etc/zabbix/scripts/*' >> /etc/sudoers
echo '...'
echo "##########end modify /etc/sudoers##########"
echo
systemctl enable zabbix-agent.service
systemctl restart zabbix-agent.service
zabbix客戶端一鍵安裝指令碼
bin bash 通過命令列引數指定 if z 1 then ip 1 echo 手動指定ip ip else 根據預設路由獲取ip位址 iface route 2 dev null grep default awk iface ip ifconfig iface 2 dev null grep o...
rsync客戶端一鍵安裝rsync指令碼 原始碼
read p 請依次輸入原始碼rsync的url 例如 ftp rsync src rsync 3.0.7 url dz bm yum remove y rsync dev null cd root tar xf bm.tar.gz cd root bm make make install echo...
Zabbix一鍵安裝指令碼
以下指令碼僅適用於centos8 mysql httpd zabbix4.4 對於其他組合僅供參考,可根據zabbix官網提供資訊作相應修改 bin bash zabbix install.sh zabbix一鍵安裝指令碼 安裝前準備if f etc yum.repos.d zabbix.repo ...