diff options
-rwxr-xr-x | collectors/snmpfetchng.pl | 26 | ||||
-rwxr-xr-x | web/api/public/dhcp-summary | 2 | ||||
-rwxr-xr-x | web/api/write/switches | 5 |
3 files changed, 22 insertions, 11 deletions
diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl index 02b75b8..cfa0d77 100755 --- a/collectors/snmpfetchng.pl +++ b/collectors/snmpfetchng.pl @@ -13,6 +13,8 @@ use IO::Socket::IP; use Scalar::Util qw(looks_like_number); use Time::HiRes qw(time); +use Try::Tiny; + SNMP::initMib(); SNMP::addMibDirs("/opt/gondul/data/mibs/StandardMibs"); SNMP::addMibDirs("/opt/gondul/data/mibs/JuniperMibs"); @@ -220,16 +222,20 @@ sub callback{ }, fields => { 'execution_time' => (time - $switch{'start'}) }, }); - my $cv = AE::cv; - $influx->write( - database => $nms::config::influx_database, - data => [@influx_tree], - on_success => $cv, - on_error => sub { - $cv->croak("Failed to write data: @_"); - } - ); - $cv->recv; + try { + my $cv = AE::cv; + $influx->write( + database => $nms::config::influx_database, + data => [@influx_tree], + on_success => $cv, + on_error => sub { + $cv->croak("Failed to write data: @_"); + } + ); + $cv->recv; + } catch { + warn "caught error: $_"; + }; if ((time - $switch{'start'}) > 10) { mylog( "Polled $switch{'sysname'} in " . (time - $switch{'start'}) . "s."); diff --git a/web/api/public/dhcp-summary b/web/api/public/dhcp-summary index 18a7f69..5245f34 100755 --- a/web/api/public/dhcp-summary +++ b/web/api/public/dhcp-summary @@ -6,7 +6,7 @@ use nms::web; nms::web::setwhen('2h'); -my $q2 = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp where $nms::web::when;"); +my $q2 = $nms::web::dbh->prepare("select count(distinct data->>'clientmac') as clients from metrics where $nms::web::when;"); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { $nms::web::json{'dhcp'} = $ref; diff --git a/web/api/write/switches b/web/api/write/switches index 1f91d48..e0ee950 100755 --- a/web/api/write/switches +++ b/web/api/write/switches @@ -63,6 +63,11 @@ foreach my $tmp2 (@tmp) { } else { %placement = %{convertplace($switch{'placement'})}; } + if (defined($switch{'tags'})) { + # MY GOD I HATE THIS + # But I'm too lazy to improve it more for now. + $switch{'tags'} = "[". join(",", map { "\"".$_."\"" } @{$switch{'tags'}})."]"; + } my ($x1,$x2,$y1,$y2); $x1 = $placement{'x1'}; $y1 = $placement{'y1'}; |