def __init__(self, measurement_db_name, measurement_definitions, facility): super(OmlMeasurementLogger, self).__init__(measurement_db_name, measurement_definitions) self.oml_instance = None if facility == 'wilab2': self.oml_instance = oml4py.OMLBase("upi", self.measurement_db_name, socket.gethostname(), "tcp:am.wilab2.ilabt.iminds.be:3004") elif facility == 'portable': self.oml_instance = oml4py.OMLBase("upi", self.measurement_db_name, socket.gethostname(), "tcp:oml.portable.ilabt.iminds.be:3003") if self.oml_instance is not None: for measurement_name in measurement_definitions.keys(): self.oml_instance.addmp(measurement_name, measurement_definitions[measurement_name]) self.oml_instance.start() pass
} }).pop()['itemid'] itemid_EPC_MM = zapi.item.get({ "output": "extend", "hostids": hostid, "search": { "name": "epc-mm is running" } }).pop()['itemid'] except: logger.error("can not open local host.") sys.exit() omlInst = oml4py.OMLBase( "CLIENT_NAME", "TESTBED_NAME", "TESTBED_DOMAIN", "tcp:IP_TO_XIPI_MONITORING_SERVER:XIPI_MONITORING_PORT") omlInst.addmp("epc_client", "statusMessage:string up:double last_check:string") omlInst.addmp("epc_wifi", "statusMessage:string up:double last_check:string") omlInst.addmp("fiteagle", "statusMessage:string up:double last_check:string") omlInst.start() try: str = zapi.history.get({ "output": "extend", "history": 1, "itemids": itemid_Fiteagle, "sortfield": "clock", "sortorder": "DESC",
# THE SOFTWARE. # # # = oml4py-simple-example.py # # == Description # # A very simple straightforward example of OML4Py. # import oml4py import time import math from datetime import datetime import pytz omlInst = oml4py.OMLBase("APP_NAME", "TESTBED_NAME", "SENDER_ID", "tcp:XIPI_MONITORING_URL:XIPI_MONITORING_IP") #Definition of testbed components #schema: resource statusMessage:string up:double last_check:string omlInst.addmp("RES_NAME1", "statusMessage:string up:double last_check:string") omlInst.addmp("RES_NAME2", "statusMessage:string up:double last_check:string") omlInst.addmp("RES_NAME3", "statusMessage:string up:double last_check:string") omlInst.start() while True: tz=pytz.timezone("Europe/Berlin") aware_dt=tz.localize(datetime.now()) current=aware_dt.isoformat() omlInst.inject("RES_NAME1", [ "up and running", 1, current]) omlInst.inject("RES_NAME2", [ "up and running", 1, current])
kv = line.split(splitchar) if (len(kv)==2): dictionsry[kv[0]] = str(kv[1])[1:-2] return dictionsry except: logger.error("can not read file %s to a dictionary, format must be KEY=VALUE" % (filename)) sys.exit() monitoring_settings=read_config('../monitoring-config-data.cfg') logger=init_logger(monitoring_settings,'infrastructure-monitoring-wrapper.py') logger.debug("infrastructure-monitoring-wrapper.py' has been started") #The following was automatically generated by oml2-scaffold V2.12.0pre.79-58cf-dirty #for infrastructure monitoring version 1.0.0. omlInst = oml4py.OMLBase(monitoring_settings["appname"],monitoring_settings["domain"],monitoring_settings["sender"], monitoring_settings["target"]) #-----------------------------------------------------------------------# omlInst.addmp("used_memory", "used_memory:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:UsedMemory}{omn-monitoring-metric:UsedMemory|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:Byte}{omn-monitoring-unit:Byte|omn-monitoring-unit:hasPrefix|omn-monitoring-unit:giga} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("total_memory", "total_memory:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:TotalMemory}{omn-monitoring-metric:TotalMemory|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:Byte}{omn-monitoring-unit:Byte|omn-monitoring-unit:hasPrefix|omn-monitoring-unit:giga} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("available_memory", "available_memory:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:AvailableMemory}{omn-monitoring-metric:AvailableMemory|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:Byte}{omn-monitoring-unit:Byte|omn-monitoring-unit:hasPrefix|omn-monitoring-unit:giga} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("free_memory", "free_memory:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:FreeMemory}{omn-monitoring-metric:FreeMemory|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:Byte}{omn-monitoring-unit:Byte|omn-monitoring-unit:hasPrefix|omn-monitoring-unit:giga} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("cached_memory", "cached_memory:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:CachedMemory}{omn-monitoring-metric:CachedMemory|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:Byte}{omn-monitoring-unit:Byte|omn-monitoring-unit:hasPrefix|omn-monitoring-unit:giga} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("used_swap", "used_swap:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:UsedSwap}{omn-monitoring-metric:UsedSwap|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:percent} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("used_bandwidth", "used_bandwidth:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:UsedBandwidth}{omn-monitoring-metric:UsedBandwidth|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:bitpersecond}{omn-monitoring-unit:bitpersecond|omn-monitoring-unit:hasPrefix|omn-monitoring-unit:mega} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("cpu_idle", "cpu_idle:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:CPUidle}{omn-monitoring-metric:CPUidle|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:percent} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("cpu_nice", "cpu_nice:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:CPUnice}{omn-monitoring-metric:CPUnice|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:percent} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("cpu_iowait", "cpu_iowait:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:CPUIOwait}{omn-monitoring-metric:CPUIOwait|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%}{omn-monitoring-data:SimpleMeasurement|omn-monitoring:hasUnit|omn-monitoring-unit:percent} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ") omlInst.addmp("availability", "availability:double:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:isMeasurementDataOf|omn-monitoring-metric:Availability}{omn-monitoring-metric:Availability|omn-monitoring:isMeasurementMetricOf|omn-domain-pc:PC}{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasMeasurementDataValue|%value%} timestamp:datetime:{omn-monitoring-data:SimpleMeasurement|omn-monitoring-data:hasTimestamp|%value%} physicalresource:string:{omn-domain-pc:PC|omn:hasURI|%value%} virtualresource:string:{omn-domain-pc:VM|omn:hasURI|%value%}{omn-domain-pc:VM|omn-lifecycle:childOf|omn-domain-pc:PC} ")
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # # # = oml4py-simple-example.py # # == Description # # A very simple straightforward example of OML4Py. # import oml4py import time import math omlInst = oml4py.OMLBase("oml4PySimpleExample", "foo", "n1") omlInst.addmp("SinMP", "label:string angle:int32 value:double") omlInst.addmp("CosMP", "label:string value:double") omlInst.start() for i in range(5): time.sleep(0.5) angle = 15 * i omlInst.inject("SinMP", [("label_%s" % angle), angle, math.sin(angle)]) omlInst.inject("CosMP", [("label_%s" % angle), math.cos(angle)]) omlInst.close()