mirror of
https://github.com/netdata/netdata.git
synced 2025-04-10 08:07:34 +00:00
docker install: support for Proxmox vms/containers name resolution (#16193)
This commit is contained in:
parent
8f17bbc159
commit
3a3ce98db4
2 changed files with 33 additions and 8 deletions
|
@ -620,21 +620,19 @@ if [ -z "${NAME}" ]; then
|
|||
# libvirtd / qemu virtual machines
|
||||
NAME="qemu_$(echo "${CGROUP}" | sed 's/^machine_//; s/\.libvirt-qemu$//; s/-/_/;')"
|
||||
|
||||
elif [[ ${CGROUP} =~ qemu.slice_([0-9]+).scope && -d /etc/pve ]]; then
|
||||
elif [[ ${CGROUP} =~ qemu.slice_([0-9]+).scope && -d "${NETDATA_HOST_PREFIX}/etc/pve" ]]; then
|
||||
# Proxmox VMs
|
||||
|
||||
FILENAME="/etc/pve/qemu-server/${BASH_REMATCH[1]}.conf"
|
||||
FILENAME="${NETDATA_HOST_PREFIX}/etc/pve/qemu-server/${BASH_REMATCH[1]}.conf"
|
||||
if [[ -f $FILENAME && -r $FILENAME ]]; then
|
||||
NAME="qemu_$(grep -e '^name: ' "/etc/pve/qemu-server/${BASH_REMATCH[1]}.conf" | head -1 | sed -rn 's|\s*name\s*:\s*(.*)?$|\1|p')"
|
||||
NAME="qemu_$(grep -e '^name: ' "${FILENAME}" | head -1 | sed -rn 's|\s*name\s*:\s*(.*)?$|\1|p')"
|
||||
else
|
||||
error "proxmox config file missing ${FILENAME} or netdata does not have read access. Please ensure netdata is a member of www-data group."
|
||||
fi
|
||||
elif [[ ${CGROUP} =~ lxc_([0-9]+) && -d /etc/pve ]]; then
|
||||
elif [[ ${CGROUP} =~ lxc_([0-9]+) && -d "${NETDATA_HOST_PREFIX}/etc/pve" ]]; then
|
||||
# Proxmox Containers (LXC)
|
||||
|
||||
FILENAME="/etc/pve/lxc/${BASH_REMATCH[1]}.conf"
|
||||
FILENAME="${NETDATA_HOST_PREFIX}/etc/pve/lxc/${BASH_REMATCH[1]}.conf"
|
||||
if [[ -f ${FILENAME} && -r ${FILENAME} ]]; then
|
||||
NAME=$(grep -e '^hostname: ' "/etc/pve/lxc/${BASH_REMATCH[1]}.conf" | head -1 | sed -rn 's|\s*hostname\s*:\s*(.*)?$|\1|p')
|
||||
NAME=$(grep -e '^hostname: ' "${FILENAME}" | head -1 | sed -rn 's|\s*hostname\s*:\s*(.*)?$|\1|p')
|
||||
else
|
||||
error "proxmox config file missing ${FILENAME} or netdata does not have read access. Please ensure netdata is a member of www-data group."
|
||||
fi
|
||||
|
|
|
@ -46,6 +46,33 @@ if [ -n "${PGID}" ]; then
|
|||
usermod -a -G "${PGID}" "${DOCKER_USR}" || echo >&2 "Could not add netdata user to group docker with ID ${PGID}"
|
||||
fi
|
||||
|
||||
# Needed to read Proxmox VMs and (LXC) containers configuration files (name resolution + CPU and memory limits)
|
||||
function add_netdata_to_proxmox_conf_files_group() {
|
||||
group_guid="$(stat -c %g /host/etc/pve 2>/dev/null || true)"
|
||||
[ -z "${group_guid}" ] && return
|
||||
|
||||
if ! getent group "${group_guid}" >/dev/null; then
|
||||
echo "Creating proxmox-etc-pve group with GID ${group_guid}"
|
||||
if ! addgroup -g "${group_guid}" "proxmox-etc-pve"; then
|
||||
echo >&2 "Failed to add group proxmox-etc-pve with GID ${group_guid}."
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! getent group "${group_guid}" | grep -q netdata; then
|
||||
echo "Assign netdata user to group ${group_guid}"
|
||||
if ! usermod -a -G "${group_guid}" "${DOCKER_USR}"; then
|
||||
echo >&2 "Failed to add netdata user to group with GID ${group_guid}."
|
||||
return
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -d "/host/etc/pve" ]; then
|
||||
add_netdata_to_proxmox_conf_files_group || true
|
||||
fi
|
||||
|
||||
|
||||
if mountpoint -q /etc/netdata; then
|
||||
echo "Copying stock configuration to /etc/netdata"
|
||||
cp -an /etc/netdata.stock/* /etc/netdata
|
||||
|
|
Loading…
Add table
Reference in a new issue