Ad Widget

Collapse

Difficulty with Discovery Macro Substitutions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nwhitehead
    Junior Member
    • Jul 2012
    • 5

    #1

    Difficulty with Discovery Macro Substitutions

    Hello;

    I am attempting to implement a JMX based discovery agent. As I had some difficulty acquiring the names of the discovery rules from the server, I implemented the discovery rules using a passive agent.

    As a basic example to get started, I implemented a discovery check for the JVM's garbage collectors. However, when I return the garbage collector names, I get an error attempting to create a new discovery based item because it is not substituting the macro {#GCName} with the actual name ( e.g. PS Scavenge) and the item it attempts to create has the same item key as the item prototype.

    I switched the server log to full debug and captured the output outlined below. The template defining the discovery rule is attached. I was not sure if a regular expression was required with the macro, so I created a ".*" regex that allows anything.

    I've tried this several different ways to get this to work. Can anyone see a flaw in this setup ? Thanks in advance for your help.

    //Nicholas


    DEBUG LOG:
    10334:20120731:131300.461 In substitute_key_macros() data:'jmxdp["java.lang:type=GarbageCollector,name={#GCName }"]'
    10334:20120731:131300.461 In substitute_simple_macros() data:'java.lang:type=GarbageCollector,name={#GCNam e}'
    10334:20120731:131300.461 End substitute_simple_macros() data:'java.lang:type=GarbageCollector,name={#GCNam e}'
    10334:20120731:131300.461 End of substitute_key_macros():SUCCEED data:'jmxdp["java.lang:type=GarbageCollector,name={#GCName }"]'
    10334:20120731:131300.461 In substitute_simple_macros() data:'10050'
    10334:20120731:131300.461 In get_value() key:'jmxdp["java.lang:type=GarbageCollector,name={#GCName }"]'
    10334:20120731:131300.461 In get_value_agent() host:'mulderd' addr:'xx.xxx.xx.xx' key:'jmxdp["java.lang:type=GarbageCollector,name={#GCName }"]'
    10334:20120731:131300.462 Sending [jmxdp["java.lang:type=GarbageCollector,name={#GCName }"]
    ]
    10334:20120731:131300.466 get value from agent result: '{"data":[{"{#GCName}":"PS Scavenge"},{"{#GCName}":"PS MarkSweep"}]}'
    10334:20120731:131300.466 End of get_value():SUCCEED
    10334:20120731:131300.466 In activate_host() hostid:10097 itemid:23820 type:0
    10334:20120731:131300.466 In DBlld_process_discovery_rule() itemid:23820
    10334:20120731:131300.466 query [txnlev:0] [select hostid,key_,status,filter,error,lifetime from items where itemid=23820]
    10334:20120731:131300.467 In substitute_simple_macros() data:'30'
    10334:20120731:131300.467 query [txnlev:1] [begin;]
    10334:20120731:131300.467 query [txnlev:1] [select r.name,e.expression,e.expression_type,e.exp_delimi ter,e.case_sensitive from regexps r,expressions e where r.regexpid=e.regexpid and r.name='AllowAnything']
    10334:20120731:131300.467 DBlld_process_discovery_rule() f_macro:'{#GCName}' f_regexp:'@AllowAnything'
    10334:20120731:131300.467 In DBlld_update_items()
    10334:20120731:131300.467 query [txnlev:1] [select i.itemid,i.name,i.key_,i.type,i.value_type,i.data_ type,i.delay,i.delay_flex,i.history,i.trends,i.sta tus,i.trapper_hosts,i.units,i.multiplier,i.delta,i .formula,i.logtimefmt,i.valuemapid,i.params,i.ipmi _sensor,i.snmp_community,i.snmp_oid,i.port,i.snmpv 3_securityname,i.snmpv3_securitylevel,i.snmpv3_aut hpassphrase,i.snmpv3_privpassphrase,i.authtype,i.u sername,i.password,i.publickey,i.privatekey,i.desc ription,i.interfaceid from items i,item_discovery id where i.itemid=id.itemid and id.parent_itemid=23820]
    10334:20120731:131300.468 In DBlld_check_record() jp_row:'{"{#GCName}":"PS Scavenge"}'
    10334:20120731:131300.468 End of DBlld_check_record():SUCCEED
    10334:20120731:131300.468 In DBlld_make_item()
    10334:20120731:131300.468 In substitute_key_macros() data:'jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]'
    10334:20120731:131300.468 In substitute_discovery_macros() data:'java.lang:type=GarbageCollector,name={#GCNam e}'
    10334:20120731:131300.468 End of substitute_discovery_macros() data:'java.lang:type=GarbageCollector,name={#GCNam e}'
    10334:20120731:131300.468 End of substitute_key_macros():SUCCEED data:'jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]'
    10334:20120731:131300.468 query [txnlev:1] [select distinct i.itemid from items i,item_discovery id where i.itemid=id.itemid and id.parent_itemid=23826 and i.key_='jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]']
    10334:20120731:131300.468 query [txnlev:1] [select distinct i.itemid,id.key_,i.key_ from items i,item_discovery id where i.itemid=id.itemid and id.parent_itemid=23826]
    10334:20120731:131300.468 query [txnlev:1] [select itemid from items where hostid=10097 and key_='jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]']
    10334:20120731:131300.469 End of DBlld_make_item():FAIL
    10334:20120731:131300.469 In DBlld_check_record() jp_row:'{"{#GCName}":"PS MarkSweep"}'
    10334:20120731:131300.469 End of DBlld_check_record():SUCCEED
    10334:20120731:131300.469 In DBlld_make_item()
    10334:20120731:131300.469 In substitute_key_macros() data:'jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]'
    10334:20120731:131300.469 In substitute_discovery_macros() data:'java.lang:type=GarbageCollector,name={#GCNam e}'
    10334:20120731:131300.469 End of substitute_discovery_macros() data:'java.lang:type=GarbageCollector,name={#GCNam e}'
    10334:20120731:131300.469 End of substitute_key_macros():SUCCEED data:'jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]'
    10334:20120731:131300.469 query [txnlev:1] [select distinct i.itemid from items i,item_discovery id where i.itemid=id.itemid and id.parent_itemid=23826 and i.key_='jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]']
    10334:20120731:131300.469 query [txnlev:1] [select distinct i.itemid,id.key_,i.key_ from items i,item_discovery id where i.itemid=id.itemid and id.parent_itemid=23826]
    10334:20120731:131300.470 query [txnlev:1] [select itemid from items where hostid=10097 and key_='jmx["java.lang:type=GarbageCollector,name={#GCName}",C ollectionTime]']
    10334:20120731:131300.470 End of DBlld_make_item():FAIL
    10334:20120731:131300.470 End of DBlld_update_items()
    10334:20120731:131300.470 In DBlld_update_triggers()
    Attached Files
    Last edited by nwhitehead; 31-07-2012, 22:32. Reason: Marking a solved
  • nwhitehead
    Junior Member
    • Jul 2012
    • 5

    #2
    [SOLVED] Difficulty with Discovery Macro Substitutions

    I got it to work. The issue seems to have been as simple as the case of the macro. It needs to be in all upper case.

    {#GCName}
    : {#GCNAME}

    Comment

    • heaje
      Senior Member
      Zabbix Certified Specialist
      • Sep 2009
      • 325

      #3
      I'd be interested in seeing the script that you're using to implement this discovery if you're OK with sharing it .

      Comment

      • nwhitehead
        Junior Member
        • Jul 2012
        • 5

        #4
        JMX MBean Discovery

        Sure. It's part of a zabbix java agent called jZab, a work in progress.
        The specific class is JMXDiscoveryCommandProcessor.

        I was unable to get the zabbix server to supply the discovery checks for a given host (without using a credentialed API call) so I implemented the discovery requests using a standard Zabbix Agent/Passive Check, and the generated item prototypes are Zabbix Agent (active) while the agent records the discovery check patterns and matching results and periodically sends the results.

        I needed this primarily to implement monitoring of MBeans for which there is no reasonable way of knowing in advance what the ObjectNames are, such as JMS Destination and Data Source management interfaces in a JEE server.

        Docs are coming up, but feel free to post back if you have any questions.

        //Nicholas

        Comment

        Working...