Ad Widget

Collapse

User Macros

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clahti
    Senior Member
    • Jan 2007
    • 126

    #1

    User Macros

    hello all:

    I am have a huge problem getting user macros to work. System macros seem to be fine. I have a template for MongoDB that I am trying to update to work with zabbix 2.2.1 originally written for zabbix 1.8x

    First Problem:
    One of the items of this template is to run an external script on the zabbix server which populates several zabbix trapper items. Here is the script usage:

    Code:
    Usage : mikoomi-mongodb-plugin.php [-D] [-h <mongoDB Server Host>] [-p <mongoDB Port>] [-u <username>] [-x <password>] -z <Zabbix_Name>
    The External check item definition looks like this:

    mikoomi-mongodb-plugin.sh["-h","{HOST.IP}","-p","{MONGODB_PORT}","-z","{HOST.HOST}"]

    this should expand to the command:
    Code:
    /usr/lib/zabbix/externalscripts/mikoomi-mongodb-plugin.sh "-h" "10.11.101.22" "-p" "27100" "-z" "sirendb2"'
    I actually get:
    Code:
    /usr/lib/zabbix/externalscripts/mikoomi-mongodb-plugin.sh "-h" "10.11.101.22" "-p" "{MONGODB_PORT}" "-z" "sirendb2"'
    So the user macro MONGODB_PORT is not getting evaluated. I applied the template to the host in question and defined the macro {$MONGODB_PORT} = 27100 but it is not getting substituted.

    Second problem:
    I hard code the port parameter in the template and now it looks like the script call is formatted properly, HOWEVER I am not getting the trapper items, so it seems the script is not actually being executed. If I run the script as the zabbix user from the command line the trapper items are updated as expected. I have the zabbix_server in debug mode and I see nothing that shows me why this would be the case. As mentioned before this template was originally written for zabbix 1.8, once I get it working for 2.2x I will happily post this for others to enjoy.

    The relevant log entries:
    Code:
      6734:20140524:190858.850 In substitute_key_macros() data:'mikoomi-mongodb-plugin.sh["-h","{HOST.IP}","-p","27100","-z","{HOST.HOST}"]'
      6734:20140524:190858.850 End of substitute_key_macros():SUCCEED data:'mikoomi-mongodb-plugin.sh["-h","10.11.101.21","-p","27100","-z","sirendb1"]'
      6734:20140524:190858.850 In get_value() key:'mikoomi-mongodb-plugin.sh["-h","{HOST.IP}","-p","27100","-z","{HOST.HOST}"]'
      6734:20140524:190858.851 In get_value_external() key:'mikoomi-mongodb-plugin.sh["-h","{HOST.IP}","-p","27100","-z","{HOST.HOST}"]'
      6734:20140524:190858.851 In zbx_popen() command:'/usr/lib/zabbix/externalscripts/mikoomi-mongodb-plugin.sh "-h" "10.11.101.21" "-p" "27100" "-z" "sirendb1"'
    /mikoomi-mongodb-plugin.php/usr/lib/zabbix/externalscripts
    Last edited by clahti; 25-05-2014, 04:16. Reason: more information
  • clahti
    Senior Member
    • Jan 2007
    • 126

    #2
    Script is executing

    I have determined that the script is executing properly, but it is still not doing user macro substitution. So problem number two has been solved. I am getting the trapper items now but I had to hard code some values I would prefer to abstract to macro substitution. Any ideas on this?

    Thanks!

    Comment

    • aib
      Senior Member
      • Jan 2014
      • 1615

      #3
      I hope you remember that User Macros has a different syntax.
      1 User macros - {$MACRO}.

      Because in your example you tried to use User Macros, described as a System Macros which doesn't exist with name {MONGODB_PORT}
      Sincerely yours,
      Aleksey

      Comment

      Working...