U
    -_g                     @   sV   d dl mZmZmZmZmZ G dd deZG dd deeZG dd deeeZdS )	    )PluginRedHatPluginDebianPluginUbuntuPlugin	PluginOptc                   @   s@   e Zd ZdZdZdZdZdZdZdZ	e
dd	d
dgZdd ZdS )Apachea  The Apache plugin covers the upstream Apache webserver project,
    regardless of the packaged name; apache2 for Debian and Ubuntu, or httpd
    for Red Hat family distributions.

    The aim of this plugin is for Apache-specific information, not necessarily
    other projects that happen to place logs or similar files within the
    standardized apache directories. For example, OpenStack components that log
    to apache logging directories are excluded from this plugin and collected
    via their respective OpenStack plugins.

    Users can expect the collection of apachectl command output, apache server
    logs, and apache configuration files from this plugin.
    zApache http daemonZapache)Z	webserverZ	openshift)httpd)z	/var/www/NlogFzgathers all apache logs)namedefaultZdescc                    sX    j ddgdd  j ddd dd	d
dddddddddg}  fdd|D  d S )Nzapachectl -Szapachectl -tT)Z
cmd_as_tagzapachectl -MZhttpd_MZtagsZaodhZ
ceilometerZcinderZforemanZgnocchiZhorizonZkeystoneZmanilaZnovaZoctaviaZ	placementZpulpc                    s    g | ]}d  j  d| dqS )z	/var/log/z*/*)	apachepkg).0subself ;/usr/lib/python3/dist-packages/sos/report/plugins/apache.py
<listcomp>?   s    z Apache.setup.<locals>.<listcomp>)Zadd_cmd_outputadd_forbidden_path)r   Zsubdirsr   r   r   setup'   s.    zApache.setup)__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesZpackagesfilesr   r   Zoption_listr   r   r   r   r   r      s   r   c                       s(   e Zd ZdZdZdZ fddZ  ZS )RedHatApachea~  
    On Red Hat distributions, the Apache plugin will also attempt to collect
    JBoss Web Server logs and configuration files.

    Note that for Red Hat distributions, this plugin explicitly collects for
    'httpd' installations. If you have installed apache from source or via any
    method that uses the name 'apache' instead of 'httpd', these collections
    will fail.
    )z/etc/httpd/conf/httpd.confz/etc/httpd22/conf/httpd.confz/etc/httpd24/conf/httpd.confr   c           
         s   |  ddddd t   dddg}d	d
 |D }dddg}dd
 |D }ddddg}| dd
 |D  |D ]&}|D ]}| j| d| dd qzqr| ds| dr| | n(|D ]"}|D ]}	| | d|	  qq| jddd d S )NZhttpd_access_logZhttpd_error_logZhttpd_ssl_access_logZhttpd_ssl_error_log)z/var/log/httpd/access_logz/var/log/httpd/error_logz/var/log/httpd/ssl_access_logz/var/log/httpd/ssl_error_log Z22Z24c                 S   s   g | ]}d | qS )z
/etc/httpdr   r   Zverr   r   r   r   e   s     z&RedHatApache.setup.<locals>.<listcomp>zconf/*.confzconf.d/*.confzconf.modules.d/*.confc                 S   s   g | ]}d | qS )z/var/log/httpdr   r   r   r   r   r   n   s     Z
access_logZ	error_logZssl_access_logZssl_error_logc                 S   s   g | ]}| d qS )z/conf/password.confr   )r   etcr   r   r   r   v   s    /Z
httpd_confr   r	   all_logsr   Zsystemctl_httpd)Zadd_file_tagssuperr   r   add_copy_spec
get_optionadd_service_status)
r   ZversZetcdirsZconfsZlogdirsZlogsZedirconfZldirr	   	__class__r   r   r   U   s>    


zRedHatApache.setup)r   r   r   r   r   r   r   __classcell__r   r   r(   r   r   D   s   	r   c                       s$   e Zd ZdZdZ fddZ  ZS )DebianApache)z/etc/apache2/apache2.confapache2c                    sZ   t    | ddg | d | dddddg | d	sJ| d
rV| dg d S )Nz/etc/apache2/*z/etc/default/apache2r,   z/var/log/apache2/access.logz/var/log/apache2/error.logz/var/log/apache2/ssl_access.logz/var/log/apache2/ssl_error.logz(/var/log/apache2/other_vhosts_access.logr	   r"   z/var/log/apache2)r#   r   r$   r&   r%   r   r(   r   r   r      s"    

zDebianApache.setup)r   r   r   r   r   r   r*   r   r   r(   r   r+      s   r+   N)	Zsos.report.pluginsr   r   r   r   r   r   r   r+   r   r   r   r   <module>	   s   7D