#!/bin/sh
# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

usage() {
    cat <<HERE >&2
Used for internal monitoring of the omd apache.
HERE
    return 1
}

[ "$(whoami)" = "root" ] && {
    su - "${OMD_SITE:?}" -c "${0}"
    exit
}

echo '<<<omd_apache:sep(124)>>>'
statsfile=~/var/log/apache/stats
[ -e "${statsfile}" ] && {
    echo "[$(whoami)]"
    cat "${statsfile}"
    : >"${statsfile}"
    # prevent next section to fail caused by a missing newline at the end of the statsfile
    echo
}
