
    -_g	                     4    d dl Z d dlmZmZ  G d dee      Zy)    N)PluginIndependentPluginc                   (    e Zd ZdZdZdZdZd Zd Zy)ElasticzElasticSearch serviceelastic)services)elasticsearchc                 P   d}d}	 t        |d      5 }|D ]  }t        j                  d|      }t        j                  d|      }|rUt        |j	                               dk(  r9|j	                         d   j                         }t        j                  d	d
|      }|st        |j	                               dk(  s|j	                         d   j                         } 	 ddd       ||fS # 1 sw Y   xY w# t        $ r$}| j                  d| d|        Y d}~||fS d}~ww xY w)z Get hostname and port number 	localhost9200zUTF-8)encodingz(^network.host):(.*)z(^http.port):(.*)   z"|\' NzFailed to parse z: )	openresearchlengroupsstripsub	Exception	_log_info)	selfels_config_filehostnameportfreadlinenetwork_hostnetwork_porterrs	            </usr/lib/python3/dist-packages/sos/report/plugins/elastic.pyget_hostname_portzElastic.get_hostname_port   s.   	Ho8 	AE! AD#%99-Dd#KL#%99-A4#HL#L,?,?,A(Ba(G#/#6#6#8#<#B#B#D#%66'2x#@ #L,?,?,A(Ba(G+224R8>>@A	A ~	A 	A  	HNN-o->bFGG~	Hs;   C8 BC,C,<#C, C8 ,C51C8 8	D%D  D%c                 P   | j                  d      }| j                  |       | j                  d      r| j                  d       n| j                  d       | j                  |      \  }}|dz   |z   }| j	                  d| dd| dd| d	d| d
d| dd| dd| dg       y )Nz$/etc/elasticsearch/elasticsearch.ymlall_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')	path_joinadd_copy_spec
get_optionr$   add_cmd_output)r   r   hostr   endpoints        r#   setupzElastic.setup*   s    ..2
 	?+??:&9:=>++O<
d#:$z)CDz)ABz)@Az8z8z7z8
 	    N)	__name__
__module____qualname__
short_descplugin_nameprofilespackagesr$   r.    r/   r#   r   r      s     (JKH!H&r/   r   )r   sos.report.pluginsr   r   r   r7   r/   r#   <module>r9      s    
 80f' 0r/   