利用的脚本有之前介绍的python脚本:
【python】用python脚本实现ansible的推送、下载、上传文件功能
创新互联-专业网站定制、快速模板网站建设、高性价比秀山土家族苗族网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式秀山土家族苗族网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖秀山土家族苗族地区。费用合理售后完善,十年实体公司更值得信赖。
-
#
!
/
bin
/
bash
-
IP
=
$
1
-
exceptip_file
=
"/opt/python/set_host_proxy_exceptip.txt"
-
# check zabbix_agent
is
started
-
stat_z
=
`
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
c
'ps -ef|grep zabbix_agentd|grep -v sh|grep -v grep>/dev/null;echo $?'
|
g
-
rep
-
v
"#"
|
grep
-
v IP
|
grep
-
v Perform
|
grep
-
v Script`
-
echo $stat_z
-
#exit 0
-
if
[
$stat_z
-
ne 0
]
;
then
-
# 得到操作系统的版本
-
OS_VERSION
=
`
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
c
"cat /etc/redhat-release"
|
awk
-
F
'release'
'{print $2}'
|
awk
'{pr
-
int $1}'
|
awk
-
F\
.
'{print $1}'
`
-
echo $OS_VERSION
-
# 开始安装
-
#如果操作系统的版本是6
-
if
[
"$OS_VERSION"
-
eq 6
]
;
then
-
echo
"centos 6"
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
s
'/opt/python/zabbix_agentd'
'/opt'
zabbix
-
2
.
4
.
3_centos6
.
tar
.
gz
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
s
'/opt/python/zabbix_agentd'
'/opt'
install_zabbix_agent_centos6
.
sh
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
c
'sh /opt/install_zabbix_agent_centos6.sh'
-
#如果操作系统的版本是7
-
elif
[
"$OS_VERSION"
-
eq 7
]
;
then
-
echo
"centos 7"
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
s
'/opt/python/zabbix_agentd'
'/opt'
zabbix
-
2
.
4
.
3_centos7
.
tar
.
gz
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
s
'/opt/python/zabbix_agentd'
'/opt'
install_zabbix_agent_centos7
.
sh
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
c
'sh /opt/install_zabbix_agent_centos7.sh'
-
#如果操作系统的版本是5
-
elif
[
"$OS_VERSION"
-
eq 5
]
;
then
-
echo
"centos 5"
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
s
'/opt/python/zabbix_agentd'
'/opt'
zabbix
-
2
.
4
.
3_centos5
.
tar
.
gz
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
s
'/opt/python/zabbix_agentd'
'/opt'
install_zabbix_agent_centos5
.
sh
-
python
/
opt
/
python
/
paramiko
-
upload
.
py
-
H $IP
-
c
'sh /opt/install_zabbix_agent_centos5.sh'
-
fi
-
#升级zabbix的配置
-
sh
/
opt
/
python
/
yuanchen_update_zabbix_agent
.
sh $IP
-
else
-
# updata zabbix_agent config
-
sh
/
opt
/
python
/
yuanchen_update_zabbix_agent
.
sh $IP
-
fi
关于zabbix
_agent_centos不同版本的脚本请参见这里:
install_zabbix_agent_centos5.sh
install_zabbix_agent_centos6.sh
install_zabbix_agent_centos7.sh
分享题目:【Zabbix】zabbix远程安装部署
文章转载:
http://mswzjz.cn/article/gjehso.html