Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'sequel'
- sql = 'show full processlist'
- db = Sequel.connect(:adapter=>'mysql', :host=>'localhost', :user=>'root', :password=>'yes')
- db_clients = Hash.new {|h,v| h[v] = Hash.new(0)}
- db_commands = []
- db.fetch(sql) do |p|
- client, port, command = p[:Host].split(':') << p[:Command]
- if client =~ /^192\./
- db_clients[client][command] += 1
- db_clients[client]['total'] += 1
- db_commands << command
- end
- end
- db_commands.uniq!
Add Comment
Please, Sign In to add comment