mcollective as an integration layer - the scale · pdf filezabbix • distributed...
TRANSCRIPT
Zabbix
• Distributed monitoring system
• Fetches time series data - can alert on anomaly
• Uses MySQL
• Multiple data sources:
• Zabbix agent / sender
• SNMP poll / traps
• JMX
ZCollective
zcollective —zabbix-api-url \! http://localhost/api_jsonrpc.php
ZCollective
include MCollective::RPC!!mc = rpcclient("rpcutil", :debug => true)!!mc.discover.sort.each do |host|!! inventory = mc.custom_request( ! "inventory", {}, host,! { "identity" => host }! ).first!! do_some_zabbix_magic(inventory)!!end
ZCollective
def do_some_zabbix_magic(inventory)!! # If the host isn’t added to Zabbix! # Add the host using the API! # For each Puppet class on this host! # If there’s a Zabbix template by this name! # Assign that template to the host.! # end! # end! # end!! # If the host is already in Zabbix! # Make sure all templates correctly assigned! # end !!end
Code
class MCollective::Application::Sfdeploy < MCollective::Application!! def main!! action = configuration[:action]!! mc = rpcclient("sfdeploy")!! printrpc mc.send(! action,! :application => configuration[:application],! :branch => configuration[:branch],! :tag => configuration[:tag],! :groups => configuration[:groups],! :options => options! )!! printrpcstats! end
Code
module MCollective! module Agent! class Sfdeploy < RPC::Agent!! all_actions.each do |act|! action act do!! sf_deploy = config.pluginconf["sfdeploy.binary"] || "sf-deploy"! deploy_user = config.pluginconf["sfdeploy.user"]|| nil!! command = "#{sf_deploy} -a #{request[:application]} -v "! command << "-b #{request[:branch]} " if request[:branch]! command << "-t #{request[:tag]} " if request[:tag]! command << "-g #{request[:groups]} " if request[:groups]! command << act!! if deploy_user! to_run = "su #{deploy_user} -c \"#{command}\""! else! to_run = command! end