Ad Widget

Collapse

How to add hostname to graph name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atavius
    Junior Member
    • Apr 2015
    • 8

    #1

    How to add hostname to graph name

    Hi,
    I am trying to create template that will have graph that will contain hostname of the device in its name. I thought this would be fairly simple just like adding
    {HOST.HOST1} or {HOST.NAME} but apparently I am doing something wrong because instead of value I always end up with graph names like:
    Singal {HOST.HOST1} or Signal {HOST.NAME}

    Could someone please tell me what is the right syntax to get this working?

    Thanks
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    What version of Zabbix are using?
    {HOST.NAME} in version 2.4 even graph name is not available.


    You can use the macro {host:key.func(param)} as an alternative.

    ex.
    {{HOST.HOST}:system.hostname.last(0)}

    I tested by version 2.4.6.

    Comment

    • atavius
      Junior Member
      • Apr 2015
      • 8

      #3
      Hi Atsushi,
      I am also running 2.4.6. When I add {{HOST.HOST}:system.hostname.last(0)} I end up with graphs with name unknown.

      I managed to get it somehow working with
      SmokePing {{HOSTNAME}:sysName.last(0)}
      But the problem with this is fact that this uses hostname that Zabbix gets from device over SNMP and not the hostname that I used in Zabbix when adding it....

      Comment

      • atavius
        Junior Member
        • Apr 2015
        • 8

        #4
        If anyone interested I found little workaround to achieve this:
        You can create external script like zbxhostname.sh with line
        Code:
        echo $1
        Then create in template new item eg. Zabbix hostname set type to external check and as key set zbxhostname.sh["{HOST.NAME}"]
        Then you can call this item in template graphs with {{HOSTNAME}:zbxhostname.sh["{HOST.NAME}"].last(0)}

        I am guessing same can be applied to other right now not supported system macros in templates. And yeah I know its not exactly elegant, but it gets job done at least for now.

        Comment

        • ERd
          Junior Member
          • Apr 2018
          • 4

          #5
          (Sry for my Eng) Hi. I Have enother way to do this.
          *I create a template item and graph
          1) Create an item in template
          Name: HOST_IP
          Type: Zabbix agent
          Key: agent.hostname
          .....
          2) Create Graph (in template)

          Name{{HOST.HOST1}:agent.hostname.last()}
          ....


          "I am also running 2.4.6. When I add {{HOST.HOST}:system.hostname.last(0)} I end up with graphs with name unknown"

          I think trouble was because y dont have any item with key system.hostname.last(0). So there is no last data and it returns unknown for you.

          Comment

          • ERd
            Junior Member
            • Apr 2018
            • 4

            #6
            You shuld first create item for example " host_ip" with key: agent.hostname (in my zabbix,conf i named hosts by ip) and then y can use macro in graph names
            {{HOST.IP1}:agent.hostname.last()}

            Comment

            Working...