Created
October 2, 2009 17:50
-
-
Save FiXato/199937 to your computer and use it in GitHub Desktop.
Get list of hosts and details from the Anope services logs based on successful nickserv identifies.
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_details_by_identified_nicks.rb | |
# A script to get a list of hosts and details from the Anope services logs based on successful nickserv identifies. | |
require 'set' | |
SERVICES_LOGS_PATH = File.expand_path("~/services/data/logs/services.log*") | |
nicks = ARGV | |
if nicks.size == 0 | |
puts('Get a list of hosts and details from the Anope services logs based on successful nickserv identifies.') | |
abort('Usage: get_details_by_identified_nicks nick [nick-2] [..] [nick-n]') | |
end | |
used_usermasks = Hash.new {|h,k| h[k] = Set.new} | |
used_hosts_by_nickservnick = Hash.new {|h,k| h[k] = Set.new} | |
grep_strings = {} | |
nicks.each do |nick| | |
grep_string = "grep -i \"identified for nick #{nick}$\" #{SERVICES_LOGS_PATH}" | |
identified_lines_for_nick = `#{grep_string}`.squeeze(' ').strip.split("\n") | |
identified_lines_for_nick.each do |line| | |
date = line.slice!(0..line.index(']')).gsub('[','').gsub(']','') | |
cols = line.strip.split(' ') | |
origin = cols[0] | |
usermask = cols[1] | |
nickserv_nick = cols[-1] | |
nick_from_log = usermask.split('!')[0] | |
ident = usermask.split('!')[1].split('@')[0] | |
host = usermask.split('@')[1] | |
used_usermasks[nickserv_nick] << usermask | |
used_hosts_by_nickservnick[nickserv_nick] << host | |
grep_strings[nickserv_nick] = grep_string | |
end | |
end | |
puts "A list of nickserv nicks and their hosts:" | |
used_hosts_by_nickservnick.each do |nick,hosts| | |
puts "#{nick}:" | |
puts hosts.to_a.sort.map{|a|' %s' % a}.join("\n") | |
puts | |
end | |
puts '-' * 80 | |
puts "A list of nickserv nicks and their hostmasks:" | |
used_usermasks.each do |nick,hosts| | |
puts "#{nick} (`#{grep_strings[nick]}`):" | |
puts hosts.to_a.sort.map{|a|' %s' % a}.join("\n") | |
puts | |
end | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment