Class: SnmpMonitoring

Inherits:
Object
  • Object
show all
Defined in:
lib/monitor/client/snmp/snmp_monitoring.rb

Constant Summary collapse

TESTOP =
["=", "!=", "<", ">"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(st, oidref_name, op, th, sev) ⇒ SnmpMonitoring

Returns a new instance of SnmpMonitoring.



8
9
10
11
12
13
14
15
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 8

def initialize (st, oidref_name, op, th, sev)
	@state=st
   @oidref=oidref_name
   @oper=op
   @threshold=th
		#index of $status
 @severity=sev
end

Instance Attribute Details

#oidrefObject

Returns the value of attribute oidref.



4
5
6
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 4

def oidref
  @oidref
end

#thresholdObject

Returns the value of attribute threshold.



4
5
6
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 4

def threshold
  @threshold
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 25

def active?()
	return @state==1
end

#get_stateObject



21
22
23
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 21

def get_state()
	return @state
end

#operObject



17
18
19
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 17

def oper()
	return TESTOP[@oper]
end

#raw_severityObject



51
52
53
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 51

def raw_severity()
	return @severity
end

#severityObject



55
56
57
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 55

def severity()
	return $status[@severity]
end

#value(manager, node) ⇒ Object

compute the value



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 31

def value(manager, node)
	if node != nil
		strcalc=$oid_refs[@oidref].value.dup
		strcalctp=strcalc.split(/\+/)
		for oidref in strcalctp
			begin
				response=manager.get(oidref)
			rescue Exception => msg
				$log.error("Exception could not request get SNMP for #{oidref}: #{msg}")
				raise
				return
			end
     				response.each_varbind do |vb|
				strcalc.gsub!(oidref,vb.value.to_s)
	   		end
		end
	  return strcalc
	end
end