当前位置: 首页>>代码示例>>PHP>>正文


PHP Check::prepareSample方法代码示例

本文整理汇总了PHP中Check::prepareSample方法的典型用法代码示例。如果您正苦于以下问题:PHP Check::prepareSample方法的具体用法?PHP Check::prepareSample怎么用?PHP Check::prepareSample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Check的用法示例。


在下文中一共展示了Check::prepareSample方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getData

        /**
	 * Requests Graphite Data for check
	 * 
	 * @param  Check $obj   The Check object to get the graphite data for
	 * @return array either a Graphite json_data array or an empty one  
	 */
	static public function getData($obj=NULL)
	{
          if ( $GLOBALS['PRIMARY_SOURCE'] == "GANGLIA" ) {
            $check_url = $GLOBALS['GANGLIA_URL'] . '/graph.php/?' .
                        'target=' . $obj->prepareTarget() . 
                        '&cs='. $obj->prepareSample() . 
                        '&ce=now&format=json';
          } else {
            $check_url = $GLOBALS['GRAPHITE_URL'] . '/render/?' .
                        'target=' . $obj->prepareTarget() . 
                        '&from='. $obj->prepareSample() . 
                        '&format=json';
          }
          $json_data = @file_get_contents($check_url);
          if ($json_data) {
            $data = json_decode($json_data);
          } else {
            $data = array();
          }
      return $data;
	}   
开发者ID:nleskiw,项目名称:Graphite-Tattle,代码行数:27,代码来源:Check.php

示例2: getData

 /**
  * Requests Graphite Data for check
  *
  * @param  Check $obj   The Check object to get the graphite data for
  * @return array either a Graphite json_data array or an empty one
  */
 public static function getData($obj = NULL)
 {
     if ($obj->getType() == 'threshold') {
         if ($GLOBALS['PRIMARY_SOURCE'] == "GANGLIA") {
             $check_url = $GLOBALS['GANGLIA_URL'] . '/graph.php/?' . 'target=' . $obj->prepareTarget() . '&cs=-' . $obj->prepareSample() . 'minutes' . '&ce=now&format=json';
         } else {
             $target = Check::constructTarget($obj);
             $target = str_replace(""", "\"", $target);
             $target = urlencode($target);
             $check_url = $GLOBALS['PROCESSOR_GRAPHITE_URL'];
             if ($check_url == "") {
                 $check_url = $GLOBALS['GRAPHITE_URL'];
             }
             $check_url = "{$check_url}/render/?target={$target}&format=json";
             if ($GLOBALS['ALERTS_TIME_OFFSET'] > 0) {
                 $check_url .= "&from=-" . ($obj->getSample() + $GLOBALS['ALERTS_TIME_OFFSET']) . "minutes" . "&until=-" . $GLOBALS['ALERTS_TIME_OFFSET'] . "minutes";
             } else {
                 $check_url .= '&from=-' . $obj->prepareSample() . 'minutes';
             }
         }
         $json_data = @file_get_contents($check_url);
         if ($json_data) {
             $data = json_decode($json_data);
             if (count($data) <= 0) {
                 fCore::debug("bad json data for {$check_url}\n", FALSE);
                 fCore::debug("Json: {$json_data}\n");
             }
         } else {
             fCore::debug("no data for {$check_url}\n", FALSE);
             $data = array();
         }
         return $data;
     } elseif ($obj->getType() == 'predictive') {
         $data = array();
         for ($i = $obj->getNumberOfRegressions(); $i >= 0; $i--) {
             $regression_size = 0;
             if ($obj->getRegressionType() == 'daily') {
                 $regression_size = self::MINUTES_PER_DAY * $i;
             } elseif ($obj->getRegressionType() == 'weekly') {
                 $regression_size = self::MINUTES_PER_WEEK * $i;
             } elseif ($obj->getRegressionType() == 'monthly') {
                 $regression_size = self::MINUTES_PER_MONTH * $i;
             }
             $from = $regression_size + $obj->getSample();
             $until = $regression_size;
             $check_url = $GLOBALS['PROCESSOR_GRAPHITE_URL'] . '/render/?' . 'target=' . $obj->prepareTarget() . '&from=-' . $from . 'minutes' . '&until=-' . $until . 'minutes' . '&format=json';
             $json_data = @file_get_contents($check_url);
             if ($json_data) {
                 $temp_data = json_decode($json_data);
                 $value = 0;
                 if ($obj->getBaseline() == 'average') {
                     $value = subarray_average($temp_data[0]->datapoints);
                 } elseif ($obj->getBaseline() == 'median') {
                     $value = subarray_median($temp_data[0]->datapoints);
                 }
                 array_push($data, $value);
                 //$temp_data = $temp_data[0]->datapoints;
                 //fCore::debug("Iteration: " . $i,FALSE);
                 //for($j=0; $j < count($temp_data); $j++) {
                 //  if($temp_data[$j][0] != 0) {
                 //    fCore::debug($temp_data[$j][0],FALSE);
                 //  }
                 //}
                 //fCore::debug("\n",FALSE);
                 //$data = array_merge($data, $temp_data);
             }
         }
         return $data;
     }
 }
开发者ID:nagyist,项目名称:Tattle,代码行数:76,代码来源:Check.php

示例3: getData

        /**
	 * Requests Graphite Data for check
	 * 
	 * @param  Check $obj   The Check object to get the graphite data for
	 * @return array either a Graphite json_data array or an empty one  
	 */
	static public function getData($obj=NULL)
	{
          $check_url = GRAPHITE_URL . '/render/?target=' . $obj->prepareTarget() . '&from='. $obj->prepareSample() . '&format=json';
          $json_data = @file_get_contents($check_url);
          if ($json_data) {
            $data = json_decode($json_data);
          } else {
            $data = array();
          }
      return $data;
	}   
开发者ID:rberger,项目名称:Graphite-Tattle,代码行数:17,代码来源:Check.php


注:本文中的Check::prepareSample方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。