本文整理汇总了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;
}
示例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;
}
}
示例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;
}