1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

feature #2289: take out ganglia im/vmm files

This commit is contained in:
Javi Fontan 2013-08-28 15:59:35 +02:00
parent 6d1a85be20
commit 01ae1027a9
7 changed files with 0 additions and 425 deletions

View File

@ -265,7 +265,6 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/im/xen3.d \
$VAR_LOCATION/remotes/im/xen4.d \
$VAR_LOCATION/remotes/im/vmware.d \
$VAR_LOCATION/remotes/im/ganglia.d \
$VAR_LOCATION/remotes/vmm \
$VAR_LOCATION/remotes/vmm/kvm \
$VAR_LOCATION/remotes/vmm/xen3 \
@ -450,7 +449,6 @@ INSTALL_FILES=(
IM_PROBES_XEN3_FILES:$VAR_LOCATION/remotes/im/xen3.d
IM_PROBES_XEN4_FILES:$VAR_LOCATION/remotes/im/xen4.d
IM_PROBES_VMWARE_FILES:$VAR_LOCATION/remotes/im/vmware.d
IM_PROBES_GANGLIA_FILES:$VAR_LOCATION/remotes/im/ganglia.d
AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh
AUTH_X509_FILES:$VAR_LOCATION/remotes/auth/x509
AUTH_LDAP_FILES:$VAR_LOCATION/remotes/auth/ldap
@ -712,7 +710,6 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \
src/mad/ruby/DriverExecHelper.rb \
src/mad/ruby/ssh_stream.rb \
src/vnm_mad/one_vnm.rb \
src/mad/ruby/Ganglia.rb \
src/oca/ruby/deprecated/OpenNebula.rb \
src/oca/ruby/opennebula.rb \
src/sunstone/OpenNebulaVNC.rb"
@ -779,7 +776,6 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \
src/vmm_mad/remotes/kvm/reset \
src/vmm_mad/remotes/kvm/save \
src/vmm_mad/remotes/kvm/poll \
src/vmm_mad/remotes/kvm/poll_ganglia \
src/vmm_mad/remotes/kvm/attach_disk \
src/vmm_mad/remotes/kvm/detach_disk \
src/vmm_mad/remotes/kvm/attach_nic \
@ -802,7 +798,6 @@ VMM_EXEC_XEN3_SCRIPTS="src/vmm_mad/remotes/xen/cancel \
src/vmm_mad/remotes/xen/reset \
src/vmm_mad/remotes/xen/save \
src/vmm_mad/remotes/xen/poll \
src/vmm_mad/remotes/xen/poll_ganglia \
src/vmm_mad/remotes/xen/attach_disk \
src/vmm_mad/remotes/xen/detach_disk \
src/vmm_mad/remotes/xen/attach_nic \
@ -821,7 +816,6 @@ VMM_EXEC_XEN4_SCRIPTS="src/vmm_mad/remotes/xen/cancel \
src/vmm_mad/remotes/xen/reset \
src/vmm_mad/remotes/xen/save \
src/vmm_mad/remotes/xen/poll \
src/vmm_mad/remotes/xen/poll_ganglia \
src/vmm_mad/remotes/xen/attach_disk \
src/vmm_mad/remotes/xen/detach_disk \
src/vmm_mad/remotes/xen/attach_nic \
@ -881,8 +875,6 @@ IM_PROBES_XEN4_FILES="src/im_mad/remotes/xen.d/xen.rb \
IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb"
IM_PROBES_GANGLIA_FILES="src/im_mad/remotes/ganglia.d/ganglia_probe"
#-------------------------------------------------------------------------------
# Auth Manager drivers to be installed under $REMOTES_LOCATION/auth
#-------------------------------------------------------------------------------

View File

@ -1,34 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
data=STDIN.read.strip
data.each_line do |line|
next if !/^([^=]+?)=(.*)$/.match line
var_name="OPENNEBULA_#{$1}"
var_data=$2
var_type=/^\d+$/.match(var_data) ? 'uint32' : 'string'
command="gmetric -n #{var_name} -v \"#{var_data}\" -t #{var_type}"
system command
end

View File

@ -1,91 +0,0 @@
#!/usr/bin/env ruby
# Adds current directory to the library search path (make the script
# compatible with ruby 1.9.2)
$: << '.'
ONE_LOCATION=ENV["ONE_LOCATION"]
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
end
$: << RUBY_LIB_LOCATION
require 'socket'
require 'pp'
require 'rexml/document'
require 'Ganglia'
#############################
## CONFIGURATION GOES HERE ##
#############################
# host and port where to get monitoring information
GANGLIA_HOST='localhost'
GANGLIA_PORT=8649
# If this variable is set the the information will be read from that file
# otherwise it will get information from the ganglia endpoint
# defined previously
#GANGLIA_FILE='data.xml'
hypervisor=ARGV[0]
host_id=ARGV[1]
host=ARGV[2]
# Gets monitoring data from ganglia or file
begin
if defined?(GANGLIA_FILE)
ganglia=GangliaHost.new_from_file(host, GANGLIA_FILE)
else
ganglia=GangliaHost.new_from_ganglia(host, GANGLIA_HOST, GANGLIA_PORT)
end
rescue
STDERR.puts "Error reading ganglia data"
exit -1
end
data=ganglia.to_hash
# Monitoring info extraction
info=Hash.new
total_cpu=data['cpu_num'].to_i*100
info["TOTALCPU"]=total_cpu
info["CPUSPEED"]=data['cpu_speed']
info["TOTALMEMORY"]=data['mem_total']
info["USEDMEMORY"]=data['mem_total'].to_i-data['mem_free'].to_i
info["FREEMEMORY"]=data['mem_free'].to_i
free_cpu=(data['cpu_idle'].to_f/100.0) * total_cpu
info["FREECPU"]=free_cpu
info["USEDCPU"]=total_cpu - free_cpu
info["NETTX"]=data['bytes_out']
info["NETRX"]=data['bytes_in']
info["KVM_VERSION"]=data['KVM_VERSION']
info["XEN_VERSION"]=data['XEN_VERSION']
# Get opennebula metrics from ganglia
info.merge!(ganglia.get_opennebula_metrics)
# Print information
info.each do |key, value|
GangliaHost.print_info(key, value)
end
system("../../vmm/kvm/poll_ganglia #{host}")

View File

@ -1,168 +0,0 @@
# -----------------------------------------------------------------------------
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------------
require 'socket'
require 'pp'
require 'rexml/document'
require 'zlib'
begin
require 'rubygems'
require 'nokogiri'
$nokogiri_enabled=true
rescue LoadError
$nokogiri_enabled=false
end
# -----------------------------------------------------------------------------
# This class holds the parsing code of ganglia xml monitoring data
# -----------------------------------------------------------------------------
class GangliaHost
# Gets monitoring data from ganglia or file
def self.new_with_options(host, options)
begin
if options[:file]
xml=File.read(options[:file])
else
socket=TCPSocket.new(options[:host], options[:port])
xml=socket.read
socket.close
end
rescue
STDERR.puts "Error reading ganglia data"
nil
end
self.new(xml, host)
end
def self.new_from_file(host, file)
new_with_options(host, :file => file)
end
def self.new_from_ganglia(host, server, port)
new_with_options(host, :host => server, :port => port)
end
# Initializes the object with raw xml data and the host we
# want to monitor
def initialize(xml, host)
# Checks if the host was specified as an IP address to
# choose the correct xpath string
if host.match(/(\d{1,3}\.){3}\d{1,3}/)
xpath="/GANGLIA_XML/CLUSTER/HOST[@IP='#{host}']"
else
xpath="/GANGLIA_XML/CLUSTER/HOST[@NAME='#{host}']"
end
if $nokogiri_enabled
@doc=Nokogiri::XML.parse(xml)
@host=@doc.xpath(xpath)
else
@doc=REXML::Document.new(xml)
@host=@doc.root.elements[xpath]
end
end
# Gets a metric value from the host
def get_value(name)
xpath="METRIC[@NAME='#{name}']"
if $nokogiri_enabled
metric=@host.xpath(xpath).first
else
metric=@host.elements[xpath]
end
if metric
if $nokogiri_enabled
metric.attr 'VAL'
else
metric.attributes['VAL']
end
else
nil
end
end
# The same as get_value
def [](name)
get_value(name)
end
# Returns a hash with the hosts metrics
def to_hash
xpath='METRIC'
if $nokogiri_enabled
values=Hash.new
@host.xpath(xpath).each do |node|
values[node.attr('NAME')]=node.attr('VAL')
end
values
else
values=Hash.new
@host.elements.each(xpath) do |node|
values[node.attributes['NAME']]=node.attributes['VAL']
end
values
end
end
# extract opennebula related metrics (start with OPENNEBULA_) and
# return a hash
def get_opennebula_metrics
all_info=self.to_hash
one_info=Hash.new
keys=all_info.keys.select {|key| key.match(/^OPENNEBULA_.*/) }
keys.each do |key|
m=key.match(/^OPENNEBULA_(.*)$/)
name=m[1]
one_info[name]=all_info[key]
end
one_info
end
# extract base64 encoded yaml hash from OPENNEBULA_VMS_INFORMATION
# metric and return the hash with the VMs information
def get_vms_information
require 'base64'
require 'yaml'
base64_info=self['OPENNEBULA_VMS_INFORMATION']
return nil if !base64_info
info_yaml=Zlib::Inflate.inflate(Base64::decode64(base64_info))
info=YAML.load(info_yaml)
end
# Helper class method to print monitoring values
def self.print_info(name, value)
return if value.nil? or value.to_s.strip.empty?
puts "#{name}=\"#{value}\""
end
end

View File

@ -1 +0,0 @@
../poll_ganglia.rb

View File

@ -1,122 +0,0 @@
#!/usr/bin/env ruby
# -----------------------------------------------------------------------------
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------------
# Adds current directory to the library search path (make the script
# compatible with ruby 1.9.2)
$: << '.'
ONE_LOCATION=ENV["ONE_LOCATION"]
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
end
$: << RUBY_LIB_LOCATION
require 'socket'
require 'pp'
require 'rexml/document'
require 'Ganglia'
#############################
## CONFIGURATION GOES HERE ##
#############################
# host and port where to get monitoring information
GANGLIA_HOST='localhost'
GANGLIA_PORT=8649
# If this variable is set the the information will be read from that file
# otherwise it will get information from the ganglia endpoint
# defined previously
#GANGLIA_FILE='data.xml'
def info_string(dom_info)
if dom_info
info=dom_info.map do |key, value|
"#{key.to_s.upcase}=#{value}"
end.join(' ')
else
''
end
end
def vm_info(name, dom_info)
number = -1
if (name =~ /^one-\d*$/)
number = name.split('-').last
end
string="VM=[\n"
string<<" ID=\"#{number}\",\n"
string<<" DEPLOY_ID=#{name},\n"
string<<" POLL=\"#{info_string(dom_info)}\" ]"
string
end
if ARGV.length==1
host=ARGV[0]
ALL=true
else
domain=ARGV[0]
dom_id=ARGV[2]
host=ARGV[1]
ALL=false
end
# Gets monitoring data from ganglia or file
begin
if defined?(GANGLIA_FILE)
ganglia=GangliaHost.new_from_file(host, GANGLIA_FILE)
else
ganglia=GangliaHost.new_from_ganglia(host, GANGLIA_HOST, GANGLIA_PORT)
end
rescue
STDERR.puts "Error reading ganglia data"
exit -1
end
doms_info=ganglia.get_vms_information
if !ALL
dom_id=domain.split('-').last
# Unknown state when the VM is not found
if !doms_info || !(doms_info[domain] || doms_info[dom_id])
puts "STATE=d"
exit(0)
end
# Get key one-<vmid> or <vmid> key from the hash
dom_info=doms_info[domain]
dom_info=doms_info[dom_id] if !dom_info
puts info_string(dom_info)
else
puts "VM_POLL=YES"
doms_info.each do |name, data|
puts vm_info(name, data)
end
end

View File

@ -1 +0,0 @@
../poll_ganglia.rb