Class: SnmpMonitoring
- Inherits:
-
Object
- Object
- SnmpMonitoring
- Defined in:
- lib/monitor/client/snmp/snmp_monitoring.rb
Constant Summary collapse
- TESTOP =
["=", "!=", "<", ">"]
Instance Attribute Summary collapse
-
#oidref ⇒ Object
Returns the value of attribute oidref.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #get_state ⇒ Object
-
#initialize(st, oidref_name, op, th, sev) ⇒ SnmpMonitoring
constructor
A new instance of SnmpMonitoring.
- #oper ⇒ Object
- #raw_severity ⇒ Object
- #severity ⇒ Object
-
#value(manager, node) ⇒ Object
compute the value.
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
#oidref ⇒ Object
Returns the value of attribute oidref.
4 5 6 |
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 4 def oidref @oidref end |
#threshold ⇒ Object
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
25 26 27 |
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 25 def active?() return @state==1 end |
#get_state ⇒ Object
21 22 23 |
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 21 def get_state() return @state end |
#oper ⇒ Object
17 18 19 |
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 17 def oper() return TESTOP[@oper] end |
#raw_severity ⇒ Object
51 52 53 |
# File 'lib/monitor/client/snmp/snmp_monitoring.rb', line 51 def raw_severity() return @severity end |
#severity ⇒ Object
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 |