Eli Mesika has uploaded a new change for review. Change subject: [WIP]core: Provide a wrapper script with rhevm to... ......................................................................
[WIP]core: Provide a wrapper script with rhevm to... Provide a wrapper script with rhevm to ensure all custom queries executed by GSS are logged The purpose of this script is to be a wrapper for GSS data manipulations on the database done up to now by psql. The script supports all original psql flags and records the executed SQL and its results in /var/log/ovirt-engine/engine-psql.log The scripts supports both original -c <sql command> and -f <file> Change-Id: I468f830196bd95dc013a5142f9aa0d508e687d90 BUG-Url: https://bugzilla.redhat.com/show_bug.cgi?id=957216 Signed-off-by: Eli Mesika <[email protected]> --- A backend/manager/tools/dbutils/engine-psql.sh 1 file changed, 44 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/73/16273/1 diff --git a/backend/manager/tools/dbutils/engine-psql.sh b/backend/manager/tools/dbutils/engine-psql.sh new file mode 100755 index 0000000..8c0a5ab --- /dev/null +++ b/backend/manager/tools/dbutils/engine-psql.sh @@ -0,0 +1,44 @@ +#!/bin/bash +################################################################################# +# The purpose of this script is to be a wrapper for GSS data manipulations on the +# database done up to now by psql. +# The script supports all original psql flags and records the executed SQL and its +# results in /var/log/ovirt-engine/engine-psql.log +# The scripts supports both original -c <sql command> and -f <file> +################################################################################# + +usage() { + psql_help=$(psql --help | sed "s@psql@engine-psql@g") + echo "${psql_help}" + exit 0 +} + +while getopts c:d:f:v:p:U:h:hlvX1aeELnoqsSAFHPRtTxz0wW option; do + case $option in + c) COMMAND=$OPTARG;; + f) FILE=$OPTARG;; + h) ret=0 && usage;; + \?) ret=1 && usage;; + esac +done + +LOGDIR="/var/log/ovirt-engine" +if [ ! -d "${LOGDIR}" ]; then + echo "Can not find log directory ${LOGDIR}" + exit 1 +fi +LOGFILE="${LOGDIR}/engine-psql.log" +if [[ -n "${COMMAND}" ]]; then + echo "$(date): executing command : ${COMMAND}" >> ${LOGFILE} +fi + +if [[ -n "${FILE}" ]]; then + content=$(cat ${FILE}) + echo "$(date): executing commands from file ${FILE} : ${content}" >> ${LOGFILE} +fi + +psql "${*}" &>> ${LOGFILE} +if [ $? -ne 0 ]; then + echo "$(date): Failed to execute command ${0} $*" >> ${LOGFILE} + exit 2 +fi -- To view, visit http://gerrit.ovirt.org/16273 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I468f830196bd95dc013a5142f9aa0d508e687d90 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
