From c2e2d53a16591489252f651272648b2f9b3c0d73 Mon Sep 17 00:00:00 2001 From: ryanaudiencepi Date: Tue, 1 Oct 2013 03:39:43 +0800 Subject: [PATCH 1/3] Fix monit module. Use lowercase letters check instead of uppercase --- library/monitoring/monit | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/monitoring/monit b/library/monitoring/monit index a21540fc53..3856ce7e6c 100644 --- a/library/monitoring/monit +++ b/library/monitoring/monit @@ -100,7 +100,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s stop %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'Not monitored' in out or 'stop pending' in out: + if 'not monitored' in out or 'stop pending' in out: module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -109,7 +109,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s unmonitor %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'Not monitored' in out: + if 'not monitored' in out: module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -118,7 +118,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s stop %s' % (MONIT, name)) rc, out, err = module.run_command('%s start %s' % (MONIT, name)) - if 'Initializing' in out or 'start pending' in out: + if 'initializing' in out or 'start pending' in out: module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -127,7 +127,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s start %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'Initializing' in out or 'start pending' in out: + if 'initializing' in out or 'start pending' in out: module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -136,7 +136,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s monitor %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'Initializing' in out or 'start pending' in out: + if 'initializing' in out or 'start pending' in out: module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) From 9da0ae2a1fa17c799e206eca678f521e684cbd1a Mon Sep 17 00:00:00 2001 From: ryanaudiencepi Date: Tue, 1 Oct 2013 03:41:17 +0800 Subject: [PATCH 2/3] Fix monit module. Monit restart bug --- library/monitoring/monit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/monitoring/monit b/library/monitoring/monit index 3856ce7e6c..e40768f642 100644 --- a/library/monitoring/monit +++ b/library/monitoring/monit @@ -116,9 +116,9 @@ def main(): elif state == 'restarted': if module.check_mode: module.exit_json(changed=True) - module.run_command('%s stop %s' % (MONIT, name)) - rc, out, err = module.run_command('%s start %s' % (MONIT, name)) - if 'initializing' in out or 'start pending' in out: + module.run_command('%s restart %s' % (MONIT, name)) + rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) + if 'initializing' in out or 'restart pending' in out: module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) From cd6d4f70c048e470c4058471f71063e0fac038bc Mon Sep 17 00:00:00 2001 From: ryanaudiencepi Date: Thu, 3 Oct 2013 02:46:35 +0800 Subject: [PATCH 3/3] Monit fix - Use case insensitive comparison --- library/monitoring/monit | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/monitoring/monit b/library/monitoring/monit index e40768f642..79ef5aa752 100644 --- a/library/monitoring/monit +++ b/library/monitoring/monit @@ -100,7 +100,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s stop %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'not monitored' in out or 'stop pending' in out: + if 'not monitored' in out.lower() or 'stop pending' in out.lower(): module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -109,7 +109,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s unmonitor %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'not monitored' in out: + if 'not monitored' in out.lower(): module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -118,7 +118,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s restart %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'initializing' in out or 'restart pending' in out: + if 'initializing' in out.lower() or 'restart pending' in out.lower(): module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -127,7 +127,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s start %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'initializing' in out or 'start pending' in out: + if 'initializing' in out.lower() or 'start pending' in out.lower(): module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out) @@ -136,7 +136,7 @@ def main(): module.exit_json(changed=True) module.run_command('%s monitor %s' % (MONIT, name)) rc, out, err = module.run_command('%s summary | grep %s' % (MONIT, name)) - if 'initializing' in out or 'start pending' in out: + if 'initializing' in out.lower() or 'start pending' in out.lower(): module.exit_json(changed=True, name=name, state=state) module.fail_json(msg=out)