Add new logs to the inventory info files
Now collect_tool implements a new param '-i' when inventory info is required to be retrieved. By default it will not be executed. The following command outputs were added: system show system host-show <hostname> system host-port-list <hostname> system host-if-list <hostname> system interface-network-list <hostname> system network-list system host-memory-list <hostname> system host-label-list <hostname> system host-disk-list <hostname> system host-stor-list <hostname> system host-lvg-list <hostname> system host-pv-list <hostname> the execution of: -system host-show -system host-port-list -system host-if-list -system interface-network-list -system host-ethernet-port-list -system host-memory-list -system host-label-list -system host-disk-list -system host-stor-list -system host-lvg-list -system host-pv-list on a simplex lab, took 12 seconds to complete Story: 2008452 Task: 41428 Signed-off-by: Jose Infanzon <jose.infanzon@windriver.com> Change-Id: I223a3ef239a00a1e9dddb86d04874f13c33163e9
This commit is contained in:
parent
438d24bbd4
commit
5c8c843438
@ -1,7 +1,7 @@
|
||||
#! /bin/bash
|
||||
########################################################################
|
||||
#
|
||||
# Copyright (c) 2014-2017 Wind River Systems, Inc.
|
||||
# Copyright (c) 2014-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -174,6 +174,8 @@ function print_help()
|
||||
echo ""
|
||||
echo "collect [--verbose | -v] ... print details during collect"
|
||||
echo ""
|
||||
echo "collect [--inventory | -i] ... collect inventory by system cli command"
|
||||
echo ""
|
||||
echo "Avoid password and security masking:"
|
||||
echo ""
|
||||
echo "collect [--skip-mask] ... skip masking of collect data"
|
||||
@ -197,6 +199,7 @@ DEBUG=false
|
||||
CLEAN=false
|
||||
VERBOSE=false
|
||||
SKIP_MASK=false
|
||||
INVENTORY=false
|
||||
|
||||
# date variables
|
||||
STARTDATE="any"
|
||||
@ -337,6 +340,10 @@ while [[ ${#} -gt 0 ]] ; do
|
||||
CLEAN=true
|
||||
;;
|
||||
|
||||
-i|--inventory)
|
||||
INVENTORY=true
|
||||
;;
|
||||
|
||||
-l|--list)
|
||||
if [[ ${#} -lt 2 ]] ; then
|
||||
print_status "Error: empty host --list" ${FAIL}
|
||||
@ -999,8 +1006,8 @@ for host in "${HOSTLIST[@]}" ; do
|
||||
log_user ${USER_LOG_MODE}
|
||||
spawn bash -i
|
||||
|
||||
set timeout 900
|
||||
send "sudo SKIP_MASK=${SKIP_MASK} ${collect_host} ${TARNAME} ${STARTDATE_OPTION} ${STARTDATE} ${STARTTIME} ${ENDDATE_OPTION} ${ENDDATE} ${ENDTIME} ${DEBUG}\n"
|
||||
set timeout 1000
|
||||
send "sudo SKIP_MASK=${SKIP_MASK} ${collect_host} ${TARNAME} ${STARTDATE_OPTION} ${STARTDATE} ${STARTTIME} ${ENDDATE_OPTION} ${ENDDATE} ${ENDTIME} ${DEBUG} ${INVENTORY}\n"
|
||||
expect {
|
||||
"assword:" {
|
||||
send "${pw}\r"
|
||||
@ -1090,8 +1097,8 @@ EOF
|
||||
send "${pw}\r"
|
||||
expect {
|
||||
"${host}:" {
|
||||
set timeout 500
|
||||
send "sudo SKIP_MASK=${SKIP_MASK} ${collect_host} ${TARNAME} ${STARTDATE_OPTION} ${STARTDATE} ${STARTTIME} ${ENDDATE_OPTION} ${ENDDATE} ${ENDTIME} ${DEBUG}\n"
|
||||
set timeout 600
|
||||
send "sudo SKIP_MASK=${SKIP_MASK} ${collect_host} ${TARNAME} ${STARTDATE_OPTION} ${STARTDATE} ${STARTTIME} ${ENDDATE_OPTION} ${ENDDATE} ${ENDTIME} ${DEBUG} ${INVENTORY}\n"
|
||||
expect {
|
||||
"assword:" {
|
||||
send "${pw}\r"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#! /bin/bash
|
||||
########################################################################
|
||||
#
|
||||
# Copyright (c) 2016-2019 Wind River Systems, Inc.
|
||||
# Copyright (c) 2016-2021 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -34,6 +34,7 @@ source_openrc_if_needed
|
||||
#
|
||||
COLLECT_NAME="${1}"
|
||||
DEBUG=${8}
|
||||
INVENTORY=${9}
|
||||
set_debug_mode ${DEBUG}
|
||||
|
||||
# Calling parms
|
||||
@ -46,7 +47,8 @@ set_debug_mode ${DEBUG}
|
||||
# 6 = end date
|
||||
# 7 = "any" (ignored - no longer used ; kept to support upgrades/downgrades)
|
||||
# 8 = debug mode
|
||||
logger -t ${COLLECT_TAG} "${0} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8}"
|
||||
# 9 = inventory
|
||||
logger -t ${COLLECT_TAG} "${0} ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9}"
|
||||
|
||||
# parse out the start data/time data if it is present
|
||||
STARTDATE_RANGE=false
|
||||
@ -85,6 +87,7 @@ VAR_LOG_INCLUDE_LIST="/tmp/${COLLECT_NAME}.lst"
|
||||
COLLECT_DIR_PCENT_CMD="df --output=pcent ${COLLECT_BASE_DIR}"
|
||||
COLLECT_DIR_USAGE_CMD="df -h ${COLLECT_BASE_DIR}"
|
||||
COLLECT_DATE="/usr/local/sbin/collect_date"
|
||||
COLLECT_SYSINV="${COLLECT_PATH}/collect_sysinv"
|
||||
|
||||
function log_space()
|
||||
{
|
||||
@ -150,7 +153,11 @@ function collect_parts()
|
||||
if [ -d ${COLLECT_PATH} ]; then
|
||||
for i in ${COLLECT_PATH}/*; do
|
||||
if [ -f $i ]; then
|
||||
$i ${COLLECT_NAME_DIR} ${EXTRA_DIR} ${hostname}
|
||||
if [ ${i} = ${COLLECT_SYSINV} ]; then
|
||||
$i ${COLLECT_NAME_DIR} ${EXTRA_DIR} ${hostname} ${INVENTORY}
|
||||
else
|
||||
$i ${COLLECT_NAME_DIR} ${EXTRA_DIR} ${hostname}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
@ -1,6 +1,6 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2014 Wind River Systems, Inc.
|
||||
# Copyright (c) 2013-2020 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@ -13,6 +13,7 @@ source /usr/local/sbin/collect_utils
|
||||
SERVICE="inventory"
|
||||
LOGFILE="${extradir}/${SERVICE}.info"
|
||||
RPMLOG="${extradir}/rpm.info"
|
||||
INVENTORY=${4}
|
||||
|
||||
function is_service_active {
|
||||
active=`sm-query service management-ip | grep "enabled-active"`
|
||||
@ -23,6 +24,74 @@ function is_service_active {
|
||||
fi
|
||||
}
|
||||
|
||||
function collect_inventory {
|
||||
is_service_active
|
||||
if [ "$?" = "0" ] ; then
|
||||
exit 0
|
||||
fi
|
||||
echo "${hostname}: System Inventory ..: ${LOGFILE}"
|
||||
|
||||
HOSTNAMES=$(system host-list --nowrap | grep '[0-9]' | cut -d '|' -f 3 | tr -d ' ')
|
||||
if [[ -z ${HOSTNAMES} || ${HOSTNAMES} != *"controller"* ]]; then
|
||||
echo "Failed to get system host-list" > $LOGFILE
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# These go into the SERVICE.info file
|
||||
delimiter ${LOGFILE} "system show"
|
||||
system show 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-list"
|
||||
system host-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system datanetwork-list"
|
||||
system datanetwork-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system service-list"
|
||||
system service-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
# delimiter ${LOGFILE} "vm-topology"
|
||||
# timeout 60 vm-topology --show all 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system network-list"
|
||||
system network-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
for host in ${HOSTNAMES}; do
|
||||
delimiter ${LOGFILE} "system host-show ${host}"
|
||||
system host-show 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-port-list ${host}"
|
||||
system host-port-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-if-list ${host}"
|
||||
system host-if-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system interface-network-list ${host}"
|
||||
system interface-network-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-ethernet-port-list ${host}"
|
||||
system host-ethernet-port-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-memory-list ${host}"
|
||||
system host-memory-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-label-list ${host}"
|
||||
system host-label-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-disk-list ${host}"
|
||||
system host-disk-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-stor-list ${host}"
|
||||
system host-stor-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-lvg-list ${host}"
|
||||
system host-lvg-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-pv-list ${host}"
|
||||
system host-pv-list ${host} 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
done
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Only Controller
|
||||
###############################################################################
|
||||
@ -33,38 +102,10 @@ if [ "$nodetype" = "controller" ] ; then
|
||||
delimiter ${RPMLOG} "rpm -qa"
|
||||
rpm -qa >> ${RPMLOG}
|
||||
|
||||
is_service_active
|
||||
if [ "$?" = "0" ] ; then
|
||||
exit 0
|
||||
if [ "${INVENTORY}" = true ] ; then
|
||||
collect_inventory
|
||||
fi
|
||||
|
||||
echo "${hostname}: System Inventory ..: ${LOGFILE}"
|
||||
|
||||
# These go into the SERVICE.info file
|
||||
delimiter ${LOGFILE} "system host-list"
|
||||
system host-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system service-list"
|
||||
system service-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "nova service-list"
|
||||
nova service-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "neutron host-list"
|
||||
neutron host-list 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-port-list controller-0"
|
||||
system host-port-list controller-0 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "system host-port-list controller-1"
|
||||
system host-port-list controller-1 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "Dump all Instances"
|
||||
nova list --fields name,status,OS-EXT-SRV-ATTR:host --all-tenant 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
delimiter ${LOGFILE} "vm-topology"
|
||||
timeout 60 vm-topology --show all 2>>${COLLECT_ERROR_LOG} >> ${LOGFILE}
|
||||
|
||||
# copy /opt/platform to extra dir while filtering out the
|
||||
# iso and lost+found dirs
|
||||
rsync -a --relative --exclude 'iso' --exclude 'lost+found' /opt/platform ${extradir}
|
||||
|
Loading…
Reference in New Issue
Block a user