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

Issue #24 Limit size of Document. #42

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions lib/logstash/inputs/snmp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class LogStash::Inputs::Snmp < LogStash::Inputs::Base
# The SNMPv3 security level can be Authentication, No Privacy; Authentication, Privacy; or no Authentication, no Privacy
config :security_level, :validate => ["noAuthNoPriv", "authNoPriv", "authPriv"]

# Batch or single. HOw should metrics be provided
# some SNMP Walks are very large and it maybe disirable to split the metrics in to individule documents.
config :mode, :validate => ["single","batch"],:default => "batch"

BASE_MIB_PATH = ::File.join(__FILE__, "..", "..", "..", "mibs")
PROVIDED_MIB_PATHS = [::File.join(BASE_MIB_PATH, "logstash"), ::File.join(BASE_MIB_PATH, "ietf")].map { |path| ::File.expand_path(path) }

Expand Down Expand Up @@ -171,22 +175,32 @@ def run(queue)
end
end
end

unless result.empty?
metadata = {
"host_protocol" => definition[:host_protocol],
"host_address" => definition[:host_address],
"host_port" => definition[:host_port],
"host_community" => definition[:host_community],
}
result["@metadata"] = metadata

event = LogStash::Event.new(result)
decorate(event)
queue << event
end
metadata = {
"host_protocol" => definition[:host_protocol],
"host_address" => definition[:host_address],
"host_port" => definition[:host_port],
"host_community" => definition[:host_community],
}
if mode == "batch"
result = result.merge(result);
result["@metadata"] = metadata
event = LogStash::Event.new(result)
decorate(event)
queue << event
else if mode == "single" # split
result.each_pair do |k,v|
nresult = {}
nresult[k] = v
nresult["@metadata"] = metadata
event = LogStash::Event.new(nresult)
decorate(event)
queue << event
end # each
end # elseif
end # batch
end # unless
end

Stud.stoppable_sleep(@interval) { stop? }
end
end
Expand Down
2 changes: 1 addition & 1 deletion logstash-input-snmp.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'logstash-input-snmp'
s.version = '1.0.1'
s.version = '1.0.2'
s.licenses = ['Apache-2.0']
s.summary = "SNMP input plugin"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand Down