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/snmpfetchng.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'collectors/snmpfetchng.pl') 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/snmpfetchng.pl | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'collectors/snmpfetchng.pl') 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 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/snmpfetchng.pl') 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