From 74e3145a04b715b1cafadeb3e640fa20941e17b5 Mon Sep 17 00:00:00 2001 From: Eric Faden Date: Sun, 18 Jun 2017 12:39:42 -0400 Subject: Adding handling case where config file doesn't exist or don't have www-data permissions. --- plugins.d/cgroup-name.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'plugins.d') diff --git a/plugins.d/cgroup-name.sh b/plugins.d/cgroup-name.sh index 3d1a2fbe5a..a48b82237d 100755 --- a/plugins.d/cgroup-name.sh +++ b/plugins.d/cgroup-name.sh @@ -128,17 +128,23 @@ if [ -z "${NAME}" ] then # Proxmox VMs - if [[ -f /etc/pve/qemu-server/${BASH_REMATCH[1]}.conf ]] + FILENAME="/etc/pve/qemu-server/${BASH_REMATCH[1]}.conf" + if [[ -f $FILENAME && -r $FILENAME ]] then NAME=$(grep -e '^name: ' /etc/pve/qemu-server/${BASH_REMATCH[1]}.conf | 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 # Proxmox Container (LXC) - if [[ -f /etc/pve/lxc/${BASH_REMATCH[1]}.conf ]] + FILENAME="/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') + 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 fi -- cgit v1.2.3