a >h @s.ddlZddlmZmZGdddeeZdS)N)PluginIndependentPluginc@s,eZdZdZdZdZdZddZddZd S) ElasticzElasticSearch serviceZelastic)Zservices)Z elasticsearchc Csd}d}zt|dd}|D]t}td|}td|}|rlt|dkrl|d}td d |}q|rt|dkr|d}qWd n1s0YWn:ty}z"|d |d |WYd }~n d }~00||fS)z Get hostname and port number Z localhostZ9200zUTF-8)encodingz(^network.host):(.*)z(^http.port):(.*)z"|\'NzFailed to parse z: ) openresearchlengroupsstripsub ExceptionZ _log_info) selfels_config_filehostnameportZfreadlineZ network_hostZ network_porterrr>/usr/lib/python3.9/site-packages/sos/report/plugins/elastic.pyget_hostname_ports   4,zElastic.get_hostname_portc Cs|d}|||dr*|dn |d||\}}|d|}|d|dd|dd|d d|d d|d d|d d|d gdS)Nz$/etc/elasticsearch/elasticsearch.ymlZall_logsz/var/log/elasticsearch/*z/var/log/elasticsearch/*.log:z curl -X GET 'z/_cluster/settings?pretty'z/_cluster/health?pretty'z/_cluster/stats?pretty'z/_cat/nodes?v'z/_cat/indices'z /_cat/shards'z/_cat/aliases')Z path_joinZ add_copy_specZ get_optionrZadd_cmd_output)rrhostrZendpointrrrsetup*s$            z Elastic.setupN) __name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZpackagesrrrrrrrs r)r Zsos.report.pluginsrrrrrrr s