Blob Blame History Raw
#!/bin/bash

# This file is part of insights-client.
#
# Any changes made to this file will be overwritten during a software update. To
# override a value in this file, see /etc/sysconfig/insights-client for variables
# that can be adjusted by users.

name=insights-client
path=/usr/bin/${name}

RANDOM_DELAY_SEC=14400
ENABLE_CHECK_RESULTS="yes"

if [ -f /etc/sysconfig/insights-client ]; then
    # shellcheck source=insights-client
    . /etc/sysconfig/insights-client
fi

DELAY=$((1 + RANDOM % RANDOM_DELAY_SEC))
/bin/sleep ${DELAY}
if [ "$(/sbin/service cgconfig status)" == "Running" ];
then
    /bin/cgcreate -g memory,cpu,blkio:insights
    /bin/cgset -r memory.limit_in_bytes=2147483648 insights
    /bin/cgset -r memory.soft_limit_in_bytes=1073741824 insights
    /bin/cgset -r memory.memsw.limit_in_bytes=2147483648 insights
    /bin/cgset -r cpu.cfs_quota_us=30000 -r cpu.cfs_period_us=100000 insights
    /bin/cgset -r blkio.weight=100 insights
    /bin/cgexec -g memory,cpu,blkio:insights /usr/bin/timeout 10m ${path} --retry 3 --quiet
    /bin/cgdelete memory,cpu,blkio:insights
    if [[ -n ${ENABLE_CHECK_RESULTS} ]]; then
        /bin/sleep 120
        ${path} --check-results
    fi
else
    /usr/bin/timeout 10m ${path} --quiet
    if [[ -n ${ENABLE_CHECK_RESULTS} ]]; then
        /bin/sleep 120
        /usr/bin/timeout 10m ${path} --check-results
    fi
fi