o
    O6uf³  ã                   @   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 daemonÚapache)Ú	webserverÚ	openshift)Úhttpd)z	/var/www/NÚlogFzgathers all apache logs)ÚnameÚdefaultÚdescc                    sD   ˆ j ddgdd� ˆ j ddd� g d¢}ˆ  ‡ fd	d
„|D ƒ¡ d S )Nzapachectl -Szapachectl -tT)Ú
cmd_as_tagzapachectl -MÚhttpd_M©Útags)ÚaodhÚ
ceilometerÚcinderÚforemanÚgnocchiÚhorizonÚkeystoneÚmanilaÚnovaÚoctaviaÚ	placementÚ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>)Úadd_cmd_outputÚadd_forbidden_path)r%   Úsubdirsr&   r$   r'   Úsetup'   s   þýÿzApache.setup)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
short_descÚplugin_nameÚprofilesÚpackagesÚfilesr!   r   Ú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ƒ  ¡  g d¢}dd„ |D ƒ}g d	¢}d
d„ |D ƒ}g d¢}|  dd„ |D ƒ¡ |D ]}|D ]}| j|› d|› �dd� q9q5|  d¡sS|  d¡rY|  |¡ n|D ]}|D ]}	|  |› d|	› �¡ q_q[| jddd� d S )NÚhttpd_access_logÚhttpd_error_logÚhttpd_ssl_access_logÚ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)Ú Ú22Ú24c                 S   ó   g | ]}d |› �‘qS )z
/etc/httpdr&   ©r"   Úverr&   r&   r'   r(   e   ó    z&RedHatApache.setup.<locals>.<listcomp>)zconf/*.confzconf.d/*.confzconf.modules.d/*.confc                 S   r?   )z/var/log/httpdr&   r@   r&   r&   r'   r(   n   rB   )Ú
access_logÚ	error_logÚssl_access_logÚssl_error_logc                 S   s   g | ]}|› d �‘qS )z/conf/password.confr&   )r"   Úetcr&   r&   r'   r(   v   s    
ÿú/Ú
httpd_confr   r   Úall_logsr   Úsystemctl_httpd)Úadd_file_tagsÚsuperr,   r*   Úadd_copy_specÚ
get_optionÚadd_service_status)
r%   ÚversÚetcdirsÚconfsÚlogdirsÚlogsÚedirÚconfÚldirr   ©Ú	__class__r&   r'   r,   U   s4   ü

ÿÿÿzRedHatApache.setup)r-   r.   r/   r0   r5   r!   r,   Ú__classcell__r&   r&   rY   r'   r7   D   s
    	r7   c                       s$   e Zd ZdZdZ‡ fdd„Z‡  ZS )ÚDebianApache)z/etc/apache2/apache2.confÚapache2c                    sX   t ƒ  ¡  |  ddg¡ |  d¡ |  g d¢¡ |  d¡s"|  d¡r*|  dg¡ d S 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   rJ   z/var/log/apache2)rM   r,   rN   rP   rO   r$   rY   r&   r'   r,   Œ   s   
þ

ÿÿzDebianApache.setup)r-   r.   r/   r5   r!   r,   r[   r&   r&   rY   r'   r\   ˆ   s    r\   N)	Úsos.report.pluginsr   r   r   r   r   r   r7   r\   r&   r&   r&   r'   Ú<module>   s   7D