class PCPEasy::PMAPI
Constants
- PM_CONTEXT_HOST
- PM_COUNT_ONE
- PM_ERR_AGAIN
- PM_ERR_APPVERSION
- PM_ERR_BADSTORE
- PM_ERR_BASE
- PM_ERR_BASE2
- PM_ERR_CONNLIMIT
- PM_ERR_CONV
- PM_ERR_DUPPMNS
- PM_ERR_EOF
- PM_ERR_EOL
- PM_ERR_FAULT
- PM_ERR_GENERIC
- PM_ERR_INDOM
- PM_ERR_INDOM_LOG
- PM_ERR_INST
- PM_ERR_INST_LOG
- PM_ERR_IPC
- PM_ERR_ISCONN
- PM_ERR_LABEL
- PM_ERR_LOGFILE
- PM_ERR_LOGREC
- PM_ERR_MODE
- PM_ERR_NAME
- PM_ERR_NEEDPORT
- PM_ERR_NOAGENT
- PM_ERR_NOCONTAINER
- PM_ERR_NOCONTEXT
- PM_ERR_NODATA
- PM_ERR_NONLEAF
- PM_ERR_NOPMNS
- PM_ERR_NOPROFILE
- PM_ERR_NOTARCHIVE
- PM_ERR_NOTCONN
- PM_ERR_NOTHOST
- PM_ERR_NYI
- PM_ERR_PERMISSION
- PM_ERR_PMDANOTREADY
- PM_ERR_PMDAREADY
- PM_ERR_PMID
- PM_ERR_PMID_LOG
- PM_ERR_PMNS
- PM_ERR_PROFILE
- PM_ERR_PROFILESPEC
- PM_ERR_RESET
- PM_ERR_SIGN
- PM_ERR_TEXT
- PM_ERR_THREAD
- PM_ERR_TIMEOUT
- PM_ERR_TOOBIG
- PM_ERR_TOOSMALL
- PM_ERR_TRUNC
- PM_ERR_TYPE
- PM_ERR_UNIT
- PM_ERR_VALUE
- PM_INDOM_NULL
- PM_MAXERRMSGLEN
- PM_SEM_COUNTER
- PM_SEM_DISCRETE
- PM_SEM_INSTANT
- PM_SPACE_BYTE
- PM_SPACE_EBYTE
- PM_SPACE_GBYTE
- PM_SPACE_KBYTE
- PM_SPACE_MBYTE
- PM_SPACE_PBYTE
- PM_SPACE_TBYTE
- PM_TIME_HOUR
- PM_TIME_MIN
- PM_TIME_MSEC
- PM_TIME_NSEC
- PM_TIME_SEC
- PM_TIME_USEC
- PM_TYPE_32
- PM_TYPE_64
- PM_TYPE_AGGREGATE
- PM_TYPE_AGGREGATE_STATIC
- PM_TYPE_DOUBLE
- PM_TYPE_EVENT
- PM_TYPE_FLOAT
- PM_TYPE_HIGHRES_EVENT
- PM_TYPE_NOSUPPORT
- PM_TYPE_STRING
- PM_TYPE_U32
- PM_TYPE_U64
- PM_TYPE_UNKNOWN
- PM_VAL_DPTR
- PM_VAL_INSITU
- PM_VAL_SPTR
Public Class Methods
new(host)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 142 def initialize(host) @context = FFIInternal.pmNewContext PM_CONTEXT_HOST, host raise PCPEasy::Error.from_pmapi_error_number(@context) if @context < 0 ObjectSpace.define_finalizer(self, self.class.finalize(@context) ) end
pmErrStr(number)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 148 def self.pmErrStr(number) buffer = FFI::MemoryPointer.new(:char, PM_MAXERRMSGLEN) FFIInternal.pmErrStr_r number, buffer, PM_MAXERRMSGLEN end
pmExtractValue(value_format, pm_desc, pm_value)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 205 def self.pmExtractValue(value_format, pm_desc, pm_value) atom = PCPEasy::PMAPI::PmAtomValue.new error_code = FFIInternal.pmExtractValue(value_format, pm_value.pointer, pm_desc.type, atom.pointer, pm_desc.type) raise PCPEasy::Error.from_pmapi_error_number(error_code) if error_code < 0 case pm_desc.type when PM_TYPE_32 atom.l when PM_TYPE_U32 atom.ul when PM_TYPE_64 atom.ll when PM_TYPE_U64 atom.ull when PM_TYPE_FLOAT atom.f when PM_TYPE_DOUBLE atom.d when PM_TYPE_STRING str = atom.cp.read_string LibC.free(atom.cp) if atom.cp str when PM_TYPE_AGGREGATE || PM_TYPE_EVENT || PM_TYPE_HIGHRES_EVENT # No support, make sure we free the pointer LibC.free(atom.vbp) if atom.vbp raise PCPEasy::Error.new "Metric type #{pm_desc.type} not supported" else raise ArgumentError.new "Type #{pm_desc.type} not valid" end end
Private Class Methods
finalize(context)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 243 def self.finalize(context) proc { FFIInternal.pmDestroyContext(context) } end
Public Instance Methods
pmFetch(pmids)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 176 def pmFetch(pmids) pmUseContext pmids_ptr = FFI::MemoryPointer.new(:uint, pmids.size) pmids_ptr.write_array_of_uint pmids pm_result_ptr = FFI::MemoryPointer.new :pointer error_code = FFIInternal.pmFetch(pmids.size, pmids_ptr, pm_result_ptr) raise PCPEasy::Error.from_pmapi_error_number(error_code) if error_code < 0 pm_result_ptr = FFI::AutoPointer.new(pm_result_ptr.get_pointer(0), FFIInternal.method(:pmFreeResult)) PCPEasy::PMAPI::PmResult.new(pm_result_ptr) end
pmGetInDom(indom)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 191 def pmGetInDom(indom) pmUseContext internal_ids = FFI::MemoryPointer.new :pointer external_names = FFI::MemoryPointer.new :pointer error_or_num_results = FFIInternal.pmGetInDom indom, internal_ids, external_names raise PCPEasy::Error.from_pmapi_error_number(error_or_num_results) if error_or_num_results < 0 ids = internal_ids.get_pointer(0).get_array_of_int(0, error_or_num_results) names = external_names.get_pointer(0).get_array_of_string(0, error_or_num_results) Hash[ids.zip(names)] end
pmLookupDesc(pmid)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 166 def pmLookupDesc(pmid) pmUseContext pm_desc = PCPEasy::PMAPI::PmDesc.new error_code = FFIInternal.pmLookupDesc(pmid, pm_desc.to_ptr) raise PCPEasy::Error.from_pmapi_error_number(error_code) if error_code < 0 pm_desc end
pmLookupName(names)
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 153 def pmLookupName(names) pmUseContext names_ptr = FFI::MemoryPointer.new(:pointer, names.size) names_ptr.write_array_of_pointer names.collect {|n| FFI::MemoryPointer.from_string n} pmid_ptr = FFI::MemoryPointer.new(:uint, names.size) error_code = FFIInternal.pmLookupName names.size, names_ptr, pmid_ptr raise PCPEasy::Error.from_pmapi_error_number(error_code) if error_code < 0 pmid_ptr.get_array_of_uint 0, names.size end
Private Instance Methods
pmUseContext()
click to toggle source
# File lib/pcp_easy/pmapi.rb, line 239 def pmUseContext FFIInternal.pmUseContext @context end