File: //lib/python3.9/site-packages/sos/report/plugins/__pycache__/elastic.cpython-39.opt-1.pyc
a
^��cB � @ s. d dl mZmZ d dlZG dd� dee�ZdS )� )�Plugin�IndependentPluginNc @ s, e Zd ZdZdZdZdZdd� Zdd� Zd S )
�ElasticzElasticSearch serviceZelastic)Zservices)Z
elasticsearchc
C s� d}d}z�t |���}|D ]t}t�d|�}t�d|�}|rht|�� �dkrh|�� d �� }t�dd|�}q|rt|�� �dkr|�� d �� }qW d � n1 s�0 Y W n6 ty� } z| �d ||f � W Y d }~n
d }~0 0 ||fS )
NZ localhostZ9200z(^network.host):(.*)z(^http.port):(.*)� ���z"|\'� zFailed to parse %s: %s) �open�re�search�len�groups�strip�sub� ExceptionZ _log_info) �self�els_config_file�hostname�portZfread�lineZnetwork_hostZnetwork_port�e� r �>/usr/lib/python3.9/site-packages/sos/report/plugins/elastic.py�get_hostname_port s
4(zElastic.get_hostname_portc C sz | � d�}| �|� | �d�r*| �d� n
| �d� | �|�\}}|d | }| �d| d| d| d | d
| g� d S )Nz$/etc/elasticsearch/elasticsearch.ymlZall_logsz/var/log/elasticsearch/*z(/var/log/elasticsearch/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')Z path_joinZ
add_copy_specZ
get_optionr Zadd_cmd_output)r r �hostr Zendpointr r r �setup) s �
�z
Elastic.setupN) �__name__�
__module__�__qualname__Z
short_descZplugin_nameZprofilesZpackagesr r r r r r r s r )Zsos.report.pluginsr r r r r r r r �<module> s