AnyEvent-Graphite

 view release on metacpan or  search on metacpan

lib/AnyEvent/Graphite/SNMPAgent.pm  view on Meta::CPAN


        # in this kind of context it's not clear what would be better to do with errors, here.
        next unless $session;

        # if you don't set a timeout, you can fill up your queues of outstanding processes
        # protects against 'lame' servers
        $session->timeout($self->{timeout});

        for my $metric (@{$self->{hosts}{$host}}) {
            $session->get_request( 
                -varbindlist => [$metric->{oid}], 
                -callback => sub {
                    my ($session) = @_;
                    my $result = $session->var_bind_list();
                    my $value = $result->{$metric->{oid}};
                    if(!defined($value)) {
                        warn "undefined reply from $host" . ":" . "$metric->{oid}: " . $session->error();
                    } else {
                        if($metric->{filter}) {
                            $value = $metric->{filter}->($value);
                        }
                        $self->{graphite}->send($metric->{graphite_key}, $value);
                    }
                });



( run in 0.640 second using v1.01-cache-2.11-cpan-d7f47b0818f )