3 ܓi @s.ddlZddlmZmZGdddeeZdS)N)PluginIndependentPluginc@s,eZdZdZdZd Zd ZddZddZd S) ElasticzElasticSearch serviceZelasticservices elasticsearchc 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) selfels_config_fileZhostnameportZfreadlineZ network_hostZ network_porterrr/usr/lib/python3.6/elastic.pyget_hostname_ports    "(zElastic.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/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)r)r) __name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZpackagesrrrrrrrs r)r Zsos.report.pluginsrrrrrrr s