mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
* add support for all monit service types
* ignore case when performing check
* add changelog
* Escape special characters before matching
Co-authored-by: Felix Fontein <felix@fontein.de>
* escape each element individually
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit bed1dc479f
)
Co-authored-by: Graham Herceg <g.a.herceg@gmail.com>
This commit is contained in:
parent
56055d4f1e
commit
4f7d44aa10
3 changed files with 36 additions and 12 deletions
|
@ -62,6 +62,9 @@ STATE_COMMAND_MAP = {
|
|||
'restarted': 'restart'
|
||||
}
|
||||
|
||||
MONIT_SERVICES = ['Process', 'File', 'Fifo', 'Filesystem', 'Directory', 'Remote host', 'System', 'Program',
|
||||
'Network']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class StatusValue(namedtuple("Status", "value, is_pending")):
|
||||
|
@ -151,7 +154,9 @@ class Monit(object):
|
|||
return self._parse_status(out, err)
|
||||
|
||||
def _parse_status(self, output, err):
|
||||
if "Process '%s'" % self.process_name not in output:
|
||||
escaped_monit_services = '|'.join([re.escape(x) for x in MONIT_SERVICES])
|
||||
pattern = "(%s) '%s'" % (escaped_monit_services, re.escape(self.process_name))
|
||||
if not re.search(pattern, output, re.IGNORECASE):
|
||||
return Status.MISSING
|
||||
|
||||
status_val = re.findall(r"^\s*status\s*([\w\- ]+)", output, re.MULTILINE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue