Created
November 20, 2010 03:20
-
-
Save glarizza/707583 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------Server.cfg and Angelia Plugin--------- | |
bash-3.2# cat /etc/mcollective/server.cfg | |
# main config | |
topicprefix = /topic/mcollective | |
libdir = /etc/mcollective/plugins | |
logfile = /var/log/mcollective.log | |
daemonize = 1 | |
keeplogs = 1 | |
max_log_size = 10240 | |
loglevel = debug | |
identity = server | |
registerinterval = 300 | |
# connector plugin config | |
connector = stomp | |
plugin.stomp.host = testing.huronhs.com | |
plugin.stomp.port = 6163 | |
plugin.stomp.user = mcollective | |
plugin.stomp.password = marionette | |
# facts | |
factsource = yaml | |
plugin.yaml = /etc/mcollective/facts.yaml | |
# security plugin config | |
securityprovider = psk | |
plugin.psk = abcdefghjbash-3.2# | |
bash-3.2# cd /etc/mcollective/plugins/mcollective/agent/ | |
bash-3.2# ls -l | |
total 40 | |
-rw-r--r-- 1 root wheel 1253 Nov 19 22:22 angelianotify.ddl | |
-rw-r--r-- 1 root wheel 2232 Nov 19 22:14 angelianotify.rb | |
-rw-r--r-- 1 root wheel 2431 Nov 19 14:28 discovery.rb | |
-rw-r--r-- 1 root wheel 3517 Nov 19 14:28 rpcutil.ddl | |
-rw-r--r-- 1 root wheel 2489 Nov 19 14:28 rpcutil.rb | |
bash-3.2# cat angelianotify.rb | |
module MCollective | |
module Agent | |
# A SimpleRPC plugin that uses the Angelia notify system to send messages. | |
# | |
# Messages can be sent using the normal mc-rpc command: | |
# | |
# mc-rpc angelianotify sendmsg message="hello world" recipient="xmpp://[email protected]" subject="test" -v | |
# | |
# For information about Angelia see http://github.com/ripienaar/angelia | |
class Angelianotify<RPC::Agent | |
require 'angelia' | |
metadata :name => "SimpleRPC Plugin for The Angelia Nagios Notifier", | |
:description => "Agent to send messages via angelia", | |
:author => "R.I.Pienaar", | |
:license => "Apache License 2.0", | |
:version => "1.2", | |
:url => "http://mcollective-plugins.googlecode.com/", | |
:timeout => 2 | |
def startup_hook | |
@configfile = @config.pluginconf["angelia.configfile"] || "/etc/angelia/angelia.cfg" | |
end | |
action "sendmsg" do | |
validate :recipient, :shellsafe | |
validate :message, :shellsafe | |
validate :subject, :shellsafe if request.include?(:subject) | |
begin | |
angelia = Angelia::Config.new(@configfile, false) | |
if request.include?(:subject) | |
msg = Angelia::Message.new(request[:recipient], request[:message], request[:subject], "") | |
else | |
msg = Angelia::Message.new(request[:recipient], request[:message], "", "") | |
end | |
unless angelia.plugins.include?(msg.recipient.protocol.capitalize) | |
reply.fail! "Don't know how to handle protocol #{msg.recipient.protocol.capitalize}" | |
end | |
Angelia::Spool.createmsg msg | |
reply[:msg] = "Spooled message for #{request[:recipient]}" | |
rescue Exception => e | |
reply.fail! "Failed to send message: #{e}" | |
end | |
end | |
end | |
end | |
end | |
# vi:tabstop=4:expandtab:ai | |
bash-3.2# | |
-------------Angelianotify Call from Client-------------- | |
bash-3.2# mc-rpc angelianotify sendmsg message="Testing from MC" recipient="boxcar://[email protected]" subject="test" -v | |
Determining the amount of hosts matching filter for 2 seconds .... 1 | |
* [ ============================================================> ] 1 / 1 | |
server : Unknown action: sendmsg | |
---- angelianotify#sendmsg call stats ---- | |
Nodes: 1 / 1 | |
Pass / Fail: 0 / 1 | |
Start Time: Fri Nov 19 22:17:29 -0500 2010 | |
Discovery Time: 2000.74ms | |
Agent Time: 9.56ms | |
Total Time: 2010.30ms | |
bash-3.2# | |
-------------/var/log/mcollective.log--------------- | |
D, [2010-11-19T22:31:24.821793 #42136] DEBUG -- : 42136 runnerstats.rb:44:in `received': Incrementing total stat | |
D, [2010-11-19T22:31:24.821983 #42136] DEBUG -- : 42136 runnerstats.rb:33:in `validated': Incrementing validated stat | |
D, [2010-11-19T22:31:24.822141 #42136] DEBUG -- : 42136 base.rb:79:in `validate_filter?': Passing based on agent angelianotify | |
D, [2010-11-19T22:31:24.822242 #42136] DEBUG -- : 42136 base.rb:79:in `validate_filter?': Passing based on agent angelianotify | |
D, [2010-11-19T22:31:24.822335 #42136] DEBUG -- : 42136 base.rb:112:in `validate_filter?': Message passed the filter checks | |
D, [2010-11-19T22:31:24.822424 #42136] DEBUG -- : 42136 runnerstats.rb:21:in `passed': Incrementing passed stat | |
D, [2010-11-19T22:31:24.822537 #42136] DEBUG -- : 42136 runner.rb:71:in `run': Handling message for angelianotify | |
D, [2010-11-19T22:31:24.822628 #42136] DEBUG -- : 42136 agents.rb:97:in `dispatch': Dispatching a message to agent angelianotify | |
D, [2010-11-19T22:31:24.822789 #42136] DEBUG -- : 42136 pluginmanager.rb:73:in `[]': Returning plugin angelianotify_agent with class MCollective::Agent::Angelianotify | |
D, [2010-11-19T22:31:24.822928 #42136] DEBUG -- : 42136 stomp.rb:127:in `receive': Waiting for a message from Stomp | |
D, [2010-11-19T22:31:24.823178 #42136] DEBUG -- : 42136 pluginmanager.rb:73:in `[]': Returning plugin angelianotify_agent with class MCollective::Agent::Angelianotify | |
D, [2010-11-19T22:31:24.823698 #42136] DEBUG -- : 42136 psk.rb:37:in `encodereply': Encoded a message with hash f4ad2fd9c6239f08991102e10276aa51 for request 19fe928e6cd70b2adf988c06c08a5ea0 | |
D, [2010-11-19T22:31:24.823871 #42136] DEBUG -- : 42136 stomp.rb:138:in `send': Sending a message to Stomp target '/topic/mcollective.angelianotify.reply' | |
D, [2010-11-19T22:31:24.824364 #42136] DEBUG -- : 42136 runnerstats.rb:51:in `sent': Incrementing replies stat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment