Zatree plug-in optimization: Supports HTTP Basic authorization authentication access Zabbix API

Source: Internet
Author: User

Zatree is a plug- in for monitoring software Zabbix that provides a tree display of host group and a keyword query and data ordering in item.

Zatree Project Address https://github.com/spide4k/zatree, installation method into different versions of the directory to see the Readme.

recently encountered a problem, when the Zabbix Web side uses the HTTP Basic authentication method,the Zatree plug-in does not call the normal Zabbix API, resulting in an error.

viewing error message Methods : Open the display error of PHP,

# Vi/etc/php.ini

Display_errors = On

Restart Web server.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/41/39/wKiom1PRzTaATc6qAAChzbh5j_U802.jpg "title=" Qq20140725111646.png "alt=" Wkiom1prztaatc6qaachzbh5j_u802.jpg "/>

Click Zatree button, you will see an error message on the page.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/41/39/wKioL1PRzl-C51W6AAL4xe5OUp4649.jpg "title=" Zatree error. png "alt=" wkiol1przl-c51w6aal4xe5oup4649.jpg "/>


The workaround here is to modify the zabbix-2.2.x version of Zatree, which is also suitable for the zabbix-2.0.x version.

go to the Zatree directory and modify the following four files:

Step One , modify zabbix_config.php

Add HTTP Basic Authorization Authentication user name and password parameters. If HTTP Basic Authorization authenticationis not set, the value of Http_user and Http_password is blank.

<?php Global $zabbix _api_config, $zabbix _api_config=array (' api_url ' = ' api_jsonrpc.php ', ' http_user ' and ' = ') XXXXX ', ' http_password ' = ' xxxxx ', ' user ' = ' Admin ', ' passowrd ' = ' xxxxx ', ' graph_url ' and ' zabbix_chart.php ' ‘,);? >

Step two , modify zabbix_ajax.php , add the $url _http when HTTP authentication is available.

$url _http = dirname (dirname (' http://'. $_server[' Http_host ']. $_server["Request_uri"]));

Modified to:

if (!empty ($zabbix _api_config[' Http_user ')) &&!empty ($zabbix _api_config[' Http_password ')) {$url _ http = dirname (dirname (' http://'. Trim ($zabbix _api_config[' Http_user '). ‘:‘ . Trim ($zabbix _api_config[' Http_password '). ‘@‘ . $_server[' Http_host '.        $_server["Request_uri"]));        } else {$url _http = dirname (dirname (' http://'. $_server[' Http_host ']. $_server["Request_uri"])); }


Step three , modify graph.php line 141th, add the $url _http when HTTP authentication is available.

$url _http = dirname (dirname (' http://'. $_server[' Http_host ']. $_server["Request_uri"]));

Modified to:

if (!empty ($zabbix _api_config[' Http_user ')) &&!empty ($zabbix _api_config[' Http_password ')) {$url _ http = dirname (dirname (' http://'. Trim ($zabbix _api_config[' Http_user '). ‘:‘ . Trim ($zabbix _api_config[' Http_password '). ‘@‘ . $_server[' Http_host '.        $_server["Request_uri"]));        } else {$url _http = dirname (dirname (' http://'. $_server[' Http_host ']. $_server["Request_uri"])); }


Step four , modify big_graph.php line 88th, add the $url _http when HTTP authentication is available.

$url _http = dirname (dirname (' http://'. $_server[' Http_host ']. $_server["Request_uri"]));

Modified to:

        if  (!empty ($zabbix _ api_config[' Http_user ')  && !empty ($zabbix _api_config[' Http_password '))  {                  $url _http =  DirName (dirname ('/HTTP '  . trim ($zabbix _api_config[' http_user ')  .  ': '  . trim ($ zabbix_api_config[' Http_password ')  .  ' @ '  . $_server[' http_host '] . $_server[' Request_uri "]));        } else {                  $url _http = dirname (dirname ( ' HTTP//'  . $_server[' http_host '] . $_server["Request_uri"]));         } 

Link address:HTTPS://GITHUB.COM/SPIDE4K/ZATREE/PULL/2


This article is from the "Departure-linux Technology Blog" blog, please be sure to keep this source http://qicheng0211.blog.51cto.com/3958621/1530018

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.