
    -_g                     <    d dl m Z  d dlmZmZmZ  G d dee      Zy)    )glob)PluginRedHatPlugin	PluginOptc                   @    e Zd ZdZdZdZdZ eddd      gZd	 Z	d
 Z
y)WatchdogzWatchdog information.watchdog)system)r	   	conf-filez/etc/watchdog.confzwatchdog config file)defaultdescc                 6   d}t        |dd      5 }|D ]]  }|j                  d      d   j                         }	 |j                  dd      \  }}|j                         d	k(  r|j                         }_ 	 ddd       |S # t        $ r Y vw xY w# 1 sw Y   |S xY w)
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_dirconf_flinekeyvalues          =/usr/lib/python3/dist-packages/sos/report/plugins/watchdog.pyget_log_dirzWatchdog.get_log_dir   s     )S73 
	v 	zz#q)//1#'::c1#5LS%yy{i/"'++-	
	 	 " 
	 s.   (B8A?2B?	BB
BBBc                    | j                  | j                  d            }| j                  d      }| j                  |dg       | j                  ddg       	 | j                  |      }|r|}| j                  d	      rt        | j                  |d
            }n7t        | j                  |d            t        | j                  |d            z   }| j                  |       t        | j                  d            D ]  }| j                  d|         y# t        $ r!}| j                  d| d|        Y d}~d}~ww xY w)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: Nall_logs*z*.stdoutz*.stderrz/dev/watchdog*zwdctl )	path_join
get_optionadd_copy_specr    IOError	_log_warnr   add_cmd_output)r   r   r   resex	log_filesdevs          r   setupzWatchdog.setup4   sC    NN4??;#?@	..!45 	%
 	 	+
 		@""9-C ??:&T^^GS9:IdnnWjABdnnWjABCI 	9% '789 	0C&/	0  	@NN_YKr">??	@s   D 	E D<<EN)__name__
__module____qualname__
short_descplugin_nameprofilespackagesr   option_listr    r.        r   r   r      s9    (JKHH 	+';-	/K
2'0r8   r   N)r   sos.report.pluginsr   r   r   r   r7   r8   r   <module>r:      s      > >L0v| L0r8   