saltstack使用python api实现检查zabbix-agent安装情况

2860阅读 0评论2014-08-18 yyf1986
分类:Python/Ruby

该脚本作为检查zabbix-agnet的安装情况,通过salt自带python api实现。

点击(此处)折叠或打开

  1. #!/usr/bin/python
  2. import salt.client


  3. class Run():
  4.     def __init__(self):
  5.         pass
  6.     def run(self):
  7.         local = salt.client.LocalClient()
  8.         ##针对于所有机器
  9.         ret = local.cmd('*','cmd.run',["cd /etc/init.d;ls -l |grep zabbix-agent |wc -l"])
  10.         ##针对于组abc,需要有参数expr_form='nodegroup'
  11.         #ret = local.cmd('abc','cmd.run',["cd /etc/init.d;ls -l |grep zabbix-agent |wc -l"],expr_form='nodegroup')
  12.         for key,value in ret.items():
  13.             if int(value) == 0:
  14.                 ##打印出没有安装的ip
  15.                 print key
  16. r = Run()
  17. r.run()
其他的一些操作,都类似,比如:
ret = local.cmd('*','test.ping',[])

上一篇:salt halite
下一篇:suse安装saltstack