aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2016-10-22 23:01:57 +0200
committerKristian Lyngstol <kly@kly.no>2016-10-22 23:01:57 +0200
commit0f26dbca2a8ba416cb38002a9463cf80f27487c3 (patch)
tree6b4dc2874a855db47dcf9ad62ffce97b06660c06
parent57c27b76fbb7dcc7477a573585f1366364bccdd6 (diff)
More PoC-style graphite integration + grafana
The grafana-bit is ok, but needs to be configured by hand (once). Also tweaks graphite to write new stuff faster. I suspect I will need a better way to handle the graphite/carbon insertion for both ping and snmp, but maybe UDP would solve it... Running tests tonight to get some data regardless.
-rw-r--r--ansible/playbook-test.yml6
-rw-r--r--build/carbon.conf2
-rw-r--r--build/test/gondul-grafana-test.Dockerfile2
-rwxr-xr-xcollectors/snmpfetchng.pl19
4 files changed, 27 insertions, 2 deletions
diff --git a/ansible/playbook-test.yml b/ansible/playbook-test.yml
index f9e19c1..ee35b04 100644
--- a/ansible/playbook-test.yml
+++ b/ansible/playbook-test.yml
@@ -14,6 +14,10 @@
volumes: [ "{{ pwd.stdout }}/:/opt/gondul" , "{{ pwd.stdout }}/data/graphite:/var/lib/graphite" ]
links: []
ports: []
+ - name: "gondul-grafana-test"
+ volumes: [ "{{ pwd.stdout }}/:/opt/gondul" , "{{ pwd.stdout }}/data/grafana:/var/lib/grafana" ]
+ links: ["gondul-graphite-test:graphite" ]
+ ports: []
- name: "gondul-collector-test"
volumes: [ "{{ pwd.stdout }}/:/opt/gondul" ]
links: [ "gondul-db-test:db", "gondul-graphite-test:graphite" ]
@@ -28,5 +32,5 @@
ports: "{{ varnish_ports }}"
- name: "gondul-snmp-test"
volumes: [ "{{ pwd.stdout }}/:/opt/gondul" ]
- links: [ "gondul-db-test:db" ]
+ links: [ "gondul-db-test:db", "gondul-graphite-test:graphite" ]
ports: []
diff --git a/build/carbon.conf b/build/carbon.conf
index e93ca58..f11df9a 100644
--- a/build/carbon.conf
+++ b/build/carbon.conf
@@ -58,7 +58,7 @@ MAX_UPDATES_PER_SECOND = 500
# database files to all get created and thus longer until the data becomes usable.
# Setting this value high (like "inf" for infinity) will cause graphite to create
# the files quickly but at the risk of slowing I/O down considerably for a while.
-MAX_CREATES_PER_MINUTE = 50
+MAX_CREATES_PER_MINUTE = 500
LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_PORT = 2003
diff --git a/build/test/gondul-grafana-test.Dockerfile b/build/test/gondul-grafana-test.Dockerfile
new file mode 100644
index 0000000..b7b442b
--- /dev/null
+++ b/build/test/gondul-grafana-test.Dockerfile
@@ -0,0 +1,2 @@
+FROM grafana/grafana
+
diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl
index 566e48c..70cdf4b 100755
--- a/collectors/snmpfetchng.pl
+++ b/collectors/snmpfetchng.pl
@@ -8,6 +8,7 @@ use SNMP;
use Data::Dumper;
use lib '/opt/gondul/include';
use nms qw(convert_mac);
+use IO::Socket::IP;
SNMP::initMib();
SNMP::addMibDirs("/opt/gondul/mibs/StandardMibs");
@@ -55,6 +56,13 @@ sub mylog
printf STDERR "[%s] %s\n", $time, $msg;
}
+my $sock = IO::Socket::IP->new(
+ PeerHost => "$nms::config::graphite_host:$nms::config::graphite_port",
+ Timeout => 20,
+ ) or die "Cannot connect - $@";
+
+ $sock->blocking( 0 );
+
sub populate_switches
{
@switches = ();
@@ -110,6 +118,7 @@ sub callback{
my %nics;
my @nicids;
my $total = 0;
+ my $now_graphite = time();
for my $ret (@top) {
for my $var (@{$ret}) {
@@ -130,6 +139,16 @@ sub callback{
my %tree2;
for my $nic (@nicids) {
$tree2{'ports'}{$tree{$nic}{'ifName'}} = $tree{$nic};
+ for my $tmp_key (keys $tree{$nic}) {
+ my $path = "snmp.$switch{'sysname'}.$tree{$nic}{'ifName'}.$tmp_key";
+ my $value = $tree{$nic}{$tmp_key};
+ if ($value =~ m/^\d+$/) {
+ print $sock "$path $value $now_graphite\n";
+ } else {
+ mylog ("??? $path $value $now_graphite");
+ }
+
+ }
delete $tree{$nic};
}
for my $iid (keys %tree) {