I have created a userparameter to cable the no of open files for a particular user. It works perfectly when I directly issue the command in OS level as well as testing with zabbix_get -t. While it did provide different value (I also have no idea why this script produce this value). Here is the details:-
/opt/zabbix/etc/noOfOpenFiles.sh
This problem happens with zabbix_agent 1.8.9 as well as 1.8.12 running under rhel 5.3
It is really strange. Let me know if additional information is needed.
I suspect it is also a permission related problem. Coz I would obtain the value 25 (which is the result reported by zabbix_get) when run the lsof command under a non-privilege account.
So that means zabbix already have the rights to execute lsof thru sudo coz I have granted the user zabbix to run all commands thru sudoer below:-
While zabbix agent seems unable to successfully obtain the root privilege thus sudo. I know I can get around this problem thru allow root in zabbix_agentd.conf while I would like to know if there is better ways to get around with this problem.
Code:
UserParameter=NoOfOpenFiles[*],/opt/zabbix/etc/noOfOpenFiles.sh "$1"
Code:
[root@server ~# /opt/zabbix/etc/noOfOpenFiles.sh apache 300 [root@server ~]# /opt/zabbix/sbin/zabbix_agentd -t NoOfOpenFiles[apache] NoOfOpenFiles[apache] [t|295] [root@server ~]# /opt/zabbix/bin/zabbix_get -s 127.0.0.1 -p 10050 -k NoOfOpenFiles[apache] 25
Code:
#!/bin/bash
/usr/sbin/lsof -nu ${1} | /usr/bin/wc -l
It is really strange. Let me know if additional information is needed.
I suspect it is also a permission related problem. Coz I would obtain the value 25 (which is the result reported by zabbix_get) when run the lsof command under a non-privilege account.
Code:
[root@server ~] su - zabbix -c '/opt/zabbix/etc/noOfOpenFiles.sh apache' 25 [root@server ~] su zabbix [zabbix@server ~] /usr/sbin/lsof -nu apache | /usr/bin/wc -l 25 [zabbix@server ~]$ sudo /usr/sbin/lsof -nu apache | /usr/bin/wc -l 303
Code:
User_Alias MONITOR = zabbix Cmnd_Alias LSOF = /usr/sbin/lsof Cmnd_Alias NOOFOPENFILES = /opt/zabbix/etc/noOfOpenFiles.sh MONITOR ALL=NOPASSWD: ALL
Comment