utilities/tools/collector/debian-scripts/collect_mariadb.sh
Charles Short 87dd74faf0 debian: Create debian version of collect
Debian and Centos use the same tools but they are installed
in different places. In order for collect to work on Debian,
make sure that we are trying not use to RPMs on Debian. This
is done in the collect-patching script so that the "smart"
program is not run.

Also kdump uses the /var/lib/kdump path on Debian rather
than /var/crash on Centos.

Also checked for 'rpm -qa' usage and changed them to 'dpkg -l'.

Test Plan
PASS Build package
PASS Build and install ISO
PASS Run the collect -v -all

Story: 2009101
Task: 43732

Depends-On: https://review.opendev.org/c/starlingx/tools/+/838327

Signed-off-by: Charles Short <charles.short@windriver.com>
Change-Id: I66cf0615f8cab7fe877b6cb09d605557c9258c43
2022-04-19 10:21:23 -04:00

62 lines
1.7 KiB
Bash
Executable File

#! /bin/bash
#
# Copyright (c) 2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Gather containerized MariaDB information from active controller.
# Loads Up Utilities and Commands Variables
source /usr/local/sbin/collect_parms
source /usr/local/sbin/collect_utils
SERVICE="mariadb"
DB_DIR="${extradir}/${SERVICE}"
LOGFILE="${extradir}/${SERVICE}.info"
echo "${hostname}: MariaDB Info .....: ${LOGFILE}"
function is_service_active {
active=$(sm-query service postgres | grep "enabled-active")
if [ -z "${active}" ] ; then
return 0
else
return 1
fi
}
if [ "${nodetype}" = "controller" ] ; then
is_service_active
if [ "$?" = "0" ] ; then
exit 0
fi
# MariaDB databases
delimiter ${LOGFILE} "MariaDB databases:"
mariadb-cli --command 'show databases' >> ${LOGFILE}
# MariaDB database sizes
delimiter ${LOGFILE} "MariaDB database sizes:"
mariadb-cli --command '
SELECT table_schema AS "database",
ROUND(SUM(DATA_LENGTH + INDEX_LENGTH)/1024/1024, 3) AS "Size (MiB)",
SUM(TABLE_ROWS) AS "rowCount"
FROM information_schema.TABLES
GROUP BY table_schema' >> ${LOGFILE}
delimiter ${LOGFILE} "MariaDB database table sizes:"
mariadb-cli --command '
SELECT
table_schema AS "database", TABLE_NAME AS "table",
ROUND((DATA_LENGTH + INDEX_LENGTH)/1024/1024, 6) AS "Size (MiB)",
TABLE_ROWS AS "rowCount"
FROM information_schema.TABLES
ORDER BY table_schema, TABLE_NAME' >> ${LOGFILE}
# MariaDB dump all databases
delimiter ${LOGFILE} "Dumping MariaDB databases: ${DB_DIR}"
mkdir -p ${DB_DIR}
(cd ${DB_DIR}; mariadb-cli --dump --exclude keystone,ceilometer)
fi
exit 0