diff --git a/collectors/charts.d.plugin/charts.d.plugin.in b/collectors/charts.d.plugin/charts.d.plugin.in index 05a63875b32577..ca09f20b3f763a 100755 --- a/collectors/charts.d.plugin/charts.d.plugin.in +++ b/collectors/charts.d.plugin/charts.d.plugin.in @@ -76,6 +76,17 @@ debug() { [ $debug -eq 1 ] && log DEBUG "${@}" } +os_version() { + OS_VERSION="unknown" + OS_FILE="/etc/os-release" + info "Detecting OS version" + + [ -f ${OS_FILE} ] && OS_VERSION=$(cat ${OS_FILE} | grep '^ID=' | sed -e 's/ID=//g') + + info "Detected OS version: ${OS_VERSION}" + echo ${OS_VERSION} +} + # ----------------------------------------------------------------------------- # check a few commands @@ -281,7 +292,14 @@ run() { if [ "z${1}" = "z-t" -a "${2}" != "0" ]; then t="${2}" shift 2 - timeout ${t} "${@}" 2>"${TMP_DIR}/run.${pid}" + case "$(os_version)" in + "alpine") + timeout -t ${t} "${@}" 2>"${TMP_DIR}/run.${pid}" + ;; + *) + timeout ${t} "${@}" 2>"${TMP_DIR}/run.${pid}" + ;; + esac ret=$? else "${@}" 2>"${TMP_DIR}/run.${pid}"