Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trap SNMP events in riemann #613

Closed
qnick opened this issue Oct 9, 2015 · 8 comments
Closed

Trap SNMP events in riemann #613

qnick opened this issue Oct 9, 2015 · 8 comments

Comments

@qnick
Copy link

qnick commented Oct 9, 2015

At 2013 @aphyr wrote "there could be an snmp server". Is there any chance to see it?
What should I do to send snmp traps into riemann server?

@aphyr
Copy link
Collaborator

aphyr commented Oct 9, 2015

Traps... Dunno if anyone has done that yet. Google reports several SNMP pollers though.
On Oct 9, 2015 7:36 AM, qnick notifications@github.com wrote:At 2013 @aphyr wrote "there could be an snmp server". Is there any chance to see it?
What should I do to send snmp traps into riemann server?

—Reply to this email directly or view it on GitHub.

@bfritz
Copy link
Contributor

bfritz commented Oct 9, 2015

@qnick Haven't seen anything like that published, but I suspect you could build a snmp4j trap listener, something like this, and wrap it with a bit of clojure that converts the trap into a Riemann event. The graphite transport has an example of creating and event.

Edit: herark by @c-garcia might be a better starting point for Riemann integration than native snmp4j.

@pyr
Copy link
Contributor

pyr commented Oct 9, 2015

The collectd snmp plugin will emit events on traps (and will also poll if you want)

On October 9, 2015 5:41:43 PM CEST, Kyle Kingsbury notifications@github.com wrote:

Traps... Dunno if anyone has done that yet. Google reports several SNMP
pollers though.
On Oct 9, 2015 7:36 AM, qnick notifications@github.com wrote:At 2013
@aphyr wrote "there could be an snmp server". Is there any chance to
see it?
What should I do to send snmp traps into riemann server?

—Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub:
#613 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@faxm0dem
Copy link
Contributor

faxm0dem commented Oct 9, 2015

Other idea: using snmptrapd and syslog-ng

@pyr
Copy link
Contributor

pyr commented Oct 9, 2015

Yes, that would be the most elegant and low-maintenance way.

On October 9, 2015 9:05:51 PM CEST, Fabien Wernli notifications@github.com wrote:

Other idea: using snmptrapd and syslog-ng


Reply to this email directly or view it on GitHub:
#613 (comment)

Sent from my Android device with K-9 Mail. Please excuse my brevity.

@qnick
Copy link
Author

qnick commented Oct 10, 2015

Ok, thank you. I decide to write python script for redirecting events from snmptrapd to riemann.

#!/usr/bin/env python

import sys
import logging
from riemann_client.transport import UDPTransport
from riemann_client.client import QueuedClient
logging.basicConfig(filename='/tmp/snmp.log', level=logging.INFO)
tags = ["snmp"]
ttl = 120

host = raw_input()
ip = raw_input()

with QueuedClient(UDPTransport("localhost", 5555)) as client:
  for line in sys.stdin:
    logging.debug(line)
    oid , val = line.split(None,1)
    try:
      val = val.strip().strip('"')
      client.event(service = oid, metric_f = float(val), host = host, tags = tags, ttl = ttl)
    except ValueError:
      logging.warn("Cannot convert %s to float", val)
  client.flush()

It seems to work well.

@faxm0dem
Copy link
Contributor

@pyr how do you configure collectd-snmp to listen for traps?

@pyr
Copy link
Contributor

pyr commented Feb 8, 2016

@faxm0dem turns out you can't
closing this as a solution was found.

@pyr pyr closed this as completed Feb 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants