From bb862773d69bc5997bd1628a3f0505827e7cfe5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Lyngst=C3=B8l?= Date: Mon, 10 Apr 2017 14:06:23 +0200 Subject: TG17 stuff ? --- collectors/ping.pl | 6 +++--- collectors/snmpfetchng.pl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'collectors') diff --git a/collectors/ping.pl b/collectors/ping.pl index 6cb3bb5..2d181b3 100755 --- a/collectors/ping.pl +++ b/collectors/ping.pl @@ -20,7 +20,7 @@ my $q = $dbh->prepare("SELECT switch,sysname,host(mgmt_v4_addr) as ip,host(mgmt_ my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is not null and addr2 is not null;"); my $last = time(); -my $target = 0.7; +my $target = 1.5; # Hack to avoid starting the collector before graphite is up. sleep(5); my $sock = IO::Socket::IP->new( @@ -38,7 +38,7 @@ while (1) { $last = time(); # ping loopbacks my $ping = Net::Oping->new; - $ping->timeout(0.4); + $ping->timeout(0.9); $q->execute; my %ip_to_switch = (); @@ -78,10 +78,10 @@ while (1) { my $now_graphite = time(); while (my ($ip, $latency) = each %$result) { my $switch = $ip_to_switch{$ip}; - my $sysname = $sw_to_sysname{$switch}; if (!defined($switch)) { next; } + my $sysname = $sw_to_sysname{$switch}; if (!defined($latency)) { $drops += $dropped{$ip}; diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl index b961cac..df90138 100755 --- a/collectors/snmpfetchng.pl +++ b/collectors/snmpfetchng.pl @@ -61,7 +61,7 @@ sleep(5); my $sock = IO::Socket::IP->new( PeerHost => "$nms::config::graphite_host:$nms::config::graphite_port", Timeout => 20, - ) or die "Cannot connect - $@"; + ) or die "Cannot connect to graphite - $@"; $sock->blocking( 0 ); -- cgit v1.2.3 From 0b99608227d53c9eebb01fd7f98d1618cbb7a2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20Lyngst=C3=B8l?= Date: Sun, 16 Apr 2017 01:47:57 +0200 Subject: TG17 monster commit --- collectors/ping.pl | 4 ++-- collectors/snmpfetchng.pl | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'collectors') diff --git a/collectors/ping.pl b/collectors/ping.pl index 2d181b3..0ad0d1a 100755 --- a/collectors/ping.pl +++ b/collectors/ping.pl @@ -20,7 +20,7 @@ my $q = $dbh->prepare("SELECT switch,sysname,host(mgmt_v4_addr) as ip,host(mgmt_ my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is not null and addr2 is not null;"); my $last = time(); -my $target = 1.5; +my $target = 0.7; # Hack to avoid starting the collector before graphite is up. sleep(5); my $sock = IO::Socket::IP->new( @@ -38,7 +38,7 @@ while (1) { $last = time(); # ping loopbacks my $ping = Net::Oping->new; - $ping->timeout(0.9); + $ping->timeout(0.3); $q->execute; my %ip_to_switch = (); diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl index df90138..b1ee68a 100755 --- a/collectors/snmpfetchng.pl +++ b/collectors/snmpfetchng.pl @@ -7,7 +7,7 @@ use POSIX; use SNMP; use Data::Dumper; use lib '/opt/gondul/include'; -use nms qw(convert_mac); +use nms qw(convert_mac convert_decimal); use IO::Socket::IP; SNMP::initMib(); @@ -109,7 +109,7 @@ sub inner_loop } } mylog( "Polling " . @switches . " switches: $poll_todo"); - SNMP::MainLoop(10); + SNMP::MainLoop(6); } sub callback{ @@ -121,24 +121,32 @@ sub callback{ my @nicids; my $total = 0; my $now_graphite = time(); + my %tree2; for my $ret (@top) { for my $var (@{$ret}) { for my $inner (@{$var}) { $total++; my ($tag,$type,$name,$iid, $val) = ( $inner->tag ,$inner->type , $inner->name, $inner->iid, $inner->val); - if ($tag eq "ifPhysAddress") { + if ($tag eq "ifPhysAddress" or $tag eq "jnxVirtualChassisMemberMacAddBase") { $val = convert_mac($val); } $tree{$iid}{$tag} = $val; if ($tag eq "ifIndex") { push @nicids, $iid; } + if ($tag =~ m/^jnxVirtualChassisMember/) { + $tree2{'vcm'}{$tag}{$iid} = $val; + } + if ($tag =~ m/^jnxVirtualChassisPort/ ) { + my ($member,$lol,$interface) = split(/\./,$iid,3); + my $decoded_if = convert_decimal($interface); + $tree2{'vcp'}{$tag}{$member}{$decoded_if} = $val; + } } } } - my %tree2; for my $nic (@nicids) { $tree2{'ports'}{$tree{$nic}{'ifName'}} = $tree{$nic}; for my $tmp_key (keys $tree{$nic}) { @@ -175,7 +183,9 @@ sub callback{ or die "Couldn't unlock switch"; $dbh->commit; if ($total > 0) { - mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s."); + if ((time - $switch{'start'}) > 10) { + mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s."); + } } else { mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s - no data. Timeout?"); } -- cgit v1.2.3 From e04869bdf5e0057cd6642de70ecc088799e8d0a2 Mon Sep 17 00:00:00 2001 From: Kristian Date: Wed, 19 Apr 2017 17:29:21 +0200 Subject: ping: Remove graphite-pumping (will be moved) --- collectors/ping.pl | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'collectors') diff --git a/collectors/ping.pl b/collectors/ping.pl index 0ad0d1a..408f414 100755 --- a/collectors/ping.pl +++ b/collectors/ping.pl @@ -21,14 +21,6 @@ my $lq = $dbh->prepare("SELECT linknet,addr1,addr2 FROM linknets WHERE addr1 is my $last = time(); my $target = 0.7; -# Hack to avoid starting the collector before graphite is up. -sleep(5); -my $sock = IO::Socket::IP->new( - PeerHost => "$nms::config::graphite_host:$nms::config::graphite_port", - Timeout => 20, - ) or die "Cannot connect - $@"; - - $sock->blocking( 0 ); while (1) { my $now = time(); my $elapsed = ($now - $last); @@ -75,7 +67,6 @@ while (1) { $dbh->do('COPY ping (switch, latency_ms) FROM STDIN'); # date is implicitly now. my $drops = 0; - my $now_graphite = time(); while (my ($ip, $latency) = each %$result) { my $switch = $ip_to_switch{$ip}; if (!defined($switch)) { @@ -86,7 +77,6 @@ while (1) { if (!defined($latency)) { $drops += $dropped{$ip}; } - print $sock "ping.$sysname.ipv4 " . ($latency || "NaN") . " $now_graphite\n"; $latency //= "\\N"; $dbh->pg_putcopydata("$switch\t$latency\n"); } @@ -103,7 +93,6 @@ while (1) { next if (!defined($switch)); my $sysname = $sw_to_sysname{$switch}; - print $sock "ping.$sysname.ipv6 " . ($latency || "NaN") . " $now_graphite\n"; $latency //= "\\N"; $dbh->pg_putcopydata("$switch\t$latency\n"); } -- cgit v1.2.3 From 5bd19932a886eae468fea8bcb0e30c78f1d45141 Mon Sep 17 00:00:00 2001 From: Kristian Date: Wed, 19 Apr 2017 18:13:19 +0200 Subject: build: Add ping/snmp to new-scheme --- collectors/snmpfetchng.pl | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'collectors') diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl index b1ee68a..1d352a1 100755 --- a/collectors/snmpfetchng.pl +++ b/collectors/snmpfetchng.pl @@ -56,15 +56,6 @@ sub mylog printf STDERR "[%s] %s\n", $time, $msg; } -# Hack to avoid starting the collector before graphite is up. -sleep(5); -my $sock = IO::Socket::IP->new( - PeerHost => "$nms::config::graphite_host:$nms::config::graphite_port", - Timeout => 20, - ) or die "Cannot connect to graphite - $@"; - - $sock->blocking( 0 ); - sub populate_switches { @switches = (); @@ -149,31 +140,11 @@ sub callback{ for my $nic (@nicids) { $tree2{'ports'}{$tree{$nic}{'ifName'}} = $tree{$nic}; - for my $tmp_key (keys $tree{$nic}) { - 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"; - } - - } delete $tree{$nic}; } for my $iid (keys %tree) { for my $key (keys %{$tree{$iid}}) { $tree2{'misc'}{$key}{$iid} = $tree{$iid}{$key}; - my $localiid = $iid; - if ($localiid eq "") { - $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"; - } } } if ($total > 0) { -- cgit v1.2.3