Puppet整合Foreman(五):Mcollective命令

一、测试

1 2 3 4 5 6 [root@puppetmaster ~]# mco find puppetagent.ewin.com [root@puppetmaster ~]# mco ping puppetagent.ewin.com                     time=91.49 ms —- ping statistics —- 1 replies max: 91.49 min: 91.49 avg: 91.49

windows客户端查看日志

1 2 C:\mcollective\mcollective.log         E, [2015-05-14T14:58:24.057800 #2608] ERROR — : agents.rb:71:in `rescue in loadagent’ Loading agent puppet failed: Could not create instance of plugin MCollective::Agent::Puppet: cannot load such file — puppet

分析问题是ruby加载puppet插件未成功报错,最终找到原因是mcollective主配置文件server.cfg中 libdir = C:\mcollective\plugins中只指向了mcollective的lib库,并没有找到puppet和facter的lib库导致!因此需要在libdir中添加puppet和facter的lib库路径libdir = C:\mcollective\plugins;C:\Puppet Labs\ Puppet\puppet\lib;C:\Puppet Labs\Puppet\facter\libdir

二、命令

1 2 3 4 5 6 7 8 9     mco facts      #使用fact信息显示报告     mco inventory  #来自nodes\collectives\subcollectives报告工具     mco nettest    #测试节点网络和连接     mco nrpe       #调用NRPE工具,返回监控信息     mco package    #软件包的安装卸载升级     mco plugin     #MC插件     mco puppet     #管理puppet agent程序     mco rpc        #利用RPC程序进行交互     mco service    #管理系统服务

三、过滤

1 2 3 4 5 6     mco rpc service status service=puppet -S “environment=development”  #-S可使用and or !     mco ping –with-agent service        #–with-agent 或 -A     mco ping –with-class apache        #–with-class 或 -C     mco ping -C /service/     mco ping –with-fact country=uk     #–with-fact 或 -F     mco ping -I hostname01 -I hostname02

四、管理

1、验证Agent插件

1     mco inventory puppetagent.ewin.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Inventory for puppetagent.ewin.com:    Server Statistics:                       Version: 2.8.1                    Start Time: Thu Apr 23 14:35:39 +0800 2015                   Config File: /etc/mcollective/server.cfg                   Collectives: mcollective               Main Collective: mcollective                    Process ID: 12301                Total Messages: 14       Messages Passed Filters: 14             Messages Filtered: 0              Expired Messages: 0                  Replies Sent: 13          Total Processor Time: 5.69 seconds                   System Time: 1.8 seconds    Agents:       discovery       puppet          rpcutil       service    Data Plugins:       agent           collective      fact       fstat           puppet          resource       service    Configuration Management Classes:       No classes applied    Facts:       mcollective => 1

Data Plugins下列出了puppet说明插件安装成功。

2、查看puppet状态信息

1     mco puppet status
1 2 3 4 5 6 7 8 9 10 11 12 13  * [ ==========================================================> ] 1 / 1    puppetagent.ewin.com: Currently stopped; last completed run 27 seconds ago Summary of Applying:    false = 1 Summary of Daemon Running:    stopped = 1 Summary of Enabled:    enabled = 1 Summary of Idling:    false = 1 Summary of Status:    stopped = 1 Finished processing 1 / 1 hosts in 70.91 ms

3、查看agent的puppet状态

1     mco rpc puppet status
1 2 3 4 5 6 7 8 9 10 11 * [ ==========================================================> ] 1 / 1 puppetagent.ewin.com          Applying: false    Daemon Running: false      Lock Message:           Enabled: true            Idling: false          Last Run: 1429771233           message: Currently stopped; last completed run 1 minutes 18 seconds ago    Since Last Run: 78            Status: stopped

4、强制让所有客户端运行agent

1     mco puppet runonce -v
1 2 3 4 5 6 7 8 9 10 11 Discovering hosts using the mc method for 2 second(s) …. 1  * [ ==========================================================> ] 1 / 1 puppetagent.ewin.com                    : OK     {:initiated_at=>1429771209,     :summary=>      “Started a Puppet run using the ‘puppet agent –onetime –no-daemonize –color=false –show_diff –verbose –splay –splaylimit 30’ command”} —- rpc stats —-            Nodes: 1 / 1      Pass / Fail: 1 / 0       Start Time: Thu Apr 23 14:40:13 +0800 2015   Discovery Time: 2004.83ms       Agent Time: 89.65ms       Total Time: 2094.48ms

5、强制让指定客户端运行agent

1     mco puppet runonce -I puppetagent.ewin.com -v

五、shell插件

shell插件可以远程执行客户端的shell命令,例如:

1     mco shell “cat /etc/passwd | grep puppet”

http://projects.puppetlabs.com/projects/mcollective-plugins/wiki/InstallingPlugins

更多插件在:

https://github.com/puppetlabs/mcollective-plugins

1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!10210454@qq.com
2. 本站不保证所提供所有下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有RB奖励和额外RMB收入!

磊宇堂正在使用的服务器 维护管理由磊宇云服务器提供支持

磊宇堂 » Puppet整合Foreman(五):Mcollective命令

提供最优质的资源集合

立即查看 了解详情