This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from ripienaar/204
(#204) add a choria_util agent
- Loading branch information
Showing
9 changed files
with
200 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
metadata :name => "choria_util", | ||
:description => "Choria Utilities", | ||
:author => "R.I.Pienaar <rip@devco.net>", | ||
:license => "Apache-2.0", | ||
:version => "1.0.0", | ||
:url => "http:/choria.io", | ||
:timeout => 5 | ||
|
||
requires :mcollective => "2.9.0" | ||
|
||
action "info", :description => "Choria related information from the running Daemon and Middleware" do | ||
output :security, | ||
:description => "Security Provider plugin", | ||
:display_as => "Security Provider" | ||
|
||
output :connector, | ||
:description => "Connector plugin", | ||
:display_as => "Connector" | ||
|
||
output :client_version, | ||
:description => "Client gem version", | ||
:display_as => "Client Version" | ||
|
||
output :client_flavour, | ||
:description => "Client gem flavour", | ||
:display_as => "Client Flavour" | ||
|
||
output :client_options, | ||
:description => "Active client gem options", | ||
:display_as => "Client Options" | ||
|
||
output :connected_server, | ||
:description => "Connected middleware server", | ||
:display_as => "Connected Broker" | ||
|
||
output :client_stats, | ||
:description => "Client gem statistics", | ||
:display_as => "Client Stats" | ||
|
||
output :facter_domain, | ||
:description => "Facter domain", | ||
:display_as => "Facter Domain" | ||
|
||
output :facter_command, | ||
:description => "Command used for Facter", | ||
:display_as => "Facter" | ||
|
||
output :srv_domain, | ||
:description => "Configured SRV domain", | ||
:display_as => "SRV Domain" | ||
|
||
output :using_srv, | ||
:description => "Indicates if SRV records are considered", | ||
:display_as => "SRV Used" | ||
|
||
output :middleware_servers, | ||
:description => "Middleware Servers configured or discovered", | ||
:display_as => "Middleware" | ||
|
||
summarize do | ||
aggregate summary(:client_version) | ||
aggregate summary(:client_flavour) | ||
aggregate summary(:connected_server) | ||
aggregate summary(:srv_domain) | ||
aggregate summary(:using_srv) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module MCollective | ||
module Agent | ||
class Choria_util < RPC::Agent | ||
action "info" do | ||
connector = PluginManager["connector_plugin"] | ||
|
||
reply.fail!("Only support collectives using the Choria NATS connector") unless connector.is_a?(Connector::Nats) | ||
|
||
reply[:security] = config.securityprovider | ||
reply[:connector] = config.connector | ||
reply[:client_version] = connector.client_version | ||
reply[:client_flavour] = connector.client_flavour | ||
reply[:client_options] = stringify_keys(connector.active_options).reject {|k, _| k == "tls"} | ||
reply[:client_stats] = stringify_keys(connector.stats) | ||
reply[:facter_domain] = choria.facter_domain | ||
reply[:facter_command] = choria.facter_cmd | ||
reply[:srv_domain] = choria.srv_domain | ||
reply[:using_srv] = choria.should_use_srv? | ||
reply[:middleware_servers] = choria.middleware_servers.map {|s| s.join(":")} | ||
|
||
if connector.connected? | ||
reply[:connected_server] = "%s:%s" % [connector.connected_server.host, connector.connected_server.port] | ||
else | ||
reply[:connected_server] = "disconnected" | ||
end | ||
end | ||
|
||
def stringify_keys(hash) | ||
Hash[hash.map {|key, val| [key.to_s, val]}] | ||
end | ||
|
||
def choria | ||
@_choria ||= Util::Choria.new("production", nil, false) | ||
end | ||
end | ||
end | ||
end |
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
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
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
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
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
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