Class: Server

Inherits:
Object
  • Object
show all
Defined in:
lib/gl_tail/server.rb

Overview

gl_tail.rb - OpenGL visualization of your server traffic Copyright 2007 Erlend Simonsen <[email protected]>

Licensed under the GNU General Public License v2 (see LICENSE)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Server

Returns a new instance of Server.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gl_tail/server.rb', line 11

def initialize(options)
  @name = options[:name] || options[:host]
  @host = options[:host]
  @color = options[:color] || [1.0, 1.0, 1.0, 1.0]
  @parser = Parser.registry[ options[:parser] ] || Parser.registry[ :apache ]
  @blocks = options[:blocks]
  @max_size = 1.0

  # instantiate the parser
  @parser = @parser.new( self )

end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



8
9
10
# File 'lib/gl_tail/server.rb', line 8

def color
  @color
end

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/gl_tail/server.rb', line 8

def host
  @host
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/gl_tail/server.rb', line 8

def name
  @name
end

#parserObject (readonly)

Returns the value of attribute parser.



8
9
10
# File 'lib/gl_tail/server.rb', line 8

def parser
  @parser
end

Instance Method Details

#add_activity(options = { }) ⇒ Object

block, message, size



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gl_tail/server.rb', line 25

def add_activity(options = { })
  size = $CONFIG.min_blob_size
  if options[:size]
    size = options[:size].to_f
    @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]])
end

#add_event(options = { }) ⇒ Object

block, message



38
39
40
# File 'lib/gl_tail/server.rb', line 38

def add_event(options = { })
  block = @blocks[options[:block]].add_event( { :name => @name, :color => @color, :size => $CONFIG.min_blob_size}.update(options) ) if (options[:block] && @blocks[options[:block]])
end

#updateObject



42
43
44
# File 'lib/gl_tail/server.rb', line 42

def update
  @max_size = @max_size * 0.99 if(@max_size * 0.99 > 1.0)
end