Bug 1356945

Summary: Monit plugin traceback on rhel-7
Product: Red Hat Enterprise Linux 7 Reporter: Miroslav Hradílek <mhradile>
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Miroslav Hradílek <mhradile>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: agk, bmr, gavin, plambri, sbradley
Target Milestone: beta   
Target Release: 7.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sos-3.3-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 04:58:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miroslav Hradílek 2016-07-15 10:50:57 UTC
Description of problem:
Part of the rebased unreleased sos package is an addition of monit.py plugin which fails to execute when forced to run via '-o monit'.

Version-Release number of selected component (if applicable):
Unreleased sos-3.3-1.el7.noarch

How reproducible:
100%

Actual results:
# sosreport --batch -o monit
. . .
 Setting up plugins ...
caught exception in plugin method "monit.setup()"
writing traceback to sos_logs/monit-plugin-errors.txt
 Running plugins. Please wait ...
. . .
# tar -xf /var/tmp/sosreport-hostname-20160715064051.tar.xz
# cat sosreport-hostname-20160715064051/sos_logs/monit-plugin-errors.txt 
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1247, in setup
    plug.setup()
  File "/usr/lib/python2.7/site-packages/sos/plugins/monit.py", line 41, in setup
    self.add_copy_spec([self.monit_log, self.monit_conf])
  File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line 559, in add_copy_spec
    copy_paths = self._expand_copy_spec(copyspec)
  File "/usr/lib/python2.7/site-packages/sos/plugins/__init__.py", line 796, in _expand_copy_spec
    return glob.glob(copyspec)
  File "/usr/lib64/python2.7/glob.py", line 27, in glob
    return list(iglob(pathname))
  File "/usr/lib64/python2.7/glob.py", line 38, in iglob
    if not has_magic(pathname):
  File "/usr/lib64/python2.7/glob.py", line 95, in has_magic
    return magic_check.search(s) is not None
TypeError: expected string or buffer


Expected results:
Exit gracefully.

Additional info:
We do not have a 'monit' package in RHEL.

Comment 1 Bryn M. Reeves 2016-07-15 11:00:45 UTC
The plugin (as submitted) is completely broken (and we relied on user testing & missed it during review). It attempts to pass a list, of two lists, of strings as an argument to add_copy_spec():

     39     def setup(self):
     40         self.add_cmd_output("monit status")
     41         self.add_copy_spec([self.monit_log, self.monit_conf])

Of course this won't work: a_c_s() expects a string, or a list of strings.

It's fine to either join the lists:

     39     def setup(self):
     40         self.add_cmd_output("monit status")
     41         self.add_copy_spec(self.monit_log + self.monit_conf)

Or make two separate calls for each:

     39     def setup(self):
     40         self.add_cmd_output("monit status")
     41         self.add_copy_spec(self.monit_log)
     42         self.add_copy_spec(self.monit_conf)

I'll push the first of these as a fix upstream & Pavel should be able to pick it up shortly.

Comment 3 Pavel Moravec 2016-07-18 07:57:58 UTC
Fixed in upstream commit c746b80e91bbab8c40a0c8cc5607a221b2bed09f

Comment 7 errata-xmlrpc 2016-11-04 04:58:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2380.html