Ad Widget

Collapse

different result for zabbix_get and zabbix_agentd

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • frankcheong
    Member
    • Oct 2009
    • 73

    #1

    different result for zabbix_get and zabbix_agentd

    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:-

    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
    /opt/zabbix/etc/noOfOpenFiles.sh
    Code:
    #!/bin/bash
    
    /usr/sbin/lsof -nu ${1} | /usr/bin/wc -l
    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.

    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
    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:-

    Code:
    User_Alias MONITOR = zabbix
    Cmnd_Alias LSOF = /usr/sbin/lsof
    Cmnd_Alias NOOFOPENFILES = /opt/zabbix/etc/noOfOpenFiles.sh
    
    MONITOR ALL=NOPASSWD: ALL
    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.
  • frankcheong
    Member
    • Oct 2009
    • 73

    #2
    Finally I know what is happening.

    After upgrading to 1.8.12, the verbosity is much improved, I then located an error msg in the zabbix_agentd.log as below:-

    Code:
    sudo: sorry, you must have a tty to run sudo
    After searching thru the internet. I found that in sudoer, there is a line:-

    Code:
    Defaults    requiretty
    All I have to do is to remark this line

    Code:
    #Defaults    requiretty
    And then everything works perfectly.

    Comment

    Working...