You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
830 B
Bash

1 year ago
#!/usr/bin/env bash
set -euo pipefail
# We want to setcap only when the container is started with the right caps
DCGM_EXPORTER=$(readlink -f $(which dcgm-exporter))
if [ -z "$NO_SETCAP" ]; then
if setcap 'cap_sys_admin=+ep' $DCGM_EXPORTER; then
if ! $DCGM_EXPORTER -v 1>/dev/null 2>/dev/null; then
>&2 echo "Warning #2: dcgm-exporter doesn't have sufficient privileges to expose profiling metrics. To get profiling metrics with dcgm-exporter, use --cap-add SYS_ADMIN"
setcap 'cap_sys_admin=-ep' $DCGM_EXPORTER
fi
else
>&2 echo "Warning #1: dcgm-exporter doesn't have sufficient privileges to expose profiling metrics. To get profiling metrics with dcgm-exporter, use --cap-add SYS_ADMIN"
fi
fi
# Pass the command line arguments to dcgm-exporter
set -- $DCGM_EXPORTER "$@"
exec "$@"