Skip to content

Instantly share code, notes, and snippets.

@tsubauaaa
Created November 8, 2016 15:35
Show Gist options
  • Save tsubauaaa/b3044215e060fca56fc4b765216f2202 to your computer and use it in GitHub Desktop.
Save tsubauaaa/b3044215e060fca56fc4b765216f2202 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'net-snmp2'
Net::SNMP.init
Net::SNMP::Debug.logger = Logger.new(STDOUT)
session = Net::SNMP::TrapSession.open(
peername: 'localhost:199',
version: '2c',
community: 'public'
)
probe_oid = '.1.3.6.1.4.1.2021.2'
session.inform(
oid: probe_oid,
uptime: nil,
varbinds: [
{ oid: probe_oid + '.1', value: trigger_hostname },
{ oid: probe_oid + '.2', value: severity },
{ oid: probe_oid + '.3', value: trigger_name },
{ oid: probe_oid + '.4', value: item_value },
{ oid: probe_oid + '.5', value: trigger_hostgroup_name },
{ oid: probe_oid + '.6', value: application_name },
{ oid: probe_oid + '.7', value: server_name }
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment