Chinaunix首页 | 论坛 | 博客
  • 博客访问: 55968
  • 博文数量: 11
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 164
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-15 09:42
文章分类

全部博文(11)

文章存档

2015年(1)

2014年(10)

我的朋友

分类: Python/Ruby

2014-08-18 14:10:48

该脚本作为检查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',[])

阅读(2798) | 评论(0) | 转发(0) |
0

上一篇:salt halite

下一篇:suse安装saltstack

给主人留下些什么吧!~~