HA testcase containerized Compass support
[yardstick.git] / yardstick / benchmark / scenarios / availability / ha_tools / check_lxc_process_python.bash
1 #!/bin/sh
2
3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # check the status of a service
13
14 set -e
15
16 NOVA_API_PROCESS_1="nova-api-os-compute"
17 NOVA_API_PROCESS_2="nova-api-metadata"
18 NOVA_API_LXC_FILTER_1="nova_api_os_compute"
19 NOVA_API_LXC_FILTER_2="nova_api_metadata"
20
21 process_name=$1
22
23 lxc_filter=$(echo "${process_name}" | sed 's/-/_/g')
24
25 if [ "${lxc_filter}" = "glance_api" ]; then
26     lxc_filter="glance"
27 fi
28
29 if [ "${process_name}" = "nova-api" ]; then
30     container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
31     container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
32
33    echo $(($(lxc-attach -n "${container_1}" -- ps aux | grep -e "${NOVA_API_PROCESS_1}" | grep -v grep | grep -cv /bin/sh) + $(lxc-attach -n "${container_2}" -- ps aux | grep -e "${NOVA_API_PROCESS_2}" | grep -v grep | grep -cv /bin/sh)))
34 else
35     container=$(lxc-ls -1 --filter="${lxc_filter}")
36
37     if [ "${process_name}" = "haproxy" ]; then
38         ps aux | grep -e "/usr/.*/${process_name}" | grep -v grep | grep -cv /bin/sh
39     else
40         lxc-attach -n "${container}" -- ps aux | grep -e "${process_name}" | grep -v grep | grep -cv /bin/sh
41     fi
42 fi