From fe2d9d2fe53168b24fe24c8b1f3b8bc3c831fac5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 11:58:31 +0200 Subject: [PATCH] Finished logwrapper in general --- tools/ccollect-logwrapper.sh | 37 ++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tools/ccollect-logwrapper.sh b/tools/ccollect-logwrapper.sh index a3cb6d8..518201e 100755 --- a/tools/ccollect-logwrapper.sh +++ b/tools/ccollect-logwrapper.sh @@ -2,11 +2,7 @@ # Nico Schottelius # written for Netstream (www.netstream.ch) # Date: Fr 8. Jun 10:30:24 CEST 2007 -# Call the log-wrapper instead of ccollect.sh and it will log -# to your selected destinations - -# not implemented -exit 0 +# Call the log-wrapper instead of ccollect.sh and it will create nice logs Analyses output produced by ccollect. @@ -15,11 +11,32 @@ Analyses output produced by ccollect. # CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} LOGCONF=$CCOLLECT_CONF/logwrapper -VERSION=0.1 -RELEASE="2007-XX-XX" -HALF_VERSION="ccollect $VERSION" -FULL_VERSION="ccollect $VERSION ($RELEASE)" +logdir="${LOGCONF}/destination" +CDATE="date +%Y%m%d-%H%M" +we="$(basenae $0)" +pid=$$ -# syslog: logger -t ccollect-logwrapper +logfile="${logdir}/$(${CDATE}).${pid}" +# use syslog normally +_echo() +{ + logger "${we}-${pid}: $@" + echo "${we}-${pid}: $@" +} + + +# exit on error +_exit_err() +{ + _echo "$@" + rm -f "${TMP}" + exit 1 +} + +# put everything into that specified file +_echo "Starting with arguments: $@" +touch "${logfile}" || _exit_err "Failed to create ${logfile}" +ccollect.sh "$@" > "${logfile}" 2>&1 +_echo "Finished."