Class: JMXRef

Inherits:
Object
  • Object
show all
Defined in:
lib/monitor/client/jmx/jmx_ref.rb

Constant Summary collapse

TABLENAME =
'jmx_ref'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#attributeObject

Returns the value of attribute attribute.



2
3
4
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 2

def attribute
  @attribute
end

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 2

def description
  @description
end

#mbeanObject

Returns the value of attribute mbean.



2
3
4
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 2

def mbean
  @mbean
end

#nameObject

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_nameObject

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

Returns:

  • (Boolean)


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_entryObject

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_jmxrefObject



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_jmxrefObject



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_useObject



97
98
99
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 97

def add_use()
 @nb_use+=1
end

#del_useObject



101
102
103
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 101

def del_use()
 @nb_use-=1
end

#to_strObject



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

Returns:

  • (Boolean)


105
106
107
# File 'lib/monitor/client/jmx/jmx_ref.rb', line 105

def used?()
 return @nb_use>0 
end