⚝
One Hat Cyber Team
⚝
Your IP:
3.145.106.159
Server IP:
97.74.87.16
Server:
Linux 16.87.74.97.host.secureserver.net 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
lib
/
fm-agent
/
plugins
/
__pycache__
/
View File Name :
tomcat_jmx.cpython-39.pyc
a �������fJ?����������������������@���sH���d�dl�Z�d�dlZd�dlZd�dlmZmZ�e��e�ZG�dd��dej�Z dS�)�����N)�java�javaxc����������������"���@���s����e�Zd�ZdZdZdZdddddd d ddd ddddddddddddddddddd d!d"d#d$d%�!Zed&d'���Ze d(d)���Z e d*d+���Ze d,d-���Ze d.d/���Z d0S�)1�TomcatJMXPluginzCTomcat Plugin for the FortiMonitor Agent using JMX to collect data.Z tomcat_jmxzTomcat (JMX))zHeap Memory Usage Used� java.lang�MemoryN�HeapMemoryUsage�used�bytes)zHeap Memory Usage Committedr���r���Nr���� committedr ���)zHeap Memory Usage Initr���r���Nr����initr ���)zHeap Memory Usage Maxr���r���Nr����maxr ���)zNon-Heap Memory Usage Usedr���r���N�NonHeapMemoryUsager���r ���)zNon-Heap Memory Usage Committedr���r���Nr ���r ���r ���)zNon-Heap Memory Usage Initr���r���Nr ���r���r ���)zNon-Heap Memory Usage Maxr���r���Nr ���r���r ���)zThread Countr���Z ThreadingNZThreadCountN�count)zOS Process CPU Loadr����OperatingSystemNZProcessCpuLoadN�percent)zOS System CPU Loadr���r���NZ SystemCpuLoadNr���)zOS Open File Descriptor Countr���r���NZOpenFileDescriptorCountNr���)zLoaded Class Countr���ZClassLoadingNZLoadedClassCountNr���)� Eden Spacer���� MemoryPoolr����Usager���r ���)� PS Eden Spacer���r���r���r���r���r ���)�Par Eden Spacer���r���r���r���r���r ���)� G1 Eden Spacer���r���r���r���r���r ���)�Survivor Spacer���r���r���r���r���r ���)�PS Survivor Spacer���r���r���r���r���r ���)�Par Survivor Spacer���r���r���r���r���r ���)�G1 Survivor Spacer���r���r���r���r���r ���)� PS Old Genr���r���r���r���r���r ���)�CMS Old Genr���r���r���r���r���r ���)� G1 Old Genr���r���r���r���r���r ���)�Copyr����GarbageCollectorr����CollectionCountNr���)�PS Scavenger���r���r!���r ���Nr���)�ParNewr���r���r"���r ���Nr���)�G1 Young Generationr���r���r#���r ���Nr���)�G1 Mixed Generationr���r���r$���r ���Nr���)�MarkSweepCompactr���r���r%���r ���Nr���)�PS MarkSweepr���r���r&���r ���Nr���)�ConcurrentMarkSweepr���r���r'���r ���Nr���)�G1 Old Generationr���r���r(���r ���Nr���)!zmemory.heapzmemory.heap.committedzmemory.heap.initzmemory.heap.maxzmemory.non_heapzmemory.non_heap.committedzmemory.non_heap.initzmemory.non_heap.maxzthreading.countzos.cpu_load.processzos.cpu_load.systemzos.open_file_descriptorszclass_loading.loaded_classeszmemory_pool.edenzmemory_pool.eden.pszmemory_pool.eden.parzmemory_pool.eden.g1zmemory_pool.survivorzmemory_pool.survivor.pszmemory_pool.survivor.parzmemory_pool.survivor.g1zmemory_pool.old.pszmemory_pool.old.cmszmemory_pool.old.g1z gc.young.copyzgc.young.ps_scavengezgc.young.par_newzgc.young.g1_generationzgc.mixed.g1_generationzgc.old.mark_sweep_compactzgc.old.ps_mark_sweepzgc.old.concurrent_mark_sweepzgc.old.g1_generationc�����������������C���sP���|�d�|�d�|�d���}}}d|�}|r4|d|�7�}|rD|d|�7�}t�j�|�S�)a���returns a constructed ObjectName. :type tuple_: tuple (label, domain, type, bean_name, attribute_name, composite_data_key, unit) :param tuple_: A tuple with all the information for an ObjectName. A string that represents the label, a string that represents the domain, and so on and so forth. :rtype: javax.management.ObjectName :return: An ObjectName object that can be used to lookup a MBean. ������������z%s:zname=%s,ztype=%s)r���� management� ObjectName)�tuple_�domain�type_Z bean_nameZcanonical_name��r1����'/usr/lib/fm-agent/plugins/tomcat_jmx.pyZ__get_object_name_from_tupleC���s���� z,TomcatJMXPlugin.__get_object_name_from_tuplec�����������������C���s��g�d�}i�}|D�]T}|��|�}|s8|dvr8td|���q|sH|dv�rHqqdd��|�d�D��}|||<�qi�}|d�}t|�D�]�\} } d| i|| <�dD�]l}t|��|g���d kr�||�| �}n:t|��|g���d kr�||�d �}n|dvr�td|���nq�||| �|<�q�qz|S�)a��� Parse the config object to build a structure of connections parameters based on the number of entries that are in each key. The main parameter we base on to split off is host. :type config: dict (host, port, username, password, jvm_path) :param config: Dictionary with the information stored in the config file. :rtype: Dict :return: Dictionary with connection information split up in multiple if needed. )�host�port�username�password�jvm_path)r5���r6���z"Missing %s information from configc�����������������S���s���g�|�]}|��d���qS�)� )�strip)�.0�valuer1���r1���r2���� <listcomp>r��������z?TomcatJMXPlugin.get_connections_from_config.<locals>.<listcomp>�,r3���)r4���r5���r6���r7���r)���r���)�get� ValueError�split� enumerate�len)�cls�config�keys�data�key� key_value�values�connectionsZhosts�indexr3���r;���r1���r1���r2����get_connections_from_config[���s2���� �z+TomcatJMXPlugin.get_connections_from_configc�����������������C���s���t�j}d}|s$d}|�j�|��t�j}d|vs4d|vrPd|�j�}|�j�|��t�j}|�d�}|s�z,t���}|s�t�j}d|�j�}|�j�|��W�n(���t�j}d|�j�}|�j�|��Y�n0�z |t�ju�r�t� ��s�t� |��W�n"���t�j}d}|�j�|��Y�n0�|t�ju��r�z�t� ���st� |��tj� ��}|�d ��rr|�d ��rrt�tjj�|�d �|�d �g�}|�tjjjj|��d|�d�t|�d��f�}tjj�|�}tjjj�||�} | ���} || dfW�S��t�y����d}|�j�|��Y�n0�|d|fS�) a��� returns a list of connections from the jpype library - a python interface to the Java Native Interface. Wheter there are 1 or many connections depends on the number of entries in the host, port and optionally username/password/jvm entries. :type config: dict :param config: Mapping of information under the application block for this plugin. :rtype: tuple (status, connection, error_message) :return: A tuple containing a numeric value corresponding to the agent_util status'. A MBeanServerConnection object. And, a string with an error message if any. NzNo JMX configuration foundr3���r4���zJMissing value in the [%s] block of the agent config file (e.g host, port).r7���zYUnable to find JVM, please specify 'jvm_path' in the [%s] block of the agent config file.z;Unable to access JMX metrics because JVM cannot be started.r5���r6���z*service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmizBUnable to access JMX metrics, JMX is not running or not installed.)� agent_util� SUPPORTED�log�info� MISCONFIGURED�textkeyr?����jpype�getDefaultJVMPath�isJVMStarted�startJVMr����util�HashMap�JArray�lang�String�putr���r,����remote�JMXConnector�CREDENTIALS�int� JMXServiceURL�JMXConnectorFactory�connect�getMBeanServerConnection� Exception� exception)rD���rE����status�msgr7���Zj_hashZj_array�urlZjmx_urlZjmx_soc� connectionr1���r1���r2���Z__get_connection����sz����� �� � �� �z TomcatJMXPlugin.__get_connectionc�������������� ���C���s���i�}|���|�}i�}g�}|���D�]H}|��|�\}}} d|d�|d�f�} | r^|�d| | f���q||| <�q|���s�|�j�d��|D�]} |�j�| ��q�|S�tj }d} |D�]}|�j� |��q�|�j���D�]�\}} |�� | �}g�}|���D�]N\} }z|�|��|�| ��W�q��t�y*���|�j�d|| f���Y�q�Y�q�0�q�t|����dk�rZ|�sZd }tj}d |�} n d} tj }| d�| d��}}|||| |d �||<�q�|S�)a��returns a json object who's textkeys correspond to a given metric available on the JVM. :type config: dict :param config: Mapping of information under the application block for this plugin. :return: JSON Object for all metrics �%s:%sr3���r4���z%s %sz#Unable to connect to any connection��z.Tomcat (JMX) plugin - %s bean not found at %s.r)���Nz Unreachable %s at any connectionr�������)�label�optionsrh���� error_message�unit)rM���rJ���� _TomcatJMXPlugin__get_connection�appendrF���rP���rQ����errorrN���rO����warning�JMX_MAPPING�items�,_TomcatJMXPlugin__get_object_name_from_tuple�getObjectInstancerf���rg���rC����UNSUPPORTED)rD���rE����result�configsrK����errors�entryrh���rk���ri���Zconnection_keyru���rH���r.����object_namerp���ro���rr���r1���r1���r2����get_metadata����sV���� �zTomcatJMXPlugin.get_metadatac�����������������C���s��|���|�}|r>|���D�]$}d|d�|d�f�}||kr|}qn|d�}|��|�\}}} | rn|�j�d| ���dS�|�j�|�} | d�| d��}}|��| �} zX|�| �}|� |� ��|�}|jj}d |vr�|� ��W�S�|�|�s�W�dS�|�|�}|� ��W�S����|�j�d | ���Y�dS�0�dS�)a���returns a value for the metric. :type textkey: string :param textkey: Canonical name for a metric. :type data: string :param data: Specific option to check for. :type config: dict :param config: Mapping of information under the application block for this plugin. :rtype: double :return: Value for a specific metric rl���r3���r4���r���zFailed to get a connection: %sN��������ZCompositeDataSupportz(Tomcat (JMX) plugin - %s bean not found.)rM���rJ���rs���rP���rQ���rw���r?���ry���rz����getAttributeZ getObjectName� __class__�__name__� floatValueZcontainsKey)rD���rS���rG���rE����entriesr���Zpossible_matchrh���rk���ri���r.���Zattribute_nameZcomposite_data_keyr����Zobject_instanceZattribute_valueZattribute_class_nameZcheck_resultr1���r1���r2����check.��s@���� � �zTomcatJMXPlugin.checkN)r����� __module__�__qualname__�__doc__rS���ro���rw����staticmethodry����classmethodrM���rs���r����r����r1���r1���r1���r2���r��� ���s^����4 - _ Dr���) �loggingrN���rT���r���r���� getLoggerr�����logger�Pluginr���r1���r1���r1���r2����<module>���s ���