Adding handling case where config file doesn't exist or don't have www-data permissions.
Eric Faden committed
Jun 18, 2017 at 12:39 UTC
74e3145a04b715b1cafadeb3e640fa20941e17b5
1 file changed
+8
-2
plugins.d/cgroup-name.sh
+8
-2
@@ -128,17 +128,23 @@ if [ -z "${NAME}" ]
128
then
129
130
# Proxmox VMs
131
- if [[ -f /etc/pve/qemu-server/${BASH_REMATCH[1]}.conf ]]
131
+ FILENAME="/etc/pve/qemu-server/${BASH_REMATCH[1]}.conf"
132
+ if [[ -f $FILENAME && -r $FILENAME ]]
133
then
134
NAME=$(grep -e '^name: ' /etc/pve/qemu-server/${BASH_REMATCH[1]}.conf | head -1 | sed -rn 's|\s*name\s*:\s*(.*)?$|\1|p')
135
+ else
136
+ error "proxmox config file missing $FILENAME or netdata does not have read access. Please ensure netdata is a member of www-data group."
137
fi
138
elif [[ "${CGROUP}" =~ lxc_([0-9]+) && -d /etc/pve ]]
139
then
140
141
# Proxmox Container (LXC)
139
- if [[ -f /etc/pve/lxc/${BASH_REMATCH[1]}.conf ]]
142
+ FILENAME="/etc/pve/lxc/${BASH_REMATCH[1]}.conf"
143
+ if [ -f $FILENAME && -r $FILENAME ]]
144
then
145
NAME=$(grep -e '^hostname: ' /etc/pve/lxc/${BASH_REMATCH[1]}.conf | head -1 | sed -rn 's|\s*hostname\s*:\s*(.*)?$|\1|p')
146
+ else
147
+ error "proxmox config file missing $FILENAME or netdata does not have read access. Please ensure netdata is a member of www-data group."
148
fi
149
fi
150