�
i��d� � �4 � d dl mZmZ d dlZ G d� dee� Zy)� )�Plugin�IndependentPluginNc �( � e Zd ZdZdZdZdZd� Zd� Zy)�ElasticzElasticSearch service�elastic)�services)�
elasticsearchc �L � d}d} t |� 5 }|D ]� }t j d|� }t j d|� }|rUt |j � � dk( r9|j � d j � }t j dd|� }��|s��t |j � � dk( s��|j � d j � }�� d d d � ||fS # 1 sw Y �
xY w# t $ r$}| j d |�d
|��� Y d }~||fS d }~ww xY w)N� localhost�9200z(^network.host):(.*)z(^http.port):(.*)� ���z"|\'� zFailed to parse z: ) �open�re�search�len�groups�strip�sub� Exception� _log_info) �self�els_config_file�hostname�port�fread�line�network_host�network_port�es �</usr/lib/python3/dist-packages/sos/report/plugins/elastic.py�get_hostname_portzElastic.get_hostname_port s" � ����� L��o�&�
A�%�!� A�D�#%�9�9�-D�d�#K�L�#%�9�9�-A�4�#H�L�#��L�,?�,?�,A�(B�a�(G�#/�#6�#6�#8��#<�#B�#B�#D��#%�6�6�'�2�x�#@�� �#��L�,?�,?�,A�(B�a�(G�+�2�2�4�R�8�>�>�@��A�
A� ��~��
A�
A�� � L��N�N���J�K�K���~��� L�s; �C6 �BC*�C*�:#C*�C6 �*C3�/C6 �6 D#�?D�D#c
�B � | j d� }| j |� | j d� r| j d� n| j d� | j |� \ }}|dz |z }| j d|z d|z d|z d |z d
|z d|z d|z g� y )
Nz$/etc/elasticsearch/elasticsearch.yml�all_logsz/var/log/elasticsearch/*z/var/log/elasticsearch/*.log�:z)curl -X GET '%s/_cluster/settings?pretty'z'curl -X GET '%s/_cluster/health?pretty'z&curl -X GET '%s/_cluster/stats?pretty'zcurl -X GET '%s/_cat/nodes?v'zcurl -X GET '%s/_cat/indices'zcurl -X GET '%s/_cat/shards'zcurl -X GET '%s/_cat/aliases')� path_join�
add_copy_spec�
get_optionr# �add_cmd_output)r r �hostr �endpoints r" |