o
    id>                     @   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)default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_dir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 )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 %s: %sNall_logs*z*.stdoutz*.stderrz/dev/watchdog*zwdctl %s)	path_join
get_optionadd_copy_specr   IOError	_log_warnr   add_cmd_output)r   r	   r   resex	log_filesdevr   r   r   setup4   s8   



zWatchdog.setupN)__name__
__module____qualname__
short_descplugin_nameprofilespackagesr   option_listr   r)   r   r   r   r   r      s    r   N)sos.report.pluginsr   r   r   r   r   r   r   r   r   <module>   s   
