1、需要将zabbix的auth写入到cookie中
1、调用zabbix登录接口:user.login, 获取接口中返回的auth
2、新增cookie写入的php文件, cd /usr/share/zabbix
vi login.php
<?php
header('Content-Type:text/html;Charset=utf-8');
require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/forms.inc.php';
require_once dirname(__FILE__).'/include/func.inc.php';
$result =getRequest('sessionid');
zbx_setcookie('zbx_sessionid', $result, 0);
$arr = array(
"auth" => $result
);
//echo $_GET['jsoncallback'] . json_encode($arr);
echo $_GET['jsoncallback'] . "(".json_encode($arr).")";
3、通过jsonp的模式调用该php文件:作用就是将登录获取auth植入到zabbix的cookie中
$.ajax({
type:"get",
url : zabbixUrl+"/login.php?sessionid=${sessionScope.user.auth}",
dataType : "jsonp",
jsonp:"jsoncallback",
success : function(data) {
/// alert("auth:"+ data.auth );
},
error : function() {
alert('fail');
}
}
);
2、修改PHP源文件,去掉header部分
一:修改 ./include/views/monitoring.sysmap.list.php
注释掉:
1、// ->addItem((new CButton('form', _('Import')))->onClick('redirect("map.import.php?rules_preset=map")'))
2、 // new CLink($map['name'], 'zabbix.php?action=map.view&sysmapid='.$map['sysmapid']),
修改为:
new CLink($map['name'], 'map.php?sysmapid='.$map['sysmapid']),
3、 // $action = new CLink(_('Properties'), 'sysmaps.php?form=update&sysmapid='.$map['sysmapid']);
// $constructor = new CLink(_('Constructor'), 'sysmap.php?sysmapid='.$map['sysmapid']);
修改为:
$action = new CLink(_('拓扑属性'), 'sysmaps.php?form=update&sysmapid='.$map['sysmapid']);
$constructor = new CLink(_('构造拓扑'), 'sysmap.php?sysmapid='.$map['sysmapid']);
二:修改这几个文件:['image.php', 'sysmaps.php', 'sysmap.php', 'map.php', 'map.import.php']
将require_once dirname(__FILE__).'/include/page_header.php';
替换成:
require_once dirname(__FILE__).'/include/page_header1.php';
三:复制php文件:
cp ./app/views/layout.htmlpage.menu.php ./app/views/layout.htmlpage.menu1.php
cp ./include/page_header.php ./include/page_header1.php
四:修改header文件
vi ./include/page_header1.php
将: $pageMenu = new CView('layout.htmlpage.menu', [
修改为:
$pageMenu = new CView('layout.htmlpage.menu1', [
五:cd /usr/share/zabbix
vi login.php
<?php
header('Content-Type:text/html;Charset=utf-8');
require_once dirname(__FILE__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/forms.inc.php';
require_once dirname(__FILE__).'/include/func.inc.php';
$result =getRequest('sessionid');
zbx_setcookie('zbx_sessionid', $result, 0);
$arr = array(
"auth" => $result
);
//echo $_GET['jsoncallback'] . json_encode($arr);
echo $_GET['jsoncallback'] . "(".json_encode($arr).")";
六:vi ./app/views/layout.htmlpage.menu1.php
注释一下代码:
/*
(new CTag('header', true))
->setAttribute('role', 'banner')
->addItem(
(new CDiv())
->addItem($top_menu)
->addItem($sub_menu_div)
->addClass(ZBX_STYLE_NAV)
->setAttribute('role', 'navigation')
)
->show();
*/
zabbix二次开发集成拓扑图功能
最新推荐文章于 2022-10-05 19:34:12 发布