设置vnstat语言为中文
在上一篇centos安装vnstat监控系统流量,我使用vnstat+vnstat_php_frontend来监控vps的流量,但英文看起来很别扭,还是中文看起来舒服点,下面就是我根据一位台湾朋友的配置改的.
系统:centos 5.9
环境:lnmp+vnstat+vnstat_php_frontend
1.创建cn.php
cd /var/www/vhosts/wwwroot/vnstat/lang
touch cn.php
vi cn.php
vi cn.php
<?php // sidebar labels $L['summary'] = '摘要'; $L['hours'] = '每时'; $L['days'] = '每日'; $L['months'] = '每月'; // main table headers $L['Summary'] = '摘要'; $L['Top 10 days'] = '最近 10 天'; $L['Last 24 hours'] = '最后 24 小时'; $L['Last 30 days'] = '最后 30 天'; $L['Last 12 months'] = '最后 12 个月'; // traffic table columns $L['In'] = '流入'; $L['Out'] = '流出'; $L['Total'] = '统计'; // summary rows $L['This hour'] = '本小时'; $L['This day'] = '本日'; $L['This month'] = '本月'; $L['All time'] = '全部时间'; // graph text $L['Traffic data for'] = '流量统计'; $L['bytes in'] = 'bytes 流入'; $L['bytes out'] = 'bytes 流出'; // date formats $L['datefmt_days'] = '%d %B'; $L['datefmt_days_img'] = '%d'; $L['datefmt_months'] = '%B %Y'; $L['datefmt_months_img'] = '%b'; $L['datefmt_hours'] = '%l%P'; $L['datefmt_hours_img'] = '%l'; $L['datefmt_top'] = '%d %B %Y';
2.修改config.php
cd /var/www/vhosts/wwwroot/vnstat
vi config.php
<?php
//
// vnStat PHP frontend (c)2006-2010 Bjorge Dijkstra (bjd@jooz.net)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//
// see file COPYING or at http://www.gnu.org/licenses/gpl.html
// for more information.
//
error_reporting(E_ALL | E_NOTICE);
//
// configuration parameters
//
// edit these to reflect your particular situation
//
$locale = 'en_US.UTF-8';
//$locale = 'zh_TW.UTF-8';
$language = 'cn';
// list of network interfaces monitored by vnStat
//$iface_list = array('eth0', 'sixxs');
$iface_list = array('eth0');
//
// optional names for interfaces
// if there's no name set for an interface then the interface identifier
// will be displayed instead
//
$iface_title['eth0'] = '本机流量';
//$iface_title['eth0'] = 'Internal';
//$iface_title['sixxs'] = 'SixXS IPv6';
//
// There are two possible sources for vnstat data. If the $vnstat_bin
// variable is set then vnstat is called directly from the PHP script
// to get the interface data.
//
// The other option is to periodically dump the vnstat interface data to
// a file (e.g. by a cronjob). In that case the $vnstat_bin variable
// must be cleared and set $data_dir to the location where the dumps
// are stored. Dumps must be named 'vnstat_dump_$iface'.
//
// You can generate vnstat dumps with the command:
// vnstat --dumpdb -i $iface > /path/to/data_dir/vnstat_dump_$iface
//
$vnstat_bin = '/usr/bin/vnstat';
$data_dir = dirname(__FILE__).'/dumps';
// graphics format to use: svg or png
$graph_format='svg';
// Font to use for PNG graphs
define('GRAPH_FONT',dirname(__FILE__).'/VeraBd.ttf');
// Font to use for SVG graphs
define('SVG_FONT', 'Verdana');
// Default theme
define('DEFAULT_COLORSCHEME', 'light');
3.验证效果
在浏览器上访问http://domain.name/vnstat,看是否变为中文了.如图
附件下载:
vnstat中文配置.rar 1.81KB



评论: