Skip to content

Instantly share code, notes, and snippets.

@FiXato
Created October 3, 2009 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FiXato/200277 to your computer and use it in GitHub Desktop.
Save FiXato/200277 to your computer and use it in GitHub Desktop.
Gets a list of nicks from the Anope services logs that have successfully been identified for by the given hosts.
#!/usr/bin/env ruby
# get_identified_nicks_by_hosts.rb
# Gets a list of nicks from the Anope services logs that have successfully been identified for by the given hosts.
require 'set'
SERVICES_LOGS_PATH = "~/services/data/logs/services.log*"
if ARGV.size > 0
hosts = ARGV
else
hosts = ARGF.readlines
end
if hosts.size == 0
puts('Get a list of nicks from the Anope services logs that have successfully been identified for by the given hosts.')
abort('Usage: get_identified_nicks_by_hosts host [host-2] [..] [host-n]')
end
used_nicks = Set.new
hosts.each do |host|
host.strip!
grep_string = "grep -i \"#{host} identified for nick\" #{SERVICES_LOGS_PATH}"
`#{grep_string}`.squeeze(' ').strip.split("\n").each do |line|
line.slice!(0..line.index(']')).gsub('[','').gsub(']','')
used_nicks << line.strip.split(' ')[-1]
end
end
puts used_nicks.to_a.sort.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment