Ad Widget

Collapse

Zabbix 3.4 macros for IP address in map URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • m_d_c13
    Junior Member
    • Jan 2018
    • 23

    #1

    Zabbix 3.4 macros for IP address in map URL

    Hi,
    I am using Zabbix 3.4.4 on CentOS7 and trying to get host IP via macros for URL in maps. According to zabbix manual macros like {HOST.IP} or {HOST.CONN} are not supported in map url. Here https://support.zabbix.com/browse/ZBXNEXT-155 I found patch which work on v3.2.7 but it is not for zabbix-3.4.4. Does anyone have an idea how to solve this issue
    Last edited by m_d_c13; 11-01-2018, 11:41.
  • sergio3101
    Junior Member
    • Sep 2013
    • 7

    #2
    Add this to file /usr/share/zabbix/include/maps.inc.php (in 3.2.2 String 96)

    if (preg_match("/{HOST.IP}/", $url['url'])) {
    $sql = 'SELECT ip FROM interface hi WHERE hostid='.$selement['elementid'];
    $db_host = DBfetch(DBselect($sql));
    $selement['urls'][$urlId]['url'] = str_replace('{HOST.IP}', $db_host['ip'], $url['url']);
    }


    After strings:
    // expanding host URL macros again as some hosts were added from hostgroup areas
    // and automatic expanding only happens for elements that are defined for map in db
    foreach ($selement['urls'] as $urlId => $url) {
    $selement['urls'][$urlId]['url'] = str_replace('{HOST.ID}', $selement['elementid'], $url['url']);

    Comment

    • m_d_c13
      Junior Member
      • Jan 2018
      • 23

      #3
      I tried your solution, but I get error:
      Error in query [SELECT ip FROM interface WHERE hostid=] [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1]

      Maybe this is because I upgraded Zabbix to 4.0.0.

      BTW I already put all IP addresses manualy
      Cheers

      Comment

      Working...