实现步骤:
假如zabbix web目录位置在/var/www/zabbix,定义zabbix目录
ZABBIX_PATH=/var/www/zabbix
一、
在$ZABBIX_PATH/include/defines.inc.php文件中修改771行(zabbix-2.2.8),加入中文字符支持,原始正则:
1 | define( 'ZBX_PREG_INTERNAL_NAMES' , '([0-9a-zA-Z_\. \-]+)' ); |
修改为:
1 2 | // \x80-\xff:匹配用GBK (GB2312/GB18030)编码的所有汉字和标点符号 define( 'ZBX_PREG_INTERNAL_NAMES' , '([0-9a-zA-Z_\. \-\x{80}-\x{ff}]+)' ); /* !!! Don't forget code with C !!! */ |
二、
在$ZABBIX_PATH/include/classes/parsers/CTriggerExpression.php文件中修改759行(zabbix-2.2.8),使触发器表达式支持中文:
1 2 3 4 5 6 7 8 9 |
private function isHostChar( $c ) {
$cc =ord( $c );
if (( $c >= 'a' && $c <= 'z' ) || ( $c >= 'A' && $c <= 'Z' ) || ( $c >= '0' && $c <= '9' )
|| $c == '.' || $c == ' ' || $c == '_' || $c == '-' || $cc > 127) {
return true;
}
return false;
} |