利用的腳本有之前介紹的python腳本:
【python】用python腳本實(shí)現(xiàn)ansible的推送、下載、上傳文件功能
創(chuàng)新互聯(lián)從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目
成都做網(wǎng)站、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢想脫穎而出為使命,1280元金牛做網(wǎng)站,已為上家服務(wù),為金牛各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792
-
#
!
/
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
- # 得到操作系統(tǒng)的版本
- 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
- # 開始安裝
- #如果操作系統(tǒng)的版本是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'
-
#如果操作系統(tǒng)的版本是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'
-
#如果操作系統(tǒng)的版本是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】zabbix遠(yuǎn)程安裝部署-創(chuàng)新互聯(lián)
文章源于:
http://weahome.cn/article/cdcees.html