Class: JMXRef
- Inherits:
-
Object
- Object
- JMXRef
- Defined in:
- lib/monitor/client/jmx/jmx_ref.rb
Constant Summary collapse
- TABLENAME =
'jmx_ref'
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#description ⇒ Object
Returns the value of attribute description.
-
#mbean ⇒ Object
Returns the value of attribute mbean.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.add_jmx_ref(n, descr, calc, attr) ⇒ Object
add an jmx_ref arg n for uniq name, descr the description, mbean and attribute return true if deleted otherwise false.
-
.del_jmx_ref(n) ⇒ Object
delete an jmx_ref return true is entry delete otherwise false.
-
.get_jmx_refs_name ⇒ Object
return a table of all jmxrefs name.
-
.jmx_ref_exist?(name) ⇒ Boolean
check if a given jmx ref name is defined.
-
.jmx_ref_nb_entry ⇒ Object
return number of jmx ref.
- .read_db_jmxref ⇒ Object
- .write_db_jmxref ⇒ Object
Instance Method Summary collapse
- #add_use ⇒ Object
- #del_use ⇒ Object
-
#initialize(n, descr, calc, attr) ⇒ JMXRef
constructor
A new instance of JMXRef.
- #to_str ⇒ Object
- #used? ⇒ Boolean
Constructor Details
#initialize(n, descr, calc, attr) ⇒ JMXRef
Returns a new instance of JMXRef.
88 89 90 91 92 93 94 95 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 88 def initialize (n, descr, calc, attr) #name is the identifier, it must be uniq @name=n @description=descr @mbean=calc @attribute=attr @nb_use=0 end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
2 3 4 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 2 def attribute @attribute end |
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 2 def description @description end |
#mbean ⇒ Object
Returns the value of attribute mbean.
2 3 4 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 2 def mbean @mbean end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 2 def name @name end |
Class Method Details
.add_jmx_ref(n, descr, calc, attr) ⇒ Object
add an jmx_ref arg n for uniq name, descr the description, mbean and attribute return true if deleted otherwise false
12 13 14 15 16 17 18 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 12 def JMXRef::add_jmx_ref(n, descr, calc, attr) if $jmx_refs[n] == nil $jmx_refs[n] = JMXRef.new(n, descr, calc, attr) return true end return false end |
.del_jmx_ref(n) ⇒ Object
delete an jmx_ref return true is entry delete otherwise false
25 26 27 28 29 30 31 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 25 def JMXRef::del_jmx_ref(n) if !$jmx_refs[n].used?() $jmx_refs.delete(n) return true end return false end |
.get_jmx_refs_name ⇒ Object
return a table of all jmxrefs name
63 64 65 66 67 68 69 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 63 def JMXRef::get_jmx_refs_name() name_t=[] $jmx_refs.each_key {|name| name_t.push name } return name_t end |
.jmx_ref_exist?(name) ⇒ Boolean
check if a given jmx ref name is defined
74 75 76 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 74 def JMXRef::jmx_ref_exist?(name) return $jmx_refs[name] != nil end |
.jmx_ref_nb_entry ⇒ Object
return number of jmx ref
81 82 83 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 81 def JMXRef::jmx_ref_nb_entry() return $jmx_refs.size end |
.read_db_jmxref ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 50 def JMXRef::read_db_jmxref() if defined?($db) && ($db !=nil) db_select_all_prp(TABLENAME).execute do |rs| rs.each do |name, description, mbean, attribute| add_jmx_ref(name,description,mbean,attribute) end end end end |
.write_db_jmxref ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 33 def JMXRef::write_db_jmxref() if defined?($db) && ($db !=nil) $db.transaction ps=db_delete_all_prp(TABLENAME) if ps ps.execute() stmt=db_insert_ref_prp4(TABLENAME) $jmx_refs.each_value do |jmx_ref| stmt.execute(jmx_ref.name, jmx_ref.description, jmx_ref.mbean, jmx_ref.attribute) end $db.commit else $db.rollback end end end |
Instance Method Details
#add_use ⇒ Object
97 98 99 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 97 def add_use() @nb_use+=1 end |
#del_use ⇒ Object
101 102 103 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 101 def del_use() @nb_use-=1 end |
#to_str ⇒ Object
109 110 111 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 109 def to_str() print "JMXRef: ", @name, " ", @description, " ", @mbean, " ", @attribute end |
#used? ⇒ Boolean
105 106 107 |
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 105 def used?() return @nb_use>0 end |