Class: WmiMonitoring

Inherits:
Object
  • Object
show all
Defined in:
lib/monitor/client/wmi/wmi_monitoring.rb

Constant Summary collapse

TESTOP =
["=", "!=", "<", ">","Contain","Not contain"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(st, wmiref_name, op, th, sev) ⇒ WmiMonitoring

Returns a new instance of WmiMonitoring.



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

def initialize (st, wmiref_name, op, th, sev)
	@state=st
	@wmiref=wmiref_name
	@oper=op
	@value=th
	#index of $status
	@severity=sev
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/monitor/client/wmi/wmi_monitoring.rb', line 4

def value
  @value
end

#wmirefObject

Returns the value of attribute wmiref.



4
5
6
# File 'lib/monitor/client/wmi/wmi_monitoring.rb', line 4

def wmiref
  @wmiref
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/monitor/client/wmi/wmi_monitoring.rb', line 25

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

#get_stateObject



21
22
23
# File 'lib/monitor/client/wmi/wmi_monitoring.rb', line 21

def get_state()
	return @state
end

#operObject



17
18
19
# File 'lib/monitor/client/wmi/wmi_monitoring.rb', line 17

def oper()
	return TESTOP[@oper]
end

#raw_severityObject



53
54
55
# File 'lib/monitor/client/wmi/wmi_monitoring.rb', line 53

def raw_severity()
	return @severity
end

#request(node) ⇒ Object

compute the value



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

def request(node)
	if node != nil
		wmiref=$wmi_refs[@wmiref].value.dup
		if node.("wmi")
			begin
 	 				, password = node.("wmi")
				resultt=wmi_request(, password, node.ip, wmiref)
				if resultt.size() > 0
					return resultt
				end
			rescue Exception => msg
				$log.error("Exception WMI request for #{wmiref}: #{msg}")
				raise
			end
		else
			$log.error("wmi login/password not set for host #{node.ip}")
		end
	end
	return nil
end

#severityObject



57
58
59
# File 'lib/monitor/client/wmi/wmi_monitoring.rb', line 57

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