summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-08-01 12:12:55 +0100
committerRichard Wall <richard@aziz>2010-08-01 12:12:55 +0100
commitd9601a87d071f066f0c58d3a8b93687e0d0969c4 (patch)
tree1f6bde7c4af497aa421113ceffe05258c86c3822
parenta8767f33f43d23c78ed7c93482278f90847ce00a (diff)
get rid of the separate loading of the available rrd listv10.7
-rw-r--r--docs/jarmon_example_recipes.js46
-rw-r--r--docs/rrd_finder.rpy (renamed from rrd_finder.rpy)0
-rw-r--r--index.html42
-rw-r--r--jarmon.js19
-rw-r--r--rrd_list.json69
5 files changed, 44 insertions, 132 deletions
diff --git a/docs/jarmon_example_recipes.js b/docs/jarmon_example_recipes.js
index 73dd3d5..90b5c2e 100644
--- a/docs/jarmon_example_recipes.js
+++ b/docs/jarmon_example_recipes.js
@@ -14,26 +14,26 @@ jarmon.COLLECTD_RECIPES = {
{
title: 'CPU Usage',
data: [
- ['cpu-0/cpu-wait.rrd', 0, 'CPU-0 Wait', '%'],
- ['cpu-1/cpu-wait.rrd', 0, 'CPU-1 Wait', '%'],
- ['cpu-0/cpu-system.rrd', 0, 'CPU-0 System', '%'],
- ['cpu-1/cpu-system.rrd', 0, 'CPU-1 System', '%'],
- ['cpu-0/cpu-user.rrd', 0, 'CPU-0 User', '%'],
- ['cpu-1/cpu-user.rrd', 0, 'CPU-1 User', '%']
+ ['data/cpu-0/cpu-wait.rrd', 0, 'CPU-0 Wait', '%'],
+ ['data/cpu-1/cpu-wait.rrd', 0, 'CPU-1 Wait', '%'],
+ ['data/cpu-0/cpu-system.rrd', 0, 'CPU-0 System', '%'],
+ ['data/cpu-1/cpu-system.rrd', 0, 'CPU-1 System', '%'],
+ ['data/cpu-0/cpu-user.rrd', 0, 'CPU-0 User', '%'],
+ ['data/cpu-1/cpu-user.rrd', 0, 'CPU-1 User', '%']
],
options: jQuery.extend(true, {}, jarmon.Chart.BASE_OPTIONS,
jarmon.Chart.STACKED_OPTIONS)
- },
+ }
],
'memory': [
{
title: 'Memory',
data: [
- ['memory/memory-buffered.rrd', 0, 'Buffered', 'B'],
- ['memory/memory-used.rrd', 0, 'Used', 'B'],
- ['memory/memory-cached.rrd', 0, 'Cached', 'B'],
- ['memory/memory-free.rrd', 0, 'Free', 'B']
+ ['data/memory/memory-buffered.rrd', 0, 'Buffered', 'B'],
+ ['data/memory/memory-used.rrd', 0, 'Used', 'B'],
+ ['data/memory/memory-cached.rrd', 0, 'Cached', 'B'],
+ ['data/memory/memory-free.rrd', 0, 'Free', 'B']
],
options: jQuery.extend(true, {}, jarmon.Chart.BASE_OPTIONS,
jarmon.Chart.STACKED_OPTIONS)
@@ -44,10 +44,10 @@ jarmon.COLLECTD_RECIPES = {
{
title: 'DNS Query Types',
data: [
- ['dns/dns_qtype-A.rrd', 0, 'A', 'Q/s'],
- ['dns/dns_qtype-PTR.rrd', 0, 'PTR', 'Q/s'],
- ['dns/dns_qtype-SOA.rrd', 0, 'SOA', 'Q/s'],
- ['dns/dns_qtype-SRV.rrd', 0, 'SRV', 'Q/s']
+ ['data/dns/dns_qtype-A.rrd', 0, 'A', 'Q/s'],
+ ['data/dns/dns_qtype-PTR.rrd', 0, 'PTR', 'Q/s'],
+ ['data/dns/dns_qtype-SOA.rrd', 0, 'SOA', 'Q/s'],
+ ['data/dns/dns_qtype-SRV.rrd', 0, 'SRV', 'Q/s']
],
options: jQuery.extend(true, {}, jarmon.Chart.BASE_OPTIONS)
},
@@ -55,9 +55,9 @@ jarmon.COLLECTD_RECIPES = {
{
title: 'DNS Return Codes',
data: [
- ['dns/dns_rcode-NOERROR.rrd', 0, 'NOERROR', 'Q/s'],
- ['dns/dns_rcode-NXDOMAIN.rrd', 0, 'NXDOMAIN', 'Q/s'],
- ['dns/dns_rcode-SERVFAIL.rrd', 0, 'SERVFAIL', 'Q/s']
+ ['data/dns/dns_rcode-NOERROR.rrd', 0, 'NOERROR', 'Q/s'],
+ ['data/dns/dns_rcode-NXDOMAIN.rrd', 0, 'NXDOMAIN', 'Q/s'],
+ ['data/dns/dns_rcode-SERVFAIL.rrd', 0, 'SERVFAIL', 'Q/s']
],
options: jQuery.extend(true, {}, jarmon.Chart.BASE_OPTIONS)
}
@@ -67,9 +67,9 @@ jarmon.COLLECTD_RECIPES = {
{
title: 'Load Average',
data: [
- ['load/load.rrd', 'shortterm', 'Short Term', ''],
- ['load/load.rrd', 'midterm', 'Medium Term', ''],
- ['load/load.rrd', 'longterm', 'Long Term', '']
+ ['data/load/load.rrd', 'shortterm', 'Short Term', ''],
+ ['data/load/load.rrd', 'midterm', 'Medium Term', ''],
+ ['data/load/load.rrd', 'longterm', 'Long Term', '']
],
options: jQuery.extend(true, {}, jarmon.Chart.BASE_OPTIONS)
}
@@ -79,8 +79,8 @@ jarmon.COLLECTD_RECIPES = {
{
title: 'Wlan0 Throughput',
data: [
- ['interface/if_octets-wlan0.rrd', 'tx', 'Transmit', 'b/s'],
- ['interface/if_octets-wlan0.rrd', 'rx', 'Receive', 'b/s']
+ ['data/interface/if_octets-wlan0.rrd', 'tx', 'Transmit', 'b/s'],
+ ['data/interface/if_octets-wlan0.rrd', 'rx', 'Receive', 'b/s']
],
options: jQuery.extend(true, {}, jarmon.Chart.BASE_OPTIONS)
}
diff --git a/rrd_finder.rpy b/docs/rrd_finder.rpy
index c7c8517..c7c8517 100644
--- a/rrd_finder.rpy
+++ b/docs/rrd_finder.rpy
diff --git a/index.html b/index.html
index 3db6594..cdc920e 100644
--- a/index.html
+++ b/index.html
@@ -22,29 +22,29 @@
{
title: 'Jarmon Webserver TCP Stats',
data: [
- ['tcpconns-8080-local/tcp_connections-CLOSE_WAIT.rrd', 0, 'CLOSE_WAIT', ''],
- ['tcpconns-8080-local/tcp_connections-SYN_RECV.rrd', 0, 'SYN_RECV', ''],
- ['tcpconns-8080-local/tcp_connections-TIME_WAIT.rrd', 0, 'TIME_WAIT', ''],
- ['tcpconns-8080-local/tcp_connections-CLOSED.rrd', 0, 'CLOSED', ''],
- ['tcpconns-8080-local/tcp_connections-FIN_WAIT2.rrd', 0, 'FIN_WAIT2', ''],
- ['tcpconns-8080-local/tcp_connections-FIN_WAIT1.rrd', 0, 'FIN_WAIT1', ''],
- ['tcpconns-8080-local/tcp_connections-ESTABLISHED.rrd', 0, 'ESTABLISHED', ''],
- ['tcpconns-8080-local/tcp_connections-LAST_ACK.rrd', 0, 'LAST_ACK', ''],
- ['tcpconns-8080-local/tcp_connections-LISTEN.rrd', 0, 'LISTEN', ''],
- ['tcpconns-8080-local/tcp_connections-SYN_SENT.rrd', 0, 'SYN_SENT', ''],
- ['tcpconns-8080-local/tcp_connections-CLOSING.rrd', 0, 'CLOSING', '']
+ ['data/tcpconns-8080-local/tcp_connections-CLOSE_WAIT.rrd', 0, 'CLOSE_WAIT', ''],
+ ['data/tcpconns-8080-local/tcp_connections-SYN_RECV.rrd', 0, 'SYN_RECV', ''],
+ ['data/tcpconns-8080-local/tcp_connections-TIME_WAIT.rrd', 0, 'TIME_WAIT', ''],
+ ['data/tcpconns-8080-local/tcp_connections-CLOSED.rrd', 0, 'CLOSED', ''],
+ ['data/tcpconns-8080-local/tcp_connections-FIN_WAIT2.rrd', 0, 'FIN_WAIT2', ''],
+ ['data/tcpconns-8080-local/tcp_connections-FIN_WAIT1.rrd', 0, 'FIN_WAIT1', ''],
+ ['data/tcpconns-8080-local/tcp_connections-ESTABLISHED.rrd', 0, 'ESTABLISHED', ''],
+ ['data/tcpconns-8080-local/tcp_connections-LAST_ACK.rrd', 0, 'LAST_ACK', ''],
+ ['data/tcpconns-8080-local/tcp_connections-LISTEN.rrd', 0, 'LISTEN', ''],
+ ['data/tcpconns-8080-local/tcp_connections-SYN_SENT.rrd', 0, 'SYN_SENT', ''],
+ ['data/tcpconns-8080-local/tcp_connections-CLOSING.rrd', 0, 'CLOSING', '']
],
options: jQuery.extend(true, {yaxis: {tickDecimals: 0}}, jarmon.Chart.BASE_OPTIONS, jarmon.Chart.STACKED_OPTIONS)
- },
+ }
];
- function initialiseCharts(rrdUrlList) {
+ function initialiseCharts() {
/**
* Setup chart date range controls and all charts
**/
- var p = new jarmon.Parallimiter(2);
+ var p = new jarmon.Parallimiter(1);
function serialDownloader(url) {
return p.addCallable(jarmon.downloadBinary, [url]);
}
@@ -72,22 +72,18 @@
cc.charts = [].concat(
jarmon.Chart.fromRecipe(
- rrdUrlList,
[].concat(
jarmon.COLLECTD_RECIPES.cpu,
jarmon.COLLECTD_RECIPES.memory,
jarmon.COLLECTD_RECIPES.load),
templateFactory('.system-charts'), serialDownloader),
jarmon.Chart.fromRecipe(
- rrdUrlList,
jarmon.COLLECTD_RECIPES.interface,
templateFactory('.network-charts'), serialDownloader),
jarmon.Chart.fromRecipe(
- rrdUrlList,
jarmon.COLLECTD_RECIPES.dns,
templateFactory('.dns-charts'), serialDownloader),
jarmon.Chart.fromRecipe(
- rrdUrlList,
application_recipes,
templateFactory('.application-charts'), serialDownloader)
);
@@ -97,14 +93,6 @@
}
$(function() {
- // Download a list of available rrd files and use it to generate
- // any viable chart recipes
- // A static json file containing a list of rrd urls
- $.getJSON('rrd_list.json', initialiseCharts);
-
- // Alternatively use a dynamically generated list of rrd urls
- //$.getJSON('rrd_finder.rpy', initialiseCharts);
-
// Add dhtml calendars to the date input fields
$(".timerange_control img")
.dateinput({
@@ -171,6 +159,8 @@
// Setup dhtml tabs
$(".css-tabs").tabs(".css-panes > div", {history: true});
+
+ initialiseCharts();
});
</script>
</head>
diff --git a/jarmon.js b/jarmon.js
index 8f7edb7..5ec5283 100644
--- a/jarmon.js
+++ b/jarmon.js
@@ -582,7 +582,7 @@ jarmon.Chart.prototype.draw = function() {
};
-jarmon.Chart.fromRecipe = function(rrdUrlList, recipes, templateFactory, downloader) {
+jarmon.Chart.fromRecipe = function(recipes, templateFactory, downloader) {
/**
* A factory function to generate a list of I{Chart} from a list of recipes
* and a list of available rrd files in collectd path format.
@@ -592,12 +592,11 @@ jarmon.Chart.fromRecipe = function(rrdUrlList, recipes, templateFactory, downloa
* @param templateFactory: A callable which generates an html template for a
* chart.
**/
- var rrdUrlBlob = rrdUrlList.join('\n')
var charts = [];
var dataDict = {};
- var recipe, chartData, template, c, i, j, x, ds, label, rrd, unit, re, match;
+ var recipe, chartData, template, c, i, j, ds, label, rrd, unit, re, match;
for(i=0; i<recipes.length; i++) {
recipe = recipes[i];
@@ -608,18 +607,10 @@ jarmon.Chart.fromRecipe = function(rrdUrlList, recipes, templateFactory, downloa
ds = recipe['data'][j][1];
label = recipe['data'][j][2];
unit = recipe['data'][j][3];
- re = new RegExp('.*/' + rrd, 'gm');
- match = rrdUrlBlob.match(re);
- if(!match) {
- continue;
- }
- for(x=0; x<match.length; x++) {
-
- if(typeof dataDict[match[x]] == 'undefined') {
- dataDict[match[x]] = new jarmon.RrdQueryRemote(match[x], unit, downloader);
- }
- chartData.push([label, new jarmon.RrdQueryDsProxy(dataDict[match[x]], ds)]);
+ if(typeof dataDict[rrd] == 'undefined') {
+ dataDict[rrd] = new jarmon.RrdQueryRemote(rrd, unit, downloader);
}
+ chartData.push([label, new jarmon.RrdQueryDsProxy(dataDict[rrd], ds)]);
}
if(chartData.length > 0) {
template = templateFactory();
diff --git a/rrd_list.json b/rrd_list.json
deleted file mode 100644
index 2dd35de..0000000
--- a/rrd_list.json
+++ /dev/null
@@ -1,69 +0,0 @@
-["data/cpu-1/cpu-steal.rrd",
- "data/cpu-1/cpu-user.rrd",
- "data/cpu-1/cpu-softirq.rrd",
- "data/cpu-1/cpu-nice.rrd",
- "data/cpu-1/cpu-system.rrd",
- "data/cpu-1/cpu-interrupt.rrd",
- "data/cpu-1/cpu-idle.rrd",
- "data/cpu-1/cpu-wait.rrd",
- "data/cpu-0/cpu-steal.rrd",
- "data/cpu-0/cpu-user.rrd",
- "data/cpu-0/cpu-softirq.rrd",
- "data/cpu-0/cpu-nice.rrd",
- "data/cpu-0/cpu-system.rrd",
- "data/cpu-0/cpu-interrupt.rrd",
- "data/cpu-0/cpu-idle.rrd",
- "data/cpu-0/cpu-wait.rrd",
- "data/memory/memory-buffered.rrd",
- "data/memory/memory-used.rrd",
- "data/memory/memory-free.rrd",
- "data/memory/memory-cached.rrd",
- "data/tcpconns-8080-local/tcp_connections-CLOSE_WAIT.rrd",
- "data/tcpconns-8080-local/tcp_connections-SYN_RECV.rrd",
- "data/tcpconns-8080-local/tcp_connections-TIME_WAIT.rrd",
- "data/tcpconns-8080-local/tcp_connections-CLOSED.rrd",
- "data/tcpconns-8080-local/tcp_connections-FIN_WAIT2.rrd",
- "data/tcpconns-8080-local/tcp_connections-FIN_WAIT1.rrd",
- "data/tcpconns-8080-local/tcp_connections-ESTABLISHED.rrd",
- "data/tcpconns-8080-local/tcp_connections-LAST_ACK.rrd",
- "data/tcpconns-8080-local/tcp_connections-LISTEN.rrd",
- "data/tcpconns-8080-local/tcp_connections-SYN_SENT.rrd",
- "data/tcpconns-8080-local/tcp_connections-CLOSING.rrd",
- "data/load/load.rrd",
- "data/battery-0/voltage.rrd",
- "data/battery-0/current.rrd",
- "data/battery-0/charge.rrd",
- "data/interface/if_errors-tunl0.rrd",
- "data/interface/if_errors-vboxnet0.rrd",
- "data/interface/if_octets-tunl0.rrd",
- "data/interface/if_errors-ppp0.rrd",
- "data/interface/if_octets-wlan0.rrd",
- "data/interface/if_packets-eth0.rrd",
- "data/interface/if_packets-wlan0.rrd",
- "data/interface/if_packets-wmaster0.rrd",
- "data/interface/if_octets-vboxnet0.rrd",
- "data/interface/if_octets-ppp0.rrd",
- "data/interface/if_octets-lo.rrd",
- "data/interface/if_octets-pan0.rrd",
- "data/interface/if_errors-pan0.rrd",
- "data/interface/if_packets-vboxnet0.rrd",
- "data/interface/if_errors-lo.rrd",
- "data/interface/if_errors-eth0.rrd",
- "data/interface/if_packets-lo.rrd",
- "data/interface/if_packets-ppp0.rrd",
- "data/interface/if_octets-wmaster0.rrd",
- "data/interface/if_packets-pan0.rrd",
- "data/interface/if_errors-wmaster0.rrd",
- "data/interface/if_packets-tunl0.rrd",
- "data/interface/if_errors-wlan0.rrd",
- "data/interface/if_octets-eth0.rrd",
- "data/dns/dns_qtype-SRV.rrd",
- "data/dns/dns_qtype-AAAA.rrd",
- "data/dns/dns_opcode-Query.rrd",
- "data/dns/dns_qtype-A.rrd",
- "data/dns/dns_rcode-NXDOMAIN.rrd",
- "data/dns/dns_octets.rrd",
- "data/dns/dns_qtype-PTR.rrd",
- "data/dns/dns_rcode-SERVFAIL.rrd",
- "data/dns/dns_qtype-SOA.rrd",
- "data/dns/dns_rcode-NOERROR.rrd"]