Created
October 3, 2009 00:31
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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