lwzm
12/22/2015 - 1:29 AM

dstat_logger.sh

#!/bin/sh

PIPE=".p_dstat"
DSTAT_PID=".dstat.pid"
LOGGER_PID=".logger.pid"

if [ -e "$PIPE" ]; then
    echo "stop"

    kill $(cat "$DSTAT_PID")
    rm -f "$PIPE"

else
    echo "start"

    mkfifo "$PIPE"

    logger -p local6.debug <"$PIPE" >/dev/null 2>&1 &
    echo $! >"$LOGGER_PID"

    dstat -tcmdnp --output "$PIPE" >/dev/null 2>&1 &
    echo $! >"$DSTAT_PID"
fi

exit

redirect infos from dstat to rsyslog