def restart(self): """Restart the LogicMonitor collector""" logging.debug("Running Collector.restart...") if self.platform == "Linux": logging.debug("Platform is Linux") logging.debug("Restarting logicmonitor-agent service") (output, err) = Service.doAction("logicmonitor-agent", "restart") if output != 0: self.fail( msg="Error: Failed starting logicmonitor-agent " + "service. " + err) logging.debug("Restarting logicmonitor-watchdog service") (output, err) = Service.doAction("logicmonitor-watchdog", "restart") if output != 0: self.fail( msg="Error: Failed starting logicmonitor-watchdog " + "service. " + err) else: (self.fail( msg="Error: LogicMonitor Collector must be installed " + "on a Linux device."))
def stop(self): """Stop the LogicMonitor collector""" logging.debug("Running Collector.stop...") if self.platform == "Linux": logging.debug("Platform is Linux") output = Service.getStatus("logicmonitor-agent") if "is running" in output: logging.debug("Service logicmonitor-agent is running") logging.debug("System changed") self.change = True if self.check_mode: self.exit(changed=True) logging.debug("Stopping service logicmonitor-agent") (output, err) = Service.doAction("logicmonitor-agent", "stop") if output != 0: self.fail( msg="Error: Failed stopping logicmonitor-agent " + "service. " + err) output = Service.getStatus("logicmonitor-watchdog") if "is running" in output: logging.debug("Service logicmonitor-watchdog is running") logging.debug("System changed") self.change = True if self.check_mode: self.exit(changed=True) logging.debug("Stopping service logicmonitor-watchdog") (output, err) = Service.doAction("logicmonitor-watchdog", "stop") if output != 0: self.fail( msg="Error: Failed stopping logicmonitor-watchdog " + "service. " + err) else: self.fail( msg="Error: LogicMonitor Collector must be " + "installed on a Linux device.")