我有一台运行和收集数据的石墨服务器。这已经工作了几个月。 我发现cubism.js,我想让它工作,没有运气。使用Modify Cubism.js Graphite Title Text下的代码。我无法让cubism.js工作。 代码:(更改了服务器名称)。
<!DOCTYPE html>
<meta charset="utf-8" />
Cubism.js</pre>
<style>
</style>
<div id="body">
<h2>Host01 Load Average</h2>
<div id="graphs"></div>
<script type="text/javascript" src="d3.v3.js"></script>
<script type="text/javascript" src="cubism.v1.js"></script>
<script type="text/javascript" src="highlight.min.js"></script>
<script type="text/javascript">
{font-family:arial,helvettica,sans-serif"}
</script>
<script type="text/javascript">
var context = cubism.context()
.step( 1 * 30 * 1000 )
.size(960);
var graphite = context.graphite("http://graphite.examp.com");
graphFind = 'PDU.*.B-AMPS'
graphite.find(graphFind, function(error, results) {
// Map find results to array and set to graphite.metric object type
var metrics = results.sort().map(function(i) {
return graphite.metric(i);
});
// loop through array and print stuff to "graphs" div
for (var i=0;i<metrics.length;i++){
d3.select("#graphs").call(function(div) {
div.append("div")
.selectAll(".horizon")
.data([metrics[i]])
.enter()
.append("div")
.attr("class", "horizon")
.call(context.horizon());
});
}
});
确定
我看到网址屏幕上的Cubism.js Host01负载平均值 没有数据:
查看页面源,如上所示, 在graphte服务器上查看日志。
xxx.xxx.116.130 - - [28/Mar/2014:17:17:56 -0500] "GET /metrics
/find?format=completer& query=PDU.*.B-AMPS HTTP/1.1" 200 436
在浏览器中我可以
http://graphite.examp.com/metrics/find?format=completer&query=PDU.*.B-AMPS
并获取
{"metrics": [{"is_leaf": "1", "path": "PDU.rack1a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack2a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack2b.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack3a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack3b.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack4a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack4b.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack5a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack5b.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack6a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack6b.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack7a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack7b.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack8a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack9a.B-AMPS", "name": "B-AMPS"},
{"is_leaf": "1", "path": "PDU.rack9b.B-AMPS", "name": "B-AMPS"}]}
注意:这些文件存在,我尝试了各种在线版本
<script type="text/javascript" src="d3.v3.js"></script>
<script type="text/javascript" src="cubism.v1.js"></script>
<script type="text/javascript" src="highlight.min.js"></script
我想弄清楚为什么我找不到任何可以在任何地方工作的例子。 有些我尝试我得到了很好的时间统治者,但从来没有和数据。
对此的任何帮助或指向有效示例的链接。会很棒的。
答案 0 :(得分:0)
apache2来自命令行运行.. a2enmod标头 在你的VirtualHost标签内安装它 标题集设置Access-Control-Allow-Origin&#34; *&#34; 标题集Access-Control-Allow-Methods&#34; GET,OPTIONS&#34; 标题集设置Access-Control-Allow-Headers&#34; origin,authorization,accept&#34;
你应该开始看数据,我做了。
答案 1 :(得分:0)
发现它在你的标签中添加了这个apache2。
标题集Access-Control-Allow-Origin“*” 标题集Access-Control-Allow-Methods“GET,OPTIONS” 标题设置Access-Control-Allow-Headers“origin,authorization,accept”