zoukankan      html  css  js  c++  java
  • centreon 画图x轴乱码

    rrdtool默认不指定locale,使用本地locale。乱码我估记是中文字体,由于操作系统最小化安装,本地没有中文字体,导致乱码。

    1 安装中文字体

    yum -y install wqy-zenhei-fonts wqy-zenhei-fonts-common
    cd /usr/share/fonts
    mkfontscale wqy-zenhei
    fc-cache wqy-zenhei
    

    另外一种方法是改动centreon程序,变更x轴格式,小于24小时,仅显示小时分钟 00:00,小于3天,显示日期+小时 02/01 00:00,小于3个月,显示日期 02/01,小于12个月,显示月,02

    [-x|--x-grid GTM:GST:MTM:MST:LTM:LST:LPR:LFM]

    GTM:GST :控制次要格网线的位置。GTM 是一个时间单位,可以是 SECOND、MINUTE、HOUR、DAY 、WEEK、MONTH、YEAR 。
    GST 则是一个数字,控制每隔多长时间放置一根次要格线。例如我们要画一个1天的图表,决定每15分钟一根次要网格线,则格式为 MINUTE:15

    MTM:MST : 控制主要网格线的位置。MTM 同样是时间单位,MST 是一个数字。接上面的例子,决定一个小时1根主要网格线。则格式为 HOUR:1
    LTM:LST :控制每隔多长时间输出一个label 。决定为1小时1个 label 。则格式为 HOUR:1

    LPR:LFM :LTM:LST 只是决定了 label 的显示位置了,没有指定要显示什么内容。LPR 指的是如何放置 label 。如果LPR 为0,则数字对齐格线(适用于显示时间)。如果不为0,则会做一些偏移(适用于显示星期几、月份等)。至于LFM 则需要熟悉一下 date 命令的参数,常用的有 %a(星期几)、%b(月份)、%d(天)、%H(小时)、%M(分)、%Y(年)。显示小时和分,用 %H%M
    /usr/share/centreon/www/class/centreonGraph.class.php

        ......
    
        public function displayImageFlow() {
            $commandLine = "";
    
            /*
             * Send header
             */
    
            $this->flushRrdcached($this->listMetricsId);
    
            $commandLine = " graph - ";
    
            if (isset($this->_RRDoptions["end"]) && isset($this->_RRDoptions["start"])) {
                if ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 2160000
                    && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] < 12960000) {
                    if ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] < 10368000 - (86400*7))
                        $this->setRRDOption("x-grid", "DAY:1:DAY:7:DAY:7:0:%d/%m");
                    else
                        $this->setRRDOption("x-grid", "DAY:7:DAY:7:DAY:14:0:%d/%m");
                }
            }
    
        ......
    
    if (isset($this->_RRDoptions["end"]) && isset($this->_RRDoptions["start"])) {
        if ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 3600*1 && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] <= 3600*6) {
            $this->setRRDOption("x-grid", "MINUTE:10:HOUR:1:HOUR:1:0:%H:%M");
        } elseif ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 3600*6 && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] <= 3600*24) {
            $this->setRRDOption("x-grid", "MINUTE:30:HOUR:2:HOUR:2:0:%H:%M");
        } elseif ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 86400*1 && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] <= 86400*3) {
            $this->setRRDOption("x-grid", "HOUR:2:HOUR:6:HOUR:6:0:%H:%M");
        } elseif ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 86400*3 && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] <= 86400*7) {
            $this->setRRDOption("x-grid", "HOUR:6:DAY:1:DAY:1:0:%d/%m");
        } elseif ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 86400*7 && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] <= 86400*15) {
            $this->setRRDOption("x-grid", "DAY:1:DAY:2:DAY:2:0:%d/%m");
        } elseif ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 86400*15 && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] <= 86400*31*2) {
            $this->setRRDOption("x-grid", "DAY:1:WEEK:1:WEEK:1:0:%d/%m");
        } elseif ($this->_RRDoptions["end"] - $this->_RRDoptions["start"] > 86400*31*2 && $this->_RRDoptions["end"] - $this->_RRDoptions["start"] <= 86400*31*6) { 
            $this->setRRDOption("x-grid", "WEEK:1:WEEK:4:WEEK:4:0:%m/%Y");
        } else {
            $this->setRRDOption("x-grid", "MONTH:1:MONTH:2:MONTH:2:0:%m/%Y");
        }
    }
    

  • 相关阅读:
    用Webshell直接杀入内网
    别再说找不到Python练手项目了,这80个拿去过冬
    亲爱的,我是一条Linux运维技术学习路径呀。
    一份C++学习资源,咬牙切齿地好用呀
    技术变现,到底怎么变?本文或能成为你的“点金石”
    40个大数据学习资源,个个是干货,最后7个太给力
    零基础如何学好数据分析?
    8个程序员专用软件/网站,个个是神器,第一个最惊喜......
    如何写一个优秀的GitHub项目README文档?
    超全PHP学习资源整理:入门到进阶系列
  • 原文地址:https://www.cnblogs.com/liujitao79/p/5189248.html
Copyright © 2011-2022 走看看