3 ܓiA @s.ddlZddlmZmZGdddeeZdS)N)PluginIndependentPluginc@s0eZdZdZdZd Zd Zd ZddZddZ dS) OpenSearchzOpenSearch service opensearchservicesc Csd}d}yt|dd}x||D]t}tjd|}tjd|}|rnt|jdkrn|jdj}tjd d |}q|rt|jdkr|jdj}qWWd QRXWn8tk r}z|jd |d |WYd d }~XnX||fS)z Get hostname and port number Z localhostZ9200zUTF-8)encodingz(^network.host):(.*)z(^http.port):(.*)z"|\'NzFailed to parse z: r ) openresearchlengroupsstripsub ExceptionZ _log_info) selfopensearch_config_fileZhostnameportZfreadlineZ network_hostZ network_porterrr /usr/lib/python3.6/opensearch.pyget_hostname_ports    "(zOpenSearch.get_hostname_portc Cs|jd}|j||jdr*|jdn |jd|j|\}}|d|}|jd|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)r)r)r) __name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZpackagesrrrrrrrrsr)r Zsos.report.pluginsrrrrrrr s