There are of course several ways to do this. Here are some meanderings.

1) Use God's syslog output and rsyslog's omsnmp module. Done with a little
bit of config of rsyslog

2) Write some code
 a) gem install snmp
 b) Read http://snmplib.rubyforge.org/svn/trunk/lib/snmp/manager.rb
 c) Create something like this in the config file (note: not tested, just
out of my head)
# Define the custom Syslogger event contact handler
require 'snmp'
module God
  module Contacts
    class SNMPTrap < Contact
      class << self
        attr_accessor :level, :message
      end

      def valid?
        valid = true
        valid &= complain("Attribute 'level' must be specified", self)
unless arg(:level)
        valid
      end

      attr_accessor :level, :message

      def notify(message, time, priority, category, host)
        SNMPTrapObjectThingy.doSomething(arg(:level), arg(:message) ||
message)
      rescue Object => e
        applog(nil, :info, "SNMPTrap failed")
        applog(nil, :debug, e.backtrace.join("\n"))
      end
    end
  end
end

God.contact(:SNMPTrap) do |c|
  c.name = 'Log_Flapping'
  c.message = "Thing is restarting too quickly"
  c.level = :warn
end

God.watch do |w|
  w.lifecycle do |on|
    on.condition(:flapping) do |c|
      c.notify = 'Log_Flapping'
    end
  end
end

On Tue, Sep 4, 2012 at 9:57 PM, rubymono <[email protected]> wrote:

> Greetings,
>
> I am interested in having rubygod send SNMP traps on events, has anyone
> else implemented this or have any suggestions on how best to implement?
> Thanks for any thoughts
>
> --
> You received this message because you are subscribed to the Google Groups
> "god.rb" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/god-rb/-/ifQOrhgC-ScJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/god-rb?hl=en.
>



-- 
chris -at- microcozm -dot- net
== If you wish to make an apple pie from scratch, you must first invent the
universe. - Carl Sagan
=== My crypto keys: http://www.microcozm.net/~ccosby/keys/

-- 
You received this message because you are subscribed to the Google Groups 
"god.rb" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/god-rb?hl=en.

Reply via email to