aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2016-11-18 18:54:10 +0100
committerKristian Lyngstol <kly@kly.no>2016-11-18 18:54:10 +0100
commitc38af8933072bb2b9606cd6490e1a802ab4c4187 (patch)
treeadf4e5cb65ed1dc5852c7c29e77eb6b1e09e12e3
parent06591202ce5549a949343f0f5f8959771a1b5657 (diff)
Tweak various graphite/grafana integrations
s3 is currently disabled as it's bugged.
-rw-r--r--build/storage-schemas.conf4
-rw-r--r--build/test/gondul-grafana-test.Dockerfile6
-rwxr-xr-xcollectors/snmpfetchng.pl11
-rw-r--r--web/js/nms-info-box.js7
4 files changed, 22 insertions, 6 deletions
diff --git a/build/storage-schemas.conf b/build/storage-schemas.conf
index 695ec0e..551f753 100644
--- a/build/storage-schemas.conf
+++ b/build/storage-schemas.conf
@@ -11,6 +11,10 @@
pattern = ^carbon\.
retentions = 60:90d
+[grafana]
+pattern = ^grafana\.
+retentions = 10s:1d, 1m:20d
+
[ping]
pattern = ^ping\.
retentions = 1s:1d, 1m:20d
diff --git a/build/test/gondul-grafana-test.Dockerfile b/build/test/gondul-grafana-test.Dockerfile
index 00345b6..33c69b4 100644
--- a/build/test/gondul-grafana-test.Dockerfile
+++ b/build/test/gondul-grafana-test.Dockerfile
@@ -1,2 +1,8 @@
FROM grafana/grafana:4.0.0-beta1
ENV GF_SERVER_ROOT_URL http://nms-dev.gathering.org/grafana/
+ENV GF_METRICS_GRAPHITE_ADDRESS graphite:2003
+ENV GF_METRICS_GRAPHITE_PREFIX grafana.%(instance_name)s.
+ENV GF_EXTERNAL_IMAGE_STORAGE_PROVIDER internal
+ENV GF_EXTERNAL_IMAGE_STORAGE_S3_BUCKET_URL http://grafana.situla.bitbit.net/
+ENV GF_EXTERNAL_IMAGE_STORAGE_S3_ACCESS_KEY 8KMMX9F3VZZ6MAZOGFF6
+ENV GF_EXTERNAL_IMAGE_STORAGE_S3_SECRET_KEY dTuAqxPGE5SFbtEmJxoZ9Y3AHINOZ5ju0IPfoqfA
diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl
index 7c62ed3..b961cac 100755
--- a/collectors/snmpfetchng.pl
+++ b/collectors/snmpfetchng.pl
@@ -142,7 +142,9 @@ sub callback{
for my $nic (@nicids) {
$tree2{'ports'}{$tree{$nic}{'ifName'}} = $tree{$nic};
for my $tmp_key (keys $tree{$nic}) {
- my $path = "snmp.$switch{'sysname'}.ports.$tree{$nic}{'ifName'}.$tmp_key";
+ my $field = $tree{$nic}{'ifName'};
+ $field =~ s/[^a-z0-9]/_/gi;
+ my $path = "snmp.$switch{'sysname'}.ports.$field.$tmp_key";
my $value = $tree{$nic}{$tmp_key};
if ($value =~ m/^\d+$/) {
print $sock "$path $value $now_graphite\n";
@@ -155,10 +157,11 @@ sub callback{
for my $key (keys %{$tree{$iid}}) {
$tree2{'misc'}{$key}{$iid} = $tree{$iid}{$key};
my $localiid = $iid;
- if ($iid ne "") {
- $localiid = ".$iid";
+ if ($localiid eq "") {
+ $localiid = "_";
}
- my $path = "snmp.$switch{'sysname'}.misc.$key$localiid";
+ $localiid =~ s/[^a-z0-9]/_/gi;
+ my $path = "snmp.$switch{'sysname'}.misc.$key.$localiid";
my $value = $tree{$iid}{$key};
if ($value =~ m/^\d+$/) {
print $sock "$path $value $now_graphite\n";
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js
index 96cca89..2cc6fc4 100644
--- a/web/js/nms-info-box.js
+++ b/web/js/nms-info-box.js
@@ -682,7 +682,8 @@ var switchPortsPanel = function () {
if (snmpJson[obj].ifHCInOctets != 0
|| snmpJson[obj].ifHCOutOctets != 0) {
var img = document.createElement("img");
- img.src = '/render/?target=cactiStyle(aliasByMetric(perSecond(snmp.' + this.sw + '.ports.' + obj + '.{ifHCOutOctets,ifHCInOctets})),"binary")&target=cactiStyle(aliasByMetric(secondYAxis(perSecond(snmp.' + this.sw + '.ports.' + obj + '.{ifInDiscards,ifInErrors,ifOutDiscards,ifOutErrors}))),"binary")' + nmsInfoBox._graphDefaults();
+ var port_id = nmsInfoBox._graphNormalize(obj);
+ img.src = '/render/?target=cactiStyle(aliasByMetric(perSecond(snmp.' + this.sw + '.ports.' + port_id + '.{ifHCOutOctets,ifHCInOctets})),"binary")&target=cactiStyle(aliasByMetric(secondYAxis(perSecond(snmp.' + this.sw + '.ports.' + port_id + '.{ifInDiscards,ifInErrors,ifOutDiscards,ifOutErrors}))),"binary")' + nmsInfoBox._graphDefaults();
img.classList.add("graph");
panelBodyObj.appendChild(img);
}
@@ -902,7 +903,6 @@ var switchEditPanel = function () {
var html = '<input type="text" class="form-control" value="' + template[v] + '" id="edit-' + this.sw + '-' + v + '" onchange=' + tmphandler + ' oninput=' + tmphandler + ' ' + (v == 'sysname' ? "readonly" : "") + '>';
if (v == "placement") {
v = "placement <a onclick='var _x = document.getElementById(\"edit-" + this.sw + "-placement\"); _x.value = \"\\\"reset\\\"\"; _x.oninput();' class='pull-right'>Reset</a>";
- console.log(v);
}
content.push([v, html]);
}
@@ -1139,6 +1139,9 @@ nmsInfoBox._graphZoom = function() {
}
nmsInfoBox._graphFrom = "-60min";
nmsInfoBox._graphUntil = "now";
+nmsInfoBox._graphNormalize = function(f) {
+ return f.replace(/[^a-z0-9]/gi,"_");
+}
nmsInfoBox._graphDefaults = function(title) {
if (title != undefined) {
title = "From " + nmsInfoBox._graphFrom + " until " + nmsInfoBox._graphUntil + " (" + title + ")";