数据监控使用说明

来自技术开发小组内部wiki
跳转至: 导航搜索

为了直观的查看各种数据监控,现以搭建了服务器端框架,使用方法如下:

1)在dianping代码库的application/controllers/monitor文件夹下建立自己的PHP文件如:

<?php
include(APPPATH.'core/DATA_Controller.php');
class SM_check extends DATA_Controller {
    
    public function __construct() {
        parent::__construct ();
                $this->load->model('sms_model','sms');
                $this->load->model('tickets/order_info_model','orders');
        
    }
        
        
        /**
         *短信发送
         */
        public function sm_data(){
            $current_data = date("Y-m-d H:i:s",  time());
            $sms_where = "create_time <='".$current_data."' and ret='00'";
            $ret = $this->sms->get_sms('count(*) as num',$sms_where);
            if(count($ret)>0){
                //参数2代表参数1的类型,是正常数据还是需要比较差异的数据(2,比较差异,1,正常数据)
                $this->set_data($ret[0],2);
            }
           
            $this->show_data();
            
        }
        /**
         *下订单的数量
         */
        public function order_num() {
            $where = " order_status in (1,2,5)";
            $ret = $this->orders->get_orders("count(*) as num", $where);
            
            if(count($ret)>0){
                //参数2代表参数1的类型,是正常数据还是需要比较差异的数据(2,比较差异,1,正常数据)
                $this->set_data($ret[0],2);
            }
            $this->show_data();
        }
        
        /**
         *下订单的金额
         */
        public function order_money_num() {
            $where = " order_status in (1,2,5)";
            $ret = $this->orders->get_orders("SUM(money) as money_num", $where);
            if(count($ret)>0){
                //参数2代表参数1的类型,是正常数据还是需要比较差异的数据(2,比较差异,1,正常数据)
                $this->set_data($ret[0],2);
            }
             $this->show_data();
        }


 
}
注意:编写的类一定要继承DATA_Controller

2)编写方法代码如:

/**
         *下订单的数量
         */
        public function order_num() {
            $where = " order_status in (1,2,5)";
            $ret = $this->orders->get_orders("count(*) as num", $where);
            
            if(count($ret)>0){
                //参数2代表参数1的类型,是正常数据还是需要比较差异的数据(2,比较差异,1,正常数据)
                $this->set_data($ret[0],2);
            }
            $this->show_data();
        }
注意:$this->set_data($ret[0],2);参数1:是你从数据源获取到的数据,一定要以:array('变量名'=>数值)的格式。参数2:代表参数1的类型,是正常数据还是需要比较差异的数据(2,比较差异,1,正常数据)


3)在你编写的方法里调用$this->show_data();
4)把访问地址(如:http://www.fumubang.net/monitor/sm_check/order_num)告诉DBA配置即可