0

im trying to monitoring the log from httpd but i have this error:

[root@localhost httpd]# tail -f /var/log/zabbix/zabbix_agentd.log
  2446:20210304:102535.671 agent #0 started [main process]
  2451:20210304:102535.683 agent #5 started [active checks #1]
  2447:20210304:102535.688 agent #1 started [collector]
  2448:20210304:102535.688 agent #2 started [listener #1]
  2449:20210304:102535.692 agent #3 started [listener #2]
  2450:20210304:102535.693 agent #4 started [listener #3]
  2451:20210304:102837.516 active check "log[/var/log/httpd/error_log]" is not supported: Cannot obtain information for file "/var/log/httpd/error_log": [13] Permission denied

How i can obtained permission

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
Jeyson Duque
  • 1
  • 1
  • 1

2 Answers2

1

error message suggests that zabbix user cannot read the mentioned file "/var/log/httpd/error_log".

Please know that only making the file readable by all does not help - you need to provide user "zabbix" a way to travese the directory structure where the file is located - i.e. permissions for directories need to be adjusted like so:

chmod o+rx /var
chmod o+rx /var/log
chmod o+rx /var/log/httpd

this provides "others" to read + execute the directory structure where the file is located.

to test you have correct permissions to read the file you can do the following:

~# whoami
root
~# sudo -u zabbix /bin/bash
/root$ whoami
zabbix
/root$ cat /var/log/nginx/some-error.log
cat: /var/log/nginx/some-error.log: Permission denied

example above shows that permissions are not correct.

Roman Spiak
  • 583
  • 3
  • 11
0

Instead of using chmod o+rx which gives too wide permission you can use ACLs if filesystem support it. For example to solve following error:

active check "vfs.fs.size[/home/git-data/repositories/+gitaly/PackObjectsCache,pused]" is not supported: Cannot obtain filesystem information: [13] Permission denied

on Debian-like os you can:

apt install acl
setfacl -m u:zabbix:x /home/git-data
setfacl -m u:zabbix:x /home/git-data/repositories
setfacl -m u:zabbix:x /home/git-data/repositories/+gitaly

To inspect problem please switch to user zabbix and test access rights:

sudo -u zabbix /bin/bash
df /home/git-data/repositories/+gitaly/PackObjectsCache
niziak
  • 31
  • 2