mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
M #-:vCenter monitor service start
This commit is contained in:
parent
085914fd6a
commit
63e515e761
@ -18,15 +18,48 @@
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
MAD_LOCATION=/usr/lib/one/mads
|
||||
VAR_LOCATION=/var/lib/one
|
||||
else
|
||||
MAD_LOCATION=$ONE_LOCATION/lib/mads
|
||||
VAR_LOCATION=$ONE_LOCATION/var
|
||||
fi
|
||||
|
||||
export DRIVER_NAME="one_im_sh_${BASH_ARGV##* }"
|
||||
|
||||
# Explicitly execute the vCenter monitor driver in the background
|
||||
# This way we don't have to wait until OpenNebula
|
||||
# issues the add_hosts commands to know about missing hosts
|
||||
#(/usr/bin/env ruby $VAR_LOCATION/remotes/im/lib/vcenter_monitor.rb &)
|
||||
#-------------------------------------------------------------------------------
|
||||
# vCenter Monitor Service startup routine
|
||||
#-------------------------------------------------------------------------------
|
||||
# Explicitly execute the vCenter monitor driver initialization and run it in the
|
||||
# background. This way we don't have to wait until OpenNebula issues the
|
||||
# add_hosts commands to know about missing hosts
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ "${BASH_ARGV##* }" = "vcenter" ]; then
|
||||
|
||||
FIFO_PATH="/tmp/vcenter_monitor.fifo"
|
||||
VMON_PATH="$VAR_LOCATION/remotes/im/lib/vcenter_monitor.rb"
|
||||
|
||||
# Sanitize previous instances
|
||||
VMON_PIDS=$(ps axuww | grep "ruby $VMON_PATH" | grep -v grep | awk '{print $2}')
|
||||
|
||||
if [ -n "$VMON_PIDS" ]; then
|
||||
kill $VMON_PIDS
|
||||
fi
|
||||
|
||||
# Create server FIFO
|
||||
rm -f $FIFO_PATH > /dev/null 2>&1
|
||||
mkfifo $FIFO_PATH
|
||||
|
||||
# Start & check vcenter monitor service
|
||||
/usr/bin/env ruby $VMON_PATH </dev/null &>/dev/null &
|
||||
|
||||
sleep 3
|
||||
|
||||
VMON_PIDS=$(ps axuww | grep "ruby $VMON_PATH" | grep -v grep | awk '{print $2}')
|
||||
|
||||
if [ -z "$VMON_PIDS" ]; then
|
||||
echo "Cannot start vcenter_monitor service"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exec $MAD_LOCATION/one_im_exec -l $*
|
||||
|
@ -71,9 +71,6 @@ class VcenterMonitorManager
|
||||
#
|
||||
#---------------------------------------------------------------------------
|
||||
def initialize
|
||||
# Sanitize previous instances
|
||||
kill_other_instances
|
||||
|
||||
@clusters = ClusterSet.new
|
||||
|
||||
@clusters.bootstrap
|
||||
@ -85,17 +82,6 @@ class VcenterMonitorManager
|
||||
Thread.new { timer }
|
||||
end
|
||||
|
||||
# Kills previous monitor instances
|
||||
def kill_other_instances
|
||||
path = File.expand_path(__FILE__)
|
||||
ps_str = "ps auxwww|grep \"ruby #{path}\"|grep -v grep|awk {'print $2'}"
|
||||
ids = `#{ps_str}`
|
||||
return if ids.nil?
|
||||
|
||||
ids = ids.split("\n").map{|pid| pid.to_i}
|
||||
ids.each{ |pid| Process.kill('KILL', pid) if pid!=Process.pid }
|
||||
end
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#
|
||||
#---------------------------------------------------------------------------
|
||||
@ -176,11 +162,6 @@ class IOThread
|
||||
|
||||
end
|
||||
|
||||
Thread.new do
|
||||
exit unless system('pgrep oned')
|
||||
sleep 5
|
||||
end
|
||||
|
||||
vcentermm = VcenterMonitorManager.new
|
||||
|
||||
io = IOThread.new(vcentermm)
|
||||
|
@ -26,29 +26,6 @@ else
|
||||
LOG=$ONE_LOCATION/var/vcenter_monitor.log
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check if vcenter_monitor is running
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ ! -p $IO_FIFO_PATH ]; then
|
||||
rm -f $IO_FIFO_PATH > /dev/null 2>&1
|
||||
mkfifo $IO_FIFO_PATH
|
||||
fi
|
||||
|
||||
pid=`ps auxx | grep vcenter_monitor.rb | grep -v grep | awk '{print $2}'`
|
||||
|
||||
if [ -z $pid ]; then
|
||||
ruby $BIN > $LOG 2>&1 &
|
||||
|
||||
sleep 3
|
||||
|
||||
pid=`ps auxx | grep vcenter_monitor.rb | grep -v grep | awk '{print $2}'`
|
||||
|
||||
if [ -z $pid ]; then
|
||||
echo "Cannot start vcenter_monitor service: `cat $LOG`"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Process Arguments
|
||||
#-------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user