Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/elasticsearch.cpython-36.pyc

3

�uGh��@s�y0ddlmZmZddlmZmZddlmZWn@ek
rpddlmZddl	mZddl
mZmZmZYnXddlZddlZddl
Z
ddlZGdd	�d	ej�Zed
kr�e�j�dS)�)�urlparse�	urlencode)�urlopen�Request)�	HTTPError)r)r)rrrNc@seZdZdZdd�ZdS)�Plugin�
elasticsearchc7sHdd�}t�}t�}tj|jdd��}tj|�}tj�|d<|j�}d<�fdd	�	�y"�tj|j	�|d
�dd�}Wnt
k
r�d
SXd=}	i}
ttg}x�|j
�D]�\}}
|j�j�}x2|D]*}y||
�}
Wntk
�r�YnX�q�W||	k�r�t|
�tk	�r�|j|t|
�|�||<t|
�|
|<n�q�Wtj�|
d<|j|
�|S)>z�
        experimental monitoring plugin for elasticsearch
        Add to /etc/agent360.ini:
        [elasticsearch]
        enabled = yes
        status_page_url = http://127.0.0.1:9200/_stats
        cs"dd��t�fdd�|j�D��S)NcSst|t�r|jd�S|S)N�ascii)�
isinstance�unicode�encode)�x�r�G/root/tmp/pip-build-gzoz1_uw/agent360/agent360/plugins/elasticsearch.py�<lambda>sz7Plugin.run.<locals>.ascii_encode_dict.<locals>.<lambda>c3s|]}t�|�VqdS)N)�map)�.0�pair)�ascii_encoderr�	<genexpr>sz8Plugin.run.<locals>.ascii_encode_dict.<locals>.<genexpr>)�dict�items)�datar)rr�ascii_encode_dictsz%Plugin.run.<locals>.ascii_encode_dictrZstatus_page_url�ts��_csjg}x\|j�D]P\}}|r&|||n|}t|tj�rP|j�|||d�j��q|j||f�qWt|�S)N)�sep)rr
�collections�MutableMapping�extend�appendr)�dZ
parent_keyrr�k�vZnew_key)�flattenrrr%'szPlugin.run.<locals>.flatten)�object_hookZ_all�totalF�get_time_in_millis�indexing_index_time_in_millis�flush_total_time_in_millis�indexing_delete_time_in_millis� indexing_throttle_time_in_millis�#merges_total_stopped_time_in_millis�%merges_total_throttled_time_in_millis�merges_total_time_in_millis� recovery_throttle_time_in_millis�refresh_total_time_in_millis�search_fetch_time_in_millis�search_query_time_in_millis�search_scroll_time_in_millis�search_suggest_time_in_millis�warmer_total_time_in_millis�
docs_count�docs_deleted�flush_total�get_exists_total�get_missing_total�	get_total�indexing_delete_total�indexing_index_total�indexing_noop_update_total�merges_total�merges_total_docs�#merges_total_auto_throttle_in_bytes�query_cache_cache_count�query_cache_cache_size�query_cache_evictions�query_cache_hit_count�query_cache_miss_count�query_cache_total_count�
refresh_total�request_cache_hit_count�request_cache_miss_count�search_fetch_total�search_open_contexts�search_query_total�search_scroll_total�search_suggest_total�segments_count�%segments_max_unsafe_auto_id_timestamp�warmer_total�get_exists_time_in_millis�get_missing_time_in_millis)rr)/r(r)r*r+r)r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrRrSrTrU)r�urllib2r�getr�timeZget_agent_cache�json�loads�read�	Exception�str�floatr�lower�strip�
ValueError�typeZabsolute_to_per_secondZset_agent_cache)�self�configr�resultsZ
next_cache�requestZraw_responseZ
prev_cache�jZ
delta_keysrZconstructors�key�value�cr)r%r�runs�	
	"

z
Plugin.runN)�__name__�
__module__�__qualname__rkrrrrrsr�__main__)�urllib.parserr�urllib.requestrr�urllib.errorr�ImportError�urllibrVrXZpluginsrYrZ
BasePluginrrl�executerrrr�<module>sm

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists