@@ -96,6 +96,14 @@ def batlight_running_on_instance(ip)
9696
9797 let ( :bash_functions ) do
9898 <<-EOF
99+ monitProcessName() {
100+ if pgrep ^monit-actual$ > /dev/null 2>&1; then
101+ echo "monit-actual"
102+ else
103+ echo "monit"
104+ fi
105+ }
106+
99107 waitForProcess() {
100108 local proc_name="${1}"
101109 local old_pid="${2}"
@@ -191,9 +199,10 @@ def srv_cmd
191199 # compare monit pids pre- and post kill
192200 cmd = <<-EOF
193201 #{ bash_functions }
194- old_pid="$(waitForProcess monit-actual "")"
202+ monit_proc=$(monitProcessName)
203+ old_pid="$(waitForProcess $monit_proc "")"
195204 sudo kill ${old_pid}
196- new_pid="$(waitForProcess monit-actual $old_pid)"
205+ new_pid="$(waitForProcess $monit_proc $old_pid)"
197206 if [[ "${new_pid}" = "${old_pid}" || -z "${new_pid}" ]]; then
198207 echo "FAILURE"
199208 exit 1
@@ -235,15 +244,16 @@ def srv_cmd
235244 # make sure runsvdir does not delete /etc/service/monit
236245 cmd = <<-EOF
237246 #{ bash_functions }
247+ monit_proc=$(monitProcessName)
238248 agent_pid="$(waitForProcess bosh-agent)"
239- monit_pid="$(waitForProcess monit-actual )"
249+ monit_pid="$(waitForProcess $monit_proc )"
240250
241251 _=$(waitForSymlink /etc/service/monit)
242252 link_time="$(stat --printf="%Y" /etc/service/monit)"
243253
244254 _=$(killAndAwaitProcess runsvdir)
245255 new_agent_pid="$(pgrep ^bosh-agent$)"
246- new_monit_pid="$(pgrep ^monit-actual $)"
256+ new_monit_pid="$(pgrep ^${monit_proc} $)"
247257 if [ "${new_agent_pid}" != "${agent_pid}" ] || [ -z "${new_agent_pid}" ]; then
248258 echo "FAILURE: Agent pid changed from ${agent_pid} to ${new_agent_pid}"
249259 exit 1
@@ -270,8 +280,9 @@ def srv_cmd
270280 # compare monit pids pre- and post kill
271281 cmd = <<-EOF
272282 #{ bash_functions }
283+ monit_proc=$(monitProcessName)
273284 _=$(killAndAwaitProcess runsvdir)
274- _=$(killAndAwaitProcess monit-actual )
285+ _=$(killAndAwaitProcess $monit_proc )
275286 echo "SUCCESS"
276287 EOF
277288 output = bosh_ssh ( instance_name , instance_id , cmd , deployment : deployment . name ) . output
@@ -570,10 +581,12 @@ def srv_cmd
570581
571582 # compare monit pid and process time pre and post agent restart
572583 cmd = <<-EOF
573- old_pid=$(pgrep ^monit-actual$)
584+ #{ bash_functions }
585+ monit_proc=$(monitProcessName)
586+ old_pid=$(pgrep ^${monit_proc}$)
574587 sudo sv down agent
575588 sudo sv up agent
576- new_pid=$(pgrep ^monit-actual $)
589+ new_pid=$(pgrep ^${monit_proc} $)
577590 if [ "${old_pid}" = "${new_pid}" ]; then
578591 echo "SUCCESS"
579592 else
0 commit comments