mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
im-collectd: read the collectd port from configuration file
This commit is contained in:
parent
6a002adbf1
commit
c72841e01c
@ -49,6 +49,16 @@ class InformationManagerDriver < OpenNebulaDriver
|
||||
|
||||
# register actions
|
||||
register_action(:MONITOR, method("action_monitor"))
|
||||
|
||||
# collectd port
|
||||
@collectd_port = 4124
|
||||
begin
|
||||
im_collectd = @config["IM_MAD"].select{|e| e.match(/collectd/)}[0]
|
||||
@collectd_port = im_collectd.match(/-p (\d+)/)[1]
|
||||
rescue
|
||||
end
|
||||
|
||||
File.open('/tmp/collectd_port.log','a'){|f| f.puts @collectd_port}
|
||||
end
|
||||
|
||||
# Execute the run_probes in the remote host
|
||||
@ -73,9 +83,8 @@ class InformationManagerDriver < OpenNebulaDriver
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Do not hard-code the port
|
||||
do_action("#{@hypervisor} #{number} 9876", number, host, :MONITOR,
|
||||
:script_name => 'run_probes', :base64 => true)
|
||||
do_action("#{@hypervisor} #{number} #{@collectd_port}", number, host,
|
||||
:MONITOR, :script_name => 'run_probes', :base64 => true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# This module provides an abstraction to generate an execution context for
|
||||
# OpenNebula Drivers. The module has been designed to be included as part
|
||||
# OpenNebula Drivers. The module has been designed to be included as part
|
||||
# of a driver and not to be used standalone.
|
||||
module DriverExecHelper
|
||||
# Action result strings for messages
|
||||
@ -27,7 +27,7 @@ module DriverExecHelper
|
||||
def self.failed?(rc_str)
|
||||
return rc_str == RESULT[:failure]
|
||||
end
|
||||
|
||||
|
||||
#Initialize module variables
|
||||
def initialize_helper(directory, options)
|
||||
@config = read_configuration
|
||||
@ -51,7 +51,7 @@ module DriverExecHelper
|
||||
|
||||
#
|
||||
# METHODS FOR COMMAND LINE & ACTION PATHS
|
||||
#
|
||||
#
|
||||
# Given the action name and the parameter returns full path of the script
|
||||
# and appends its parameters. It uses @local_actions hash to know if the
|
||||
# actions is remote or local. If the local actions has defined an special
|
||||
@ -96,7 +96,7 @@ module DriverExecHelper
|
||||
|
||||
#
|
||||
# METHODS FOR LOGS & COMMAND OUTPUT
|
||||
#
|
||||
#
|
||||
# Sends a message to the OpenNebula core through stdout
|
||||
def send_message(action="-", result=RESULT[:failure], id="-", info="-")
|
||||
@send_mutex.synchronize {
|
||||
@ -151,7 +151,7 @@ module DriverExecHelper
|
||||
}
|
||||
end
|
||||
|
||||
#This method returns the result in terms
|
||||
#This method returns the result in terms
|
||||
def get_info_from_execution(command_exe)
|
||||
if command_exe.code == 0
|
||||
result = RESULT[:success]
|
||||
@ -165,10 +165,10 @@ module DriverExecHelper
|
||||
|
||||
[result, info]
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
# Simple parser for the config file generated by OpenNebula
|
||||
#
|
||||
# Simple parser for the config file generated by OpenNebula
|
||||
def read_configuration
|
||||
one_config=nil
|
||||
|
||||
@ -192,7 +192,16 @@ module DriverExecHelper
|
||||
if m
|
||||
name=m[1].strip.upcase
|
||||
value=m[2].strip
|
||||
config[name]=value
|
||||
|
||||
if config[name]
|
||||
if config[name].instance_of? Array
|
||||
config[name] << value
|
||||
else
|
||||
config[name] = [config[name], value]
|
||||
end
|
||||
else
|
||||
config[name]=value
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
|
Loading…
x
Reference in New Issue
Block a user