Ad Widget

Collapse

Trouble creating a new discovery rule

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StockerRumbles
    Junior Member
    • Aug 2017
    • 2

    #1

    Trouble creating a new discovery rule

    I've been trying to create a new discovery rule, I hit a number of errors, but now I don't get any errors but the objects aren't being created either.

    The rule is supposed to iterate through all the users in /etc/passwd, look at how many files they can open, and how many files they have open, then give those values and as a percentage. Then I want to automatically create items for each user and a graph.

    If I run the check manually I get:

    Code:
    $ /usr/local/bin/user_file_descriptors.sh                                                        
    {                                
      "data":[                       
        { "file-count.[{#root}]":"262", "file-limit.[{#root}]":"1024", "file-descriptors.[{#root}]":"25" },                                
        { "file-count.[{#daemon}]":"15", "file-limit.[{#daemon}]":"1024", "file-descriptors.[{#daemon}]":"1" },                            
        { "file-count.[{#syslog}]":"23", "file-limit.[{#syslog}]":"1024", "file-descriptors.[{#syslog}]":"2" },                            
        { "file-count.[{#messagebus}]":"25", "file-limit.[{#messagebus}]":"65536", "file-descriptors.[{#messagebus}]":"0" },               
        { "file-count.[{#nagios}]":"16", "file-limit.[{#nagios}]":"1024", "file-descriptors.[{#nagios}]":"1" },                            
        { "file-count.[{#ntpd}]":"25", "file-limit.[{#ntpd}]":"1024", "file-descriptors.[{#ntpd}]":"2" },                                  
        { "file-count.[{#stocker}]":"75", "file-limit.[{#stocker}]":"1024", "file-descriptors.[{#stocker}]":"7" },                         
        { "file-count.[{#zabbix}]":"51", "file-limit.[{#zabbix}]":"1024", "file-descriptors.[{#zabbix}]":"4" }                             
      ]                              
    }
    I have the following file /etc/zabbix/zabbix_agentd.d/userparameter_user_fd.conf

    Code:
    # mongodb stats                                                                                                                         
    UserParameter=user.discovery,/usr/local/bin/user_file_descriptors.sh
    In debug logs I see the following and I don't see any errors:

    Code:
     13505:20170814:214929.183 In substitute_key_macros() data:'user.discovery'
     13505:20170814:214929.183 End of substitute_key_macros():SUCCEED data:'user.discovery'
     13507:20170814:214929.183 __zbx_zbx_setproctitle() title:'poller #5 [got 23 values in 0.187934 sec, getting values]'
     13505:20170814:214929.183 In substitute_simple_macros() data:'10050'
     13507:20170814:214929.183 In get_values()
     13505:20170814:214929.183 In get_value() key:'user.discovery'
     13507:20170814:214929.183 In DCconfig_get_poller_items() poller_type:0
     13505:20170814:214929.183 In get_value_agent() host:'salt.sheffield.domain.com' addr:'10.10.10.24' key:'user.discovery' conn:'unencrypted'
     13507:20170814:214929.183 End of DCconfig_get_poller_items():1
     13507:20170814:214929.184 In substitute_key_macros() data:'vfs.fs.size[/,pfree]'
     13507:20170814:214929.184 End of substitute_key_macros():SUCCEED data:'vfs.fs.size[/,pfree]'
     13507:20170814:214929.184 In substitute_simple_macros() data:'10050'
     13507:20170814:214929.184 In get_value() key:'vfs.fs.size[/,pfree]'
     13507:20170814:214929.184 In get_value_agent() host:'integration-wejo-mock.dev.sheffield.domain.com' addr:'10.10.11.70' key:'vfs.fs.size[/,pfree]' conn:'unencrypted'
     13502:20170814:214929.184 In get_values()
     13502:20170814:214929.184 In DCconfig_get_poller_items() poller_type:0
     13505:20170814:214929.184 Sending [user.discovery
    My template key is: user.discovery
    I have a filter macro: {#USERNAME} matches [a-z]+
    Item prototypes:

    Linux User {#USERNAME} Open File Count
    file-count.[{#USERNAME}]

    Linux User {#USERNAME} Open File Limit
    file-limit.[{#USERNAME}]

    Linux User {#USERNAME} Open File Percent
    file-descriptors.[{#USERNAME}]

    I forgot to add, I also have this in the sudoers file so that the zabbix user can run my script:

    Code:
    zabbix ALL=(ALL) NOPASSWD: /usr/bin/lsof
    I'm no sure what I've got wrong here, but clearly I've done something wrong, and in reading the docs I haven't been able to figure out what I got wrong. Can anyone suggest how to fix this?

    Attached is a zip with the conf, bash script and xml template.
    Attached Files
    Last edited by StockerRumbles; 15-08-2017, 10:04.
Working...