From f4e5c0b645d3ac5d93380c8a1d2f3aff8be2eb72 Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Fri, 21 Jun 2019 15:31:49 +0200 Subject: [PATCH] TT#65907 Write ngcpcfg PID into ngcpcfg.log file It should simplify debug when two ngcpcfg executed in parallel. Change-Id: I5fa77bfe9419c3cff798eaefbdb02f159b7b63c9 --- functions/logs | 10 +++++----- sbin/ngcpcfg | 6 +++++- scripts/commit | 8 ++++++-- scripts/decrypt | 10 +++++----- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/functions/logs b/functions/logs index 56728784..71f53dd0 100644 --- a/functions/logs +++ b/functions/logs @@ -22,29 +22,29 @@ console_output() { ## logging functions {{{ log_info() { - logger -t ngcpcfg -- "$*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*" console_output "$*\n" } # info without ending newline log_info_n() { - logger -t ngcpcfg -- "$*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*" console_output "$*" } log_warn() { - logger -t ngcpcfg -- "Warning: $*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Warning: $*" console_output "Warning: $*\n" } log_error() { - logger -t ngcpcfg -- "Error: $*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Error: $*" console_output "Error: $*\n" >&2 } log_debug() { if [ -n "${DEBUG:-}" ] ; then - logger -t ngcpcfg -- "Debug: $*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Debug: $*" console_output "DEBUG: $*\n" >&2 fi } diff --git a/sbin/ngcpcfg b/sbin/ngcpcfg index 389654b4..15e7b408 100755 --- a/sbin/ngcpcfg +++ b/sbin/ngcpcfg @@ -109,6 +109,10 @@ fi # Notify subprocesses we are running. export NGCPCFG_RUNNING=1 +export NGCPCFG_PID=$$ +logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "******************************************************" +logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Running: $0 $*" + # support for testsuite FUNCTIONS="${FUNCTIONS:-/usr/share/ngcp-ngcpcfg/functions/}" SCRIPTS="${SCRIPTS:-/usr/share/ngcp-ngcpcfg/scripts/}" @@ -125,7 +129,7 @@ if [[ "${1:-}" == "decrypt" ]] ; then # the part we need for executing ngcpcfg itself log_debug() { if [ -n "${DEBUG:-}" ] ; then - logger -t ngcpcfg -- "Debug: $*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Debug: $*" echo ; echo "DEBUG: $*" ; echo # newlines to avoid messup with cmdline output fi } diff --git a/scripts/commit b/scripts/commit index d3390aab..6cb6e88a 100755 --- a/scripts/commit +++ b/scripts/commit @@ -34,10 +34,14 @@ cd "$NGCPCTL_MAIN" if [ -z "${NO_DB_SYNC:-}" ] ; then if [ -f "${RTP_INTERFACES_CONFIG}" ] ; then log_info "Executing sync-db: " - "${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" "$RTP_INTERFACES_CONFIG" 2>&1 | sed "s/^/$timestamp_replacementchars/" 2>&1 | tee >(logger -t ngcpcfg) || true + "${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" "$RTP_INTERFACES_CONFIG" 2>&1 | \ + sed "s/^/$timestamp_replacementchars/" 2>&1 | \ + tee >(logger -t ngcpcfg --id="${NGCPCFG_PID}") || true else log_info "Executing sync-db: " - "${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" 2>&1 | sed "s/^/$timestamp_replacementchars/" 2>&1 | tee >(logger -t ngcpcfg) || true + "${HELPER}/sync-db" "$NGCPCTL_CONFIG" "$CONSTANTS_CONFIG" 2>&1 | \ + sed "s/^/$timestamp_replacementchars/" 2>&1 | \ + tee >(logger -t ngcpcfg --id="${NGCPCFG_PID}") || true fi else log_debug "no-db-sync: skipping 'sync-db'" diff --git a/scripts/decrypt b/scripts/decrypt index 97b0fdc2..e07ddb31 100755 --- a/scripts/decrypt +++ b/scripts/decrypt @@ -29,29 +29,29 @@ console_output() { } log_info() { - logger -t ngcpcfg -- "$*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*" console_output "$*\n" } # info without ending newline log_info_n() { - logger -t ngcpcfg -- "$*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "$*" console_output "$*" } log_warn() { - logger -t ngcpcfg -- "Warning: $*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Warning: $*" console_output "Warning: $*\n" } log_error() { - logger -t ngcpcfg -- "Error: $*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Error: $*" console_output "Error: $*\n" >&2 } log_debug() { if [ -n "${DEBUG:-}" ] ; then - logger -t ngcpcfg -- "Debug: $*" + logger -t ngcpcfg --id="${NGCPCFG_PID}" -- "Debug: $*" console_output "DEBUG: $*\n" fi }