a >hA @s.ddlZddlmZmZGdddeeZdS)N)PluginIndependentPluginc@s0eZdZdZdZdZdZdZddZddZ d S) OpenSearchzOpenSearch service opensearch)services)rc 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) selfopensearch_config_filehostnameportZfreadlineZ network_hostZ network_porterrrA/usr/lib/python3.9/site-packages/sos/report/plugins/opensearch.pyget_hostname_ports   4,zOpenSearch.get_hostname_portc Cs|d}|||dr*|dn |d||\}}|d|}|d|dd|dd|d d|d d|d d|d d|d gdS)Nz/etc/opensearch/opensearch.ymlZall_logsz/var/log/opensearch/*z/var/log/opensearch/*.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$            zOpenSearch.setupN) __name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZpackagesrrrrrrrrsr)r Zsos.report.pluginsrrrrrrr s