diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-10-22 23:01:57 +0200 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-10-22 23:01:57 +0200 |
commit | 0f26dbca2a8ba416cb38002a9463cf80f27487c3 (patch) | |
tree | 6b4dc2874a855db47dcf9ad62ffce97b06660c06 /collectors | |
parent | 57c27b76fbb7dcc7477a573585f1366364bccdd6 (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.
Diffstat (limited to 'collectors')
-rwxr-xr-x | collectors/snmpfetchng.pl | 19 |
1 files changed, 19 insertions, 0 deletions
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) { |