U
    -_g                     @   s6   d dl m Z  d dlmZmZmZ G dd deeZdS )    )glob)PluginRedHatPlugin	PluginOptc                   @   s<   e Zd ZdZdZdZdZeddddgZd	d
 Z	dd Z
dS )WatchdogzWatchdog information.watchdog)system)r   	conf-filez/etc/watchdog.confzwatchdog config file)defaultZdescc              
   C   s|   d}t |ddd`}|D ]T}|dd  }z(|dd\}}| d	krT| }W q tk
rj   Y qX qW 5 Q R X |S )
a  Get watchdog log directory.

            Get watchdog log directory path configured in ``conf_file``.

            :returns: The watchdog log directory path.
            :returntype: str.
            :raises: IOError if ``conf_file`` is not readable.
        NrzUTF-8)encoding#r   =   zlog-dir)opensplitstrip
ValueError)self	conf_filelog_dirZconf_flinekeyvalue r   =/usr/lib/python3/dist-packages/sos/report/plugins/watchdog.pyget_log_dir   s    	zWatchdog.get_log_dirc              
   C   s   |  | d}|  d}| |dg | ddg z| |}|rJ|}W n8 tk
r } z| d| d|  W 5 d}~X Y nX | d	rt|  |d
}n t|  |dt|  |d }| | t|  dD ]}| d|  qdS )zCollect watchdog information.

            Collect configuration files, custom executables for test-binary
            and repair-binary, and stdout/stderr logs.
        r	   z/var/log/watchdogz/etc/sysconfig/watchdogz/etc/watchdog.dz/usr/libexec/watchdog/scriptszCould not read z: NZall_logs*z*.stdoutz*.stderrz/dev/watchdog*zwdctl )Z	path_joinZ
get_optionZadd_copy_specr   IOErrorZ	_log_warnr   Zadd_cmd_output)r   r   r   resexZ	log_filesZdevr   r   r   setup4   s0    

(

zWatchdog.setupN)__name__
__module____qualname__Z
short_descZplugin_nameZprofilesZpackagesr   Zoption_listr   r!   r   r   r   r   r      s   r   N)r   Zsos.report.pluginsr   r   r   r   r   r   r   r   <module>   s   