该脚本作为检查zabbix-agnet的安装情况,通过salt自带python api实现。
-
#!/usr/bin/python
-
import salt.client
-
-
-
class Run():
-
def __init__(self):
-
pass
-
def run(self):
-
local = salt.client.LocalClient()
-
##针对于所有机器
-
ret = local.cmd('*','cmd.run',["cd /etc/init.d;ls -l |grep zabbix-agent |wc -l"])
-
##针对于组abc,需要有参数expr_form='nodegroup'
-
#ret = local.cmd('abc','cmd.run',["cd /etc/init.d;ls -l |grep zabbix-agent |wc -l"],expr_form='nodegroup')
-
for key,value in ret.items():
-
if int(value) == 0:
-
##打印出没有安装的ip
-
print key
-
r = Run()
-
r.run()
其他的一些操作,都类似,比如:
ret = local.cmd('*','test.ping',[])
阅读(2828) | 评论(0) | 转发(0) |