Class: Service

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proto, p, n = "?", s = 1, sev = 0) ⇒ Service

Returns a new instance of Service.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/service.rb', line 5

def initialize (proto, p, n="?", s=1, sev=0)
    @protocol=proto
    @port=p
    @name=n
if (s==1) || (s==true)
   @monitor=1
else
   @monitor=0
end
    @severity = sev
end

Instance Attribute Details

#monitorObject

Returns the value of attribute monitor.



3
4
5
# File 'lib/service.rb', line 3

def monitor
  @monitor
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/service.rb', line 3

def name
  @name
end

#portObject

Returns the value of attribute port.



3
4
5
# File 'lib/service.rb', line 3

def port
  @port
end

#protocolObject (readonly)

Returns the value of attribute protocol.



2
3
4
# File 'lib/service.rb', line 2

def protocol
  @protocol
end

#severityObject

Returns the value of attribute severity.



3
4
5
# File 'lib/service.rb', line 3

def severity
  @severity
end

Instance Method Details

#monitored?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/service.rb', line 32

def monitored?()
return @monitor==1
end

#set_protocol(str) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/service.rb', line 17

def set_protocol(str)
case str.downcase()
when "tcp"
	@protocol="tcp"
when "udp"
	@protocol="udp"
else
	puts "error setting protocol"
end
end

#switch_stateObject



28
29
30
# File 'lib/service.rb', line 28

def switch_state()
@state ^=1
end