2022 Zabbix中国峰会
2022 Zabbix中国峰会

4 Frontend maintenance mode前端维护模式

Overview概述

Zabbix web frontend can be temporarily disabled in order to prohibit access to it. This can be useful for protecting the Zabbix database from any changes initiated by users, thus protecting the integrity of database. Zabbix web前端可以暂时禁用,以禁止访问它。 这对于保护Zabbix数据库免受用户发起的任何更改非常有用,从而保护了数据库的完整性。

Zabbix database can be stopped and maintenance tasks can be performed while Zabbix frontend is in maintenance mode. Zabbix数据库可以被停止,并且维护任务可以在Zabbix 前端在维护模式中进行。

Users from defined IP addresses will be able to work with the frontend normally during maintenance mode. 来自指定IP地址的用户将能够在维护模式期间正常工作。

Configuration配置

In order to enable maintenance mode, the maintenance.inc.php file (located in /conf of the Zabbix HTML document directory on the webserver) must be modified to uncomment the following lines: 为了启用维护模式,必须以取消注释的方法修改 maintenance.inc.php文件(位于web服务器上的Zabbix HTML 文档目录的/ conf中):

// Maintenance mode. 维护模式
       define('ZBX_DENY_GUI_ACCESS', 1);
       
       // Array of IP addresses, which are allowed to connect to frontend (optional). 一列包含IP地址的数组,它们可以连接到前端(可选)
       $ZBX_GUI_ACCESS_IP_RANGE = array('127.0.0.1');
       
       // Message shown on warning screen (optional). 警告屏幕上所显示的信息(可选)
       $ZBX_GUI_ACCESS_MESSAGE = 'We are upgrading MySQL database till 15:00. Stay tuned...';
Parameter参数 D tails详情
ZBX_DENY_GUI_ACCESS Enable maintenance mode:打开维护模式:
1 – maintenance mode is enabled, disabled otherwise 维护模式已打开,其他的数字表示未打开
ZBX_GUI_ACCESS_IP_RANGE Array of IP addresses, which are allowed to connect to frontend (optional).允许连接到前端的IP地址数组(可选)
For example例:
array('192.168.1.1', '192.168.1.2')
ZBX_GUI_ACCESS_MESSAGE A message you can enter to inform users about the maintenance (optional).您可以输入的消息以通知用户维护(可选)

Display显示

The following screen will be displayed when trying to access the Zabbix frontend while in maintenance mode. The screen is refreshed every 30 seconds in order to return to a normal state without user intervention when the maintenance is over. 下图显示了在维护模式下访问Zabbix前端的情况。屏幕每30秒刷新一次,以便在维护结束后,无需用户干预即可恢复正常状态。

IP addresses defined in ZBX_GUI_ACCESS_IP_RANGE will be able to access the frontend as always.在ZBX_GUI_ACCESS_IP_RANGE中定义的IP地址也可以一直访问前端。