Server IP : 184.154.167.98 / Your IP : 3.145.50.254 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib64/python3.6/site-packages/pcp/__pycache__/ |
Upload File : |
3 4>�fN� � @ sz d Z ddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z mZmZm Z mZmZ ddl mZmZmZmZmZmZ ddl mZmZmZmZmZ ddl mZmZmZmZmZ ddl m!Z! ee!d��Z"ej#d kr�d ndZ$ee!e$��Z%ej&dk�re'fZ(e'Z)e*Z+ne'e)fZ(e,Z+d d� Z-G dd� de.�Z/G dd� de.�Z0ej1dk�rTeZ2nej1dk�rfeZ2ne/ej3d��ej4dk�r�eZ5nej4dk�r�eZ5ne/ej3d��G dd� de�Z6G dd� de�Z7G dd� de�Z8G dd� de�Z9G dd � d e�Z:G d!d"� d"e�Z;G d#d$� d$e�Z<G d%d&� d&e�Z=G d'd(� d(e�Z>ee>�Z?e@d)d*� ddd�e?_Ae@d+d*� ddd�e?_Be@d,d*� ddd�e?_Ce@d-d*� ddd�e?_DG d.d/� d/e�ZEeZFeZGG d0d1� d1e�ZHeeH�ZIe@d2d*� ddd�eI_Je@d3d*� ddd�eI_Ke@d4d*� ddd�eI_Le@d5d*� ddd�eI_Md6d7� ZNG d8d9� d9e�ZOG d:d;� d;e�ZPG d<d=� d=e�ZQeeQ�ZRe@d>d*� ddd�eR_Se@d?d*� ddd�eR_Te@d@d*� ddd�eR_Ue@dAd*� ddd�eR_Ve@dBd*� ddd�eR_WG dCdD� dDe�ZXee"jY_Zeeee��ge"jY_[ee"j\_Zeeee��eee��ge"j\_[ee"j]_Zg e"j]_[ee"j^_Zege"j^_[ee"j__ZeedE ee�ge"j__[ee"j`_Zeeee��ge"j`_[ee"ja_Zeee�ge"ja_[ede�Zbee"jc_Zeebge"jc_[ee"jd_Zg e"jd_[ee"je_Zeeee�ge"je_[ee"jf_Zege"jf_[ee"jg_ZeeeH�ge"jg_[ee"jh_Zeee�eeH�ge"jh_[ee"ji_Zeeee�ge"ji_[ee"jj_Zeeee�ge"jj_[ee"jk_Zeeee��eee��ge"jk_[ee"jl_Zeege"jl_[ee"jm_Zeeee�ge"jm_[ee"jn_Zeege"jn_[ee"jo_Zege"jo_[ee"jp_Zg e"jp_[ee"jq_Zege"jq_[ee"jr_Zg e"jr_[ee"js_Zeeee�ge"js_[ee"jt_Zeeee�ge"jt_[ee"ju_Zeee6�ege"ju_[ee"jv_Zege"jv_[ee"jw_Zeeege"jw_[ee"jx_Zg e"jx_[ee"jy_Zege"jy_[ee"jz_Zege"jz_[ee"j{_Zee�ge"j{_[ee8�e"j|_Zee �ee8�ge"j|_[ee"j}_Zee �ege"j}_[ee"j~_Zeee�eeeE��ge"j~_[de"j_ZeeE�ge"j_[ee"j�_ZeeE�ge"j�_[ee"j�_ZeeP�ge"j�_[ee"j�_Zee6�ge"j�_[ee"j�_Zeeee��eee��ge"j�_[ee"j�_Zeege"jl_[eGege"j�_[ee"j�_ZeGege"j�_[ee"j�_ZeeeE��ge"j�_[ee"j�_Zege"j�_[ee"j�_Zeeege"j�_[ee"j�_Zeee=�eee9�ege"j�_[ee"j�_Zeee9�ee:�ee9�ee:�ge"j�_[ee"j�_Zee:�eege"j�_[ee"j�_Zeeege"j�_[ee"j�_Zeeege"j�_[ee"j�_Zege"j�_[ee"j�_Zege"j�_[ee"j�_Zege"j�_[ee"j�_Zeeege"j�_[ee"j�_Zeege"j�_[ee"j�_Zege"j�_[ee"j�_Zege"j�_[ee"j�_Zeeege"j�_[ee"j�_Zeeege"j�_[ee"j�_Zee9�eeege"j�_[ee"j�_Zeeege"j�_[de"j�_Zeeeee=�ege"j�_[ee"j�_Zeee6�ee�ge"j�_[ee"j�_ZeeeeeeO��ee�ge"j�_[ee"j�_Zg e"j�_[ee"j�_Zege"j�_[de"j�_ZeeE�ge"j�_[ee"j�_ZeeeeX��ge"j�_[ee"j�_ZeeeeX��ge"j�_[ee"j�_ZeeeeX��ge"j�_[ee"j�_ZeeeeX��ge"j�_[ee"j�_ZeeeeX��ge"j�_[ee"j�_ZeeeeX��ge"j�_[ee"j�_ZeeeX��ge"j�_[ee"j�_Zee�eeege"j�_[eeeeQ�ee�Z�ee"j�_ZeeeX��eeee�ege"j�_[de"j�_ZeeX�ege"j�_[G dFdG� dGe��Z�G dHdI� dIe��Z�ee"j�_Zee�eege"j�_[ee"j�_Zege"j�_[ee"j�_Zege"j�_[ee"j�_Zege"j�_[ee"j�_Zeeeeee9�eee�ge"j�_[ee"j�_Zeeeee�ee�ee9�eee�eee�ee�ge"j�_[ee"j�_Zeeeeeee7�ee9�eee�eee�ee�ge"j�_[ee"j�_Zeee6�ge"j�_[ee"j�_Zege"j�_[G dJdK� dKe��Z�dS )La� Wrapper module for LIBPCP - the core Performace Co-Pilot API # # Copyright (C) 2012-2021 Red Hat # Copyright (C) 2009-2012 Michael T. Werner # # 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. # # Additional Information: # # Performance Co-Pilot Web Site # https://pcp.io # # Performance Co-Pilot Programmer's Guide # cf. Chapter 3. PMAPI - The Performance Metrics API # # EXAMPLE from pcp import pmapi import cpmapi as c_api # Create a pcp class context = pmapi.pmContext(c_api.PM_CONTEXT_HOST, "local:") # Get ids for number cpus and load metrics metric_ids = context.pmLookupName(("hinv.ncpu","kernel.all.load")) # Get the description of the metrics descs = context.pmLookupDescs(metric_ids) # Fetch the current value for number cpus results = context.pmFetch(metric_ids) # Extract the value into a scalar value atom = context.pmExtractValue(results.contents.get_valfmt(0), results.contents.get_vlist(0, 0), descs[0].contents.type, c_api.PM_TYPE_U32) print "#cpus=", atom.ul # Get the instance ids for kernel.all.load inst1 = context.pmLookupInDom(descs[1], "1 minute") inst5 = context.pmLookupInDom(descs[1], "5 minute") # Loop through the metric ids for i in range(results.contents.numpmid): # Is this the kernel.all.load id? if (results.contents.get_pmid(i) != metric_ids[1]): continue # Extract the kernel.all.load instance for j in range(results.contents.get_numval(i) - 1): atom = context.pmExtractValue(results.contents.get_valfmt(i), results.contents.get_vlist(i, j), descs[i].contents.type, c_api.PM_TYPE_FLOAT) value = atom.f if results.contents.get_inst(i, j) == inst1: print "load average 1=",atom.f elif results.contents.get_inst(i, j) == inst5: print "load average 5=",atom.f # ... or, using the fetchgroup interface: from pcp import pmapi import cpmapi as c_api pmfg = pmapi.fetchgroup(c_api.PM_CONTEXT_HOST, "local:") v = pmfg.extend_item("hinv.ncpu") vv = pmfg.extend_indom("kernel.all.load", c_api.PM_TYPE_FLOAT) vvv = pmfg.extend_event("systemd.journal.records", field="systemd.journal.field.string") t = pmfg.extend_timestamp() pmfg.fetch() print("time: %s" % t()) print("number of cpus: %d" % v()) for icode, iname, value in vv(): print("load average %s: %f" % (iname, value())) for ts, line in vvv(): print("%s : %s" % (ts, line())) � N)�c_char�c_int�c_uint�c_long�c_char_p�c_void_p)�c_float�c_double�c_int32�c_uint32�c_int64�c_uint64)�CDLL�POINTER� CFUNCTYPE� Structure�Union)� addressof�pointer�sizeof�cast�byref)�find_libraryZpcpZwin32�cZmsvcrt�3c C sb t jdkr:ttjj_tjgtjj_t j tjj| �ddd�S ttjj_tjgtjj_tjj| �S d S )Nr �rF)�closefd) �sys�versionr �ctypesZ pythonapiZPyObject_AsFileDescriptor�restypeZ py_object�argtypes�os�fdopenr Z PyFile_AsFile)�fileObj� r% �/usr/lib64/python3.6/pmapi.py� pyFileToCFile� s r'