zabbix 二次开发--- 在zabbix菜单栏中增加 CMDB 菜单,该菜单下有个子栏目 CMDB overview,如图:
实现此效果,我们需要修改两个地方:menu.inc.php 和 main.js 。
具体如下:
1 找到 menu.inc.php ,并修改该文件
[root@zabbix_nginx ~]# find / -name "menu.inc.php"
/usr/share/zabbix/include/menu.inc.php
编辑修改menu.inc.php
vim /usr/share/zabbix/include/menu.inc.php
如果没动过源代码的话,在302行添加如下内容(命令行模式下:set nu 可以显示行数):
'cmdb' => [ 'label' => _("CMDB"), 'user_type' => USER_TYPE_SUPER_ADMIN, 'default_page_id' => 0, 'pages' => [ [ 'url' => 'cmdb/overview.html', 'label' => _('CMDB overview') ] ] ]
注意:
USER_TYPE_SUPER_ADMIN 只有超级管理员才能看到该菜单,如果想让zabbix普通账户也看到该 CMDB 菜单,则应将 user_type 改成 USER_TYPE_ZABBIX_USER。(这样改后 guest用户也可以看到 CMDB菜单了,为了安全,我们采用 USER_TYPE_ZABBIX_USER 方式时,应设置禁用 guest用户:管理--->用户群组--->Guests--->设置状态为”停用“)
'user_type' => USER_TYPE_ZABBIX_USER
/usr/share/zabbix/下创建目录cmdb
mkdir cmdb
/usr/share/zabbix/cmdb/ 用来存放 overview.html --->我们的目标页面
2 找到并修改main.js
[root@zabbix_nginx ~]# find / -name "main.js"
/usr/share/zabbix/js/main.js
编辑修改 main.js
vim /usr/share/zabbix/js/main.js
修改为:
menus: {'view': 0, 'cm': 0, 'reports': 0, 'config': 0, 'admin': 0, 'cmdb': 0}
结束。
点击 CMDB ---> CMDB overview ,将弹出目标页面,如下图:
原文链接:https://blog.csdn.net/wudinaniya/article/details/99109955