aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcollectors/snmpfetchng.pl26
1 files changed, 16 insertions, 10 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.");