data source 配置了zabbix源;使用grafana创建新的dashboard,选择zabbix 源,Metrics值内未能获取到选择的zabbix主机host。 zabbix server的/var/www/html/zabbix/api_jsonrpc.php文件已配置;不知道故障出在那里,请指教。谢谢
<?php
header(‘Access-Control-Allow-Origin: *‘);
header(‘Access-Control-Allow-Headers: Content-Type‘);
header(‘Access-Control-Allow-Methods: POST‘);
header(‘Access-Control-Max-Age: 1000‘);
if ($_SERVER[‘REQUEST_METHOD‘] === ‘OPTIONS‘) {
return;
}
require_once dirname(__FILE__).'/include/func.inc.php';
require_once dirname(__FILE__).'/include/classes/class.chttp_request.php';
$allowed_content = array(
'application/json-rpc' => 'json-rpc',
'application/json' => 'json-rpc',
'application/jsonrequest' => 'json-rpc',
);
$http_request = new CHTTP_request();
$content_type = $http_request->header('Content-Type');
$content_type = explode(';', $content_type);
$content_type = $content_type[0];
if (!isset($allowed_content[$content_type])) {
header('HTTP/1.0 412 Precondition Failed');
exit();
}
require_once dirname(__FILE__).'/include/classes/core/Z.php';
header('Content-Type: application/json');
$data = $http_request->body();
try {
Z::getInstance()->run(ZBase::EXEC_MODE_API);
$jsonRpc = new CJSONrpc($data);
echo $jsonRpc->execute();
}
catch (Exception $e) {
// decode input json request to get request's id
$jsonData = CJs::decodeJson($data);
$response = array(
'jsonrpc' => '2.0',
'error' => array(
'code' => 1,
'message' => $e->getMessage()
),
'id' => (isset($jsonData['id']) ? $jsonData['id'] : null)
);
echo CJs::encodeJson($response);
}