Ad Widget

Collapse

How to reference Proxy or {PROXY.NAME} in an item key ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MickeyPM
    Junior Member
    • Apr 2020
    • 13

    #1

    How to reference Proxy or {PROXY.NAME} in an item key ?

    How do we reference then Proxy or {PROXY.NAME} in an item key ?

    We have a item using the Zabbix Agent Active, and in the key we want to pass in if the host proxy value, to determine if the hosts is sending data back to the server or to a proxy.
    However it seems the Macro does not expand when used in a item key.

    Key = zbx.run[PING,{PROXY.NAME}]

    /etc/zabbix/zabbix_agent2.d/zabbix_agent2.userparams.conf
    # USER-DEFINED MONITORED PARAMETERS #
    UserParameter=zbx.run[*],/apps/zabbix/zbx-run $1 $2

    if [ "${1}" = "PING" ]
    then
    if [ "${2}" = "" ]
    then
    echo "Ping Zabbix Server"
    else
    echo "Ping Zabbix Proxy"
    fi
    fi # PING

    Last edited by MickeyPM; 19-12-2023, 10:06.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    First thing to do is look in docs, where one can use specific macro
    https://www.zabbix.com/documentation...ed_by_location
    {PROXY.NAME} → Trigger-based notifications and commands
    → Problem update notifications and commands
    → Discovery notifications and commands
    → Autoregistration notifications and commands
    → Internal notifications
    → Manual event action scripts
    Name of the proxy. Resolves to either:
    1) proxy of the Nth item in the trigger expression (in trigger-based notifications). You may use indexed macros here.
    2) proxy, which executed discovery (in discovery notifications). Use {PROXY.NAME} here, without indexing.
    3) proxy to which an active agent registered (in autoregistration notifications). Use {PROXY.NAME} here, without indexing.

    This macro may be used with a numeric index e.g. {PROXY.NAME<1-9>} to point to the first, second, third, etc. host in a trigger expression. See indexed macros.

    As you see, you cannot use this macro in item key parameters...

    Comment


    • MickeyPM
      MickeyPM commented
      Editing a comment
      I have looked and the docs and have seen the comment, which is WHY I posted the question.

      If I create an item, how can I then pass a parameter to the item to indicate that the host monitored belongs to a Proxy or the Server ?
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #3
    Create a host level user macro, fill it with appropriate value, use it. Filling probably could be done by a script during agent autoregistration.
    Or submit a request to Zabbix to create an additional macro, that would return that value... something like {HOST.PROXY} or something.

    PS. (general usability related): Please use answers or quotes and not comments, comments are hard to quote normally, for the answer to look normal..

    Comment

    Working...