????
Current Path : /lib64/python3.6/site-packages/pcp/__pycache__/ |
Current File : //lib64/python3.6/site-packages/pcp/__pycache__/mmv.cpython-36.pyc |
3 4>�f_A � @ s\ d Z ddlmZmZ ddlmZ ddlZddlmZmZ ddlm Z m Z mZmZm Z mZmZ ejejjd��ZG dd � d e�ZG d d� de�ZG dd � d e�Zeej_e e e ee�e ee�e gej_dej_e egej_ee�ej_ee e gej_dej_eee�egej_dej_eee�ee�gej_dej_eee�egej_dej_eee�ee�gej_dej _eee�e e gej _dej!_ee e egej!_dej"_ee e gej"_dej#_ee e egej#_dej$_ee e e egej$_dej%_ee e e gej%_ee�ej&_eee�e e gej&_dej'_eee�gej'_dej(_ee e e egej(_G dd� de)�Z*dS )a� Wrapper module for libpcp_mmv - PCP Memory Mapped Values library # # Copyright (C) 2013-2016,2019 Red Hat. # # This file is part of the "pcp" module, the python interfaces for the # Performance Co-Pilot toolkit. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # Example use of this module for instrumenting a python application: from pcp import mmv, pmapi import cpmapi as pcpapi import cmmv as mmvapi instances = [ mmv.mmv_instance(0, "Anvils"), mmv.mmv_instance(1, "Rockets"), mmv.mmv_instance(2, "Giant_Rubber_Bands") ] ACME_PRODUCTS_INDOM = 61 indoms = [ mmv.mmv_indom( serial = ACME_PRODUCTS_INDOM, shorttext = "Acme products", helptext = "Most popular products produced by the Acme Corporation") ] indoms[0].set_instances(instances) metrics = [ mmv.mmv_metric( name = "products.count", item = 7, typeof = mmvapi.MMV_TYPE_U64, semantics = mmvapi.MMV_SEM_COUNTER, dimension = pmapi.pmUnits(0,0,1,0,0,pcpapi.PM_COUNT_ONE), indom = ACME_PRODUCTS_INDOM, shorttext = "Acme factory product throughput", helptext = "Monotonic increasing counter of products produced in the Acme Corporation " + "factory since starting the Acme production application. Quality guaranteed."), mmv.mmv_metric( name = "products.time", item = 8, typeof = mmvapi.MMV_TYPE_U64, semantics = mmvapi.MMV_SEM_COUNTER, dimension = pmapi.pmUnits(0,1,0,0,pcpapi.PM_TIME_USEC,0), indom = ACME_PRODUCTS_INDOM, shorttext = "Machine time spent producing Acme products") ] values = mmv.MemoryMappedValues("acme") values.add_indoms(indoms) values.add_metrics(metrics) values.start() anvils = values.lookup_mapping("products.count", "Anvils") values.set(anvils, 41) values.inc(anvils) values.stop() � )�pmUnits�pmAtomValue)�MMV_NAMEMAXN)� Structure�POINTER)�c_int�c_uint�c_long�c_char�c_char_p�c_double�c_void_pZpcp_mmvc @ s, e Zd ZdZdefdee fgZdd� ZdS )�mmv_instancezX Maps internal to external instance identifiers, within an instance domain. �internal�externalc C s. t j| � t|t�s|jd�}|| _|| _d S )Nzutf-8)r �__init__� isinstance�bytes�encoder r )�self�inst�name� r �/usr/lib64/python3.6/mmv.pyr c s zmmv_instance.__init__N) �__name__� __module__�__qualname__�__doc__r r r �_fields_r r r r r r \ s r c @ sH e Zd ZdZdefdefdee�fdefdefgZd dd �Z d d� Z dS )� mmv_indomz� Represents an instance domain (for set valued metrics) Instance domains have associated instances - integer/string pairs. Defines complete indom metadata (instances, count, text and so on) �serial�count� instances� shorttext�helptext� c C s\ t j| � |d k r(t|t� r(|jd�}|d k rFt|t� rF|jd�}|| _|| _|| _d S )Nzutf-8)r r r r r r# r$ r )r r r# r$ r r r r u s zmmv_indom.__init__c C sT t |�| _t| j � }x2t| j�D ]$}|| j|| _|| j|| _q"W || _dS )z7 Update the instances and counts fields for this indom N)�lenr! r �ranger r r"