o
    *b>  ã                   @   s6   d dl mZmZmZ d dlmZ G dd„ deeƒZdS )é    )ÚPluginÚRedHatPluginÚ	PluginOpt)Úglobc                   @   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ƒ4}|D ](}| d¡d  ¡ }z| dd¡\}}| ¡ dkr(| ¡ }W q
 ty2   Y q
w W d  ƒ |S 1 s>w   Y  |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Úrú#r   ú=é   zlog-dir)ÚopenÚsplitÚstripÚ
ValueError)Úselfr	   Ú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|  |¡}|r%|}W n tyA } z|  d||f ¡ W Y d}~nd}~ww |  d¡rPt|   |d	¡ƒ}nt|   |d
¡ƒt|   |d¡ƒ }|  |¡ t|   d¡ƒD ]	}|  d| ¡ qldS )zªCollect 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 %s: %sNZall_logsÚ*z*.stdoutz*.stderrz/dev/watchdog*zwdctl %s)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   s8   
þþ
€€ÿ
ÿ
ÿ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)Zsos.report.pluginsr   r   r   r   r   r   r   r   r   Ú<module>   s   
