Collectd Exec Plugin Permission denied for script

570 Views Asked by At

I am testing the collectd Exec plugin using sample scripts before using it for my end purpose. But I am facing issues with the sample script itself.

This is the error:

collectd[4585]: exec plugin: Failed to execute ``/home/ec2-user/magic_level.sh'': Permission denied

More info:

$cat /home/ec2-user/magic_level.sh
#!/bin/bash
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
while sleep "$INTERVAL"; do
  echo "PUTVAL \"$HOSTNAME/exec-magic/gauge-magic_level\" interval=$INTERVAL N:$(date +%N)"
done

$ls -l /home/ec2-user/magic_level.sh
-rwxrwxr-x. 1 ec2-user ec2-user 244 Dec 27 16:28 /home/ec2-user/magic_level.sh

My exec plugin configuration:

<Plugin exec>
    Exec "ec2-user" "/home/ec2-user/magic_level.sh"
</Plugin>

Note: I could see that SELINUX is enabled. But I couldn't see any denials for this script in the log

Can someone please help me resolve this

1

There are 1 best solutions below

0
Kiran G On BEST ANSWER

Actually this turned out to be SELINUX blocking it.

exec read system_u:system_r:collectd_t:s0 59 file execute system_u:object_r:shell_exec_t:s0 denied 147851

Initially I didn't see the errors due to my lack of knowledge of SELINUX