metal/mtce/src/scripts/hbs-query

41 lines
967 B
Bash
Executable File

#!/bin/bash
# Copyright (c) 2013-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# This utility is primarily used by no reboot patching for process restart
#
# This script sends a json string containing the restart command
# and ${1} as the specified process name to pmond over the loopback
# interface on port 2117
#
# Linux Standard Base (LSB) Error Codes
RETVAL=0
GENERIC_ERROR=1
INVALID_ARGS=2
UNSUPPORTED_FEATURE=3
NOT_INSTALLED=5
NOT_RUNNING=7
PROTOCOL="UDP4-DATAGRAM"
ADDRESS="127.0.0.1"
socat_exec=`(which socat) 2> /dev/null`
if [ -z ${socat_exec} ] ; then
logger "Error: $0 cannot find socat exec"
exit ${NOT_INSTALLED}
fi
reqid=123
if [ "${1}" != "" ] ; then
reqid=${1}
fi
port=$(cat /etc/mtc.ini | awk '{if ($1 == "sm_server_port") { print $3; }}')
echo "{\"origin\":\"sm\", \"service\":\"heartbeat\", \"request\":\"cluster_info\", \"reqid\": $reqid }" | socat - ${PROTOCOL}:${ADDRESS}:${port}
exit ${RETVAL}