Skip to content
Open
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
23 changes: 19 additions & 4 deletions perfsonar-logstash/perfsonar-logstash/ruby/pscheduler_trace.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
def filter(event)
paths = event.get("[result][paths]")
ip_version = event.get("[test][spec][ip-version]")
if paths and paths.respond_to?('length') and paths.length() > 0 then
#only look at first path for now, multipath is not this use case
hop_ips = []
Expand All @@ -14,8 +15,15 @@ def filter(event)
hop_ips.push(hop["ip"])
success_count += 1
else
# Add zero (non-global) address to indicate missing info for hop
if ip_version == 4
hop_ips.push("0.0.0.0")
end
if ip_version == 6
hop_ips.push("::")
end
error_count += 1
next
#next
end

#ASN
Expand All @@ -27,6 +35,11 @@ def filter(event)
if hop["as"]["owner"] then
hop_asos.push(hop["as"]["owner"])
end
else
# Add zero number (non-valid) number to indicate missing info for hop
hop_asns.push(0)
# Add "not-available" to indicate missing info for hop
hop_asos.push("n/a")
end

#Path MTU
Expand All @@ -44,9 +57,11 @@ def filter(event)
event.set("[@metadata][result][hop][success_count]", success_count)
event.set("[@metadata][result][hop][error_count]", error_count)
event.set("[@metadata][result][hop][ip]", hop_ips)
event.set("[@metadata][result][hop][ip_str]", hop_ips.join(" "))
# Apply traditional * for missing hop
event.set("[@metadata][result][hop][ip_str]", hop_ips.join(" ").gsub(/^0.0.0.0 /, "* ").gsub(/ 0.0.0.0 /, " * ").gsub(/ 0.0.0.0$/," *").gsub(/^:: /, "* ").gsub(/ :: /, " * ").gsub(/ ::$/," *"))
event.set("[@metadata][result][hop][as_number]", hop_asns)
event.set("[@metadata][result][hop][as_number_str]", hop_asns.join(" "))
# Apply traditional * for missing hop
event.set("[@metadata][result][hop][as_number_str]", hop_asns.join(" ").gsub(/^0 /, "* ").gsub(/ 0 /, " * ").gsub(/ 0$/," *"))
event.set("[@metadata][result][hop][as_organization]", hop_asos)
event.set("[@metadata][result][hop][as_organization_str]", hop_asos.join(" "))
if path_mtu then
Expand All @@ -56,4 +71,4 @@ def filter(event)
end

return [event]
end
end
Loading