Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

gltail ver 0

  • Loading branch information...
commit d2de5405360f811356e73f598db6d581e1941d5c 1 parent 2b1a87c
@brownman authored
View
1  Gemfile
@@ -0,0 +1 @@
+gemspec
View
2  bin/gl_tail
@@ -108,4 +108,6 @@ end
config = GlTail::Config.parse_yaml(file)
engine = GlTail::Engine.new(config)
+puts "1.config.parse-yaml"
+puts "2.engine.new.start"
engine.start
View
116 bin/gltail1.rb
@@ -0,0 +1,116 @@
+#!/usr/bin/env ruby
+# gl_tail.rb - OpenGL visualization of your server traffic
+# Copyright 2007 Erlend Simonsen <mr@fudgie.org>
+#
+# Licensed under the GNU General Public License v2 (see LICENSE)
+
+$DBG=1
+$VRB=1
+
+file = 'gl_tail.yaml'
+
+ARGV.each do |arg|
+ case arg
+ when '-help','--help','-h'
+ puts "gl_tail [--help|-h] [--parsers|-p] [--verbose|-v] [--debug|-d] [--debug-ssh|-ds] [configfile]",
+ '[--help|-h] This help screen',
+ '[--version] Print version information',
+ '[--new|-n] Initialize config specified with default options',
+ '[--parsers|-p] List available parsers',
+ '[--options|-o] List available configuration options',
+ '[--quiet|-q] Turn off runtime information',
+ '[--debug|-d] Turn on debugging',
+ '[--debug-ssh|-ds] Only debug SSH',
+ '[configfile] The YAML config file you wish to load (default = config.yaml)'
+ exit
+ when '-version', '--version'
+ @print = :version
+ when '-new', '--new', '-n'
+ @init_config = true
+ when '-parsers','--parsers', '-p'
+ @print = :parsers
+ when '-debug', '--debug', '-d'
+ $DBG=1
+ when '-quiet', '--quiet', '-q'
+ $VRB=0
+ when '-debug-ssh', '--debug-ssh', '-ds'
+ $DBG=2
+ when '--options', '-o'
+ @print = :options
+ else
+ if(File.exist?(arg) && File.file?(arg))
+ file = arg
+ else
+ if defined? @init_config
+ file = arg
+ else
+ file = "#{arg}.yaml"
+ end
+ end
+ end
+end
+
+if defined? @init_config
+ require 'ftools'
+
+ if File.directory? file
+ puts "'#{file}' is a directory, not overwriting."
+ exit
+ end
+
+ if File.exist? file
+ File.move(file, file + ".bak")
+ puts "Existing configuration moved to '#{file + '.bak'}'"
+ end
+
+ File.copy(File.dirname(__FILE__) + '/../dist/config.yaml', file)
+ puts "Example configuration installed in '#{file}'"
+ puts "Please edit it and change server and login information."
+ exit
+elsif !File.exist?(file)
+ puts "Configuration file not found. Either supply the path to a config file as an argument to gl_tail,",
+ "or create a new one with:",
+ " gl_tail --new #{file}"
+ exit
+end
+
+require File.dirname(__FILE__) + '/../lib/gl_tail.rb'
+
+if defined? @print
+ case @print
+ when :parsers
+ puts "Supported Parsers [" + Parser::registry.keys.sort { |a,b| a.to_s <=> b.to_s }.collect{ |p| ":#{p.to_s}"}.join(", ") + "]"
+ when :options
+ require 'pp'
+ puts "Supported Configuration Options"
+
+ pp(GlTail::CONFIG_OPTIONS)
+ when :version
+ puts "gl_tail v" + GlTail::VERSION + " by Erlend Simonsen <mr@fudgie.org> - http://www.fudgie.org"
+ end
+ exit
+end
+
+
+######## TRAP Interrupts and exit cleanly ########
+
+if RUBY_PLATFORM.split('-',2).last != "mswin32"
+ trap("HUP") { exit }
+ trap("INT") { exit }
+ trap("QUIT") { exit }
+ trap("ABRT") { exit }
+ trap("KILL") { exit }
+ trap("TERM") { exit }
+ #trap("USR1") { $VRB >= 1 ? $VRB = 0 : $VRB += 1; puts "verbose toggled" }
+ trap("USR2") { $DBG >= 2 ? $DBG = 0 : $DBG += 1; puts "debug level toggled" }
+end
+
+config = GlTail::Config.parse_yaml(file)
+
+engine = GlTail::Engine.new(config)
+puts "ofer"
+require 'rubygems'
+require 'ap'
+require 'pp'
+
+engine.start
View
44 dist/config.yaml
@@ -1,28 +1,35 @@
# Only use spaces to indent, not tabs
servers:
- site1:
- host: foobar.com
- user: foo
- password: topsecret
- command: tail -f -n0
- files: /var/log/apache/access_log
- parser: apache
- color: 0.2, 1.0, 0.2, 1.0
rails:
- host: anotherfunsite.com
- user: anotherfunuser
- port: 222
- command: tail -f -n0
- files: /var/www/apps/funapp/current/log/production.log
- parser: rails
- color: 0.2, 0.2, 1.0, 1.0
- dev:
- host: clockingit.com
+ host: 0.0.0.0
source: local
- files: /var/www/clockingit/logs/production.log
+ files: /home/dao01/RAILS/sample_app/log/development.log
parser: rails
color: 0.2, 0.2, 1.0, 1.0
+
+# site1:
+# host: foobar.com
+# user: foo
+# password: topsecret
+# command: tail -f -n0
+# files: /var/log/apache/access_log
+# parser: apache
+# color: 0.2, 1.0, 0.2, 1.0
+# rails:
+# host: anotherfunsite.com
+# user: anotherfunuser
+# port: 222
+# command: tail -f -n0
+# files: /var/www/apps/funapp/current/log/production.log
+# parser: rails
+# color: 0.2, 0.2, 1.0, 1.0
+# dev:
+# host: clockingit.com
+# source: local
+# files: /var/www/clockingit/logs/production.log
+# parser: rails
+# color: 0.2, 0.2, 1.0, 1.0
config:
dimensions: 1200x600
min_blob_size: 0.004
@@ -161,3 +168,4 @@ config:
resolver:
reverse_ip_lookups: true
reverse_timeout: 0.5
+
View
4 lib/gl_tail/activity.rb
@@ -9,6 +9,7 @@ class Activity
attr_accessor :message, :color, :size, :type, :body, :shape, :gl_list
def initialize(message, x, y, z, color, size, type = 0)
+ puts "activity.rb: init: #{message}"
@shape = @body = nil
@message = message
@x, @y, @z = x, y, z
@@ -99,6 +100,7 @@ def render(engine)
glDisable(GL_LINE_SMOOTH);
glEndList()
+ puts "activity.rb: blobstore.put-gl-list:{@gl_list}"
BlobStore.put((@size * 1000).to_i, @gl_list)
end
end
@@ -131,7 +133,7 @@ def render(engine)
glRasterPos(0.0, 0.0)
@text_list ||= engine.render_string(@message, false)
-
+ puts "add text: #{@text_list}"
glCallList(@text_list)
end
View
2  lib/gl_tail/blob_store.rb
@@ -45,6 +45,8 @@ def self.prune(since)
end
def self.empty
+ puts @store.inspect
+
@store.keys.each do |k|
glDeleteLists(@store[k], 1)
@store.delete k
View
2  lib/gl_tail/block.rb
@@ -98,7 +98,9 @@ def render(engine, num)
end
def add_activity(options = { })
+
return unless options[:name]
+ puts "block.rb: add_activity: #{options}"
x = nil
unless @elements[options[:name]]
x = Element.new(self, options[:name], @color || options[:color] )
View
3  lib/gl_tail/config/configurable.rb
@@ -45,7 +45,8 @@ def config_rewrite_color(v)
end
def self.included(receiver)
+ puts "#{receiver}"
receiver.extend ClassMethods
end
end
-end
+end
View
6 lib/gl_tail/element.rb
@@ -43,7 +43,8 @@ def initialize(block, name, color, start_position = nil)
@last_number = nil
end
- def add_activity(message, color, size, type, real_size)
+ def add_activity(message, color, size, type, real_size)
+ puts "element.rb: add_activity_item(): message,type:#{message}#{type}"
@bar_color[0] = @bar_color[0] + (@color[0] - @bar_color[0]) / 5
@bar_color[1] = @bar_color[1] + (@color[1] - @bar_color[1]) / 5
@bar_color[2] = @bar_color[2] + (@color[2] - @bar_color[2]) / 5
@@ -61,6 +62,7 @@ def add_activity(message, color, size, type, real_size)
end
def add_event(message, color, update_stats)
+ puts "element.rb: add event #{messages} #{update_stats} #{color}"
@pending.push Item.new(message, 0.01, color, 2)
if update_stats
@messages += 1
@@ -161,7 +163,7 @@ def render(engine, options = { })
if d.abs < 0.001
@y = @wy
else
- @y += d / 20
+ @y += d / 20000
end
d = @wx - @x
View
9 lib/gl_tail/engine.rb
@@ -10,6 +10,7 @@ class Engine
attr_accessor :space
def render_string(text, cache=true, pos=0)
+ puts "engine.rb: render_string(): text:#{text} pos:#{pos}"
FontStore.render_string(self, text, cache, pos)
end
@@ -291,15 +292,17 @@ def initialize(config)
@left_left = @left_right = @right_left = @right_right = 0.0 # TODO: Why is draw called before these are set by reshape?
if $PHYSICS
+ puts "glut.init: env has physics? #{$PHYSICS}"
@space = CP::Space.new
@space.damping = 0.89
- @space.gravity = CP::Vec2.new(0, -85)
+ @space.gravity = CP::Vec2.new(0, -1)
@space.iterations = 2
@space.elastic_iterations = 0
end
end
def start
+ puts '3. glut: Init window + register key'
glutInit()
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
@@ -341,13 +344,13 @@ def start
glEnable(GL_COLOR_MATERIAL)
glEnable(GL_NORMALIZE)
-
+ puts 'FontStore. generate font store'
FontStore.generate_font
glBlendFunc(GL_ONE, GL_ONE) # Make text transparent
@since = glutGet(GLUT_ELAPSED_TIME)
-
+puts '4. @config.init'
@config.init
glutMainLoop()
View
8 lib/gl_tail/item.rb
@@ -4,12 +4,14 @@
# Licensed under the GNU General Public License v2 (see LICENSE)
#
-class Item
+class Item #circle shape
attr_accessor :message, :size, :color, :type
def initialize(message, size, color, type)
- @message = message
- @size = size
+ puts "item.rb init: #{size} #{type} #{message}"
+ @message = message
+
+ @size = size*10
@color = color
@type = type
end
View
1  lib/gl_tail/parser.rb
@@ -41,6 +41,7 @@ def add_activity( opts = {} )
end
def add_event( opts = {} )
+ puts "add_event #{opts}"
@source.add_event( opts )
end
end
View
1  lib/gl_tail/parsers/rails.rb
@@ -7,6 +7,7 @@
# Parser which handles Rails access logs
class RailsParser < Parser
def parse( line )
+ puts "parser: rails.rb: parse #{line}"
if matchdata = /^Started (GET|PUT|DELETE|POST) \"([\/A-Za-z0-9\-_]+)\" for (\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b)/.match(line)
_, method, url, host = matchdata.to_a
end
View
5 lib/gl_tail/server.rb
@@ -9,6 +9,7 @@ class Server
def initialize(options)
+ puts "Server.init with options: #{options}"
@name = options[:name] || options[:host]
@host = options[:host]
@color = options[:color] || [1.0, 1.0, 1.0, 1.0]
@@ -18,6 +19,9 @@ def initialize(options)
# instantiate the parser
@parser = @parser.new( self )
+require 'ap'
+puts " line 22"
+ap @parser
end
@@ -29,6 +33,7 @@ def add_activity(options = { })
@max_size = size if size > @max_size
size = $CONFIG.min_blob_size + ((size / @max_size) * ($CONFIG.max_blob_size - $CONFIG.min_blob_size))
options[:size] = size
+
end
block = @blocks[options[:block]].add_activity( { :name => @name, :color => @color, :size => $CONFIG.min_blob_size }.update(options) ) if (options[:block] && @blocks[options[:block]])
View
2  lib/gl_tail/sources/base.rb
@@ -33,10 +33,12 @@ def update
end
def add_activity( opts = {} )
+ puts "add activity: #{opts}"
@config.add_activity( self, opts )
end
def add_event( opts = {} )
+ puts "add event: #{opts}"
@config.add_event( self, opts )
end
end
View
1  lib/gl_tail/sources/local.rb
@@ -15,6 +15,7 @@ def init
end
def process
+ puts '@log.get last line + parse.line'
@log.tail(1) { |line|
parser.parse(line)
}
View
1  posix
@@ -0,0 +1 @@
+<breakpoint file="/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/element.rb" line="49" threadId="1"/>++vim-ruby-debugger separator++<variables><variable name="self" kind="local" value="#&lt;Element:0xae9c748&gt;" type="Element" hasChildren="true" objectId="+0x574e3a4"/><variable name="color" kind="local" value="Array (4 element(s))" type="Array" hasChildren="true" objectId="+0x543d9e8"/><variable name="message" kind="local"/><variable name="real_size" kind="local" value="0.004" type="Float" hasChildren="false" objectId="+0x5454e38"/><variable name="size" kind="local" value="0.004" type="Float" hasChildren="false" objectId="+0x5454e38"/><variable name="type" kind="local" value="0" type="Fixnum" hasChildren="false" objectId="+0x1"/></variables>++vim-ruby-debugger separator++<frames><frame no='1' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/element.rb' line='49' current='true' /><frame no='2' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/block.rb' line='114' /><frame no='3' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/config.rb' line='176' /><frame no='4' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/sources/base.rb' line='36' /><frame no='5' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/parser.rb' line='40' /><frame no='6' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/parsers/rails.rb' line='16' /><frame no='7' file='/home/dao01/.rvm/gems/ruby-1.9.1-p376/gems/file-tail-1.0.5/lib/file/tail.rb' line='19' /><frame no='8' file='/home/dao01/.rvm/gems/ruby-1.9.1-p376/gems/file-tail-1.0.5/lib/file/tail.rb' line='269' /><frame no='9' file='/home/dao01/.rvm/gems/ruby-1.9.1-p376/gems/file-tail-1.0.5/lib/file/tail.rb' line='249' /><frame no='10' file='/home/dao01/.rvm/gems/ruby-1.9.1-p376/gems/file-tail-1.0.5/lib/file/tail.rb' line='246' /><frame no='11' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/sources/local.rb' line='18' /><frame no='12' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/config.rb' line='140' /><frame no='13' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/engine.rb' line='357' /><frame no='14' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/engine.rb' line='137' /><frame no='15' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/lib/gl_tail/engine.rb' line='353' /><frame no='16' file='/home/dao01/OPENGL/RUBY/gltail3/gltail/bin/gl_tail' line='111' /></frames>
Please sign in to comment.
Something went wrong with that request. Please try again.