def do_work(self, run_type, group): if run_type == "poll": info("Polling billing") LibreNMS.call_script("poll-billing.php") else: # run_type == 'calculate' info("Calculating billing") LibreNMS.call_script("billing-calculate.php")
def do_work(self, context, group): if self.lock(group, 'group', timeout=self.config.ping.frequency): try: info("Running fast ping") LibreNMS.call_script('ping.php', ('-g', group)) finally: self.unlock(group, 'group')
def do_work(self, context, group): if self.lock(group, 'group', timeout=self.config.ping.frequency): try: info("Running fast ping") LibreNMS.call_script('ping.php', ('-g', group)) finally: self.unlock(group, 'group')
def do_work(self, run_type, group): if run_type == 'poll': info("Polling billing") LibreNMS.call_script('poll-billing.php') else: # run_type == 'calculate' info("Calculating billing") LibreNMS.call_script('billing-calculate.php')
def do_work(self, context, group): if self.lock(group, "group", timeout=self.config.ping.frequency): try: info("Running fast ping") LibreNMS.call_script("ping.php", ("-g", group)) finally: self.unlock(group, "group")
def do_work(self, device_id, group): try: info("Checking alerts") LibreNMS.call_script('alerts.php') except subprocess.CalledProcessError as e: if e.returncode == 1: warning("There was an error issuing alerts: {}".format(e.output)) else: raise
def do_work(self, device_id, group): try: info("Checking alerts") LibreNMS.call_script("alerts.php") except subprocess.CalledProcessError as e: if e.returncode == 1: warning("There was an error issuing alerts: {}".format( e.output)) else: raise
def do_work(self, device_id, group): if self.lock(device_id, timeout=self.config.services.frequency): try: info("Checking services on device {}".format(device_id)) LibreNMS.call_script('check-services.php', ('-h', device_id)) except subprocess.CalledProcessError as e: if e.returncode == 5: info("Device {} is down, cannot poll service, waiting {}s for retry" .format(device_id, self.config.down_retry)) self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: self.unlock(device_id)
def do_work(self, run_type, group): if run_type == "poll": logger.info("Polling billing") exit_code, output = LibreNMS.call_script("poll-billing.php") if exit_code != 0: logger.warning("Error {} in Polling billing:\n{}".format( exit_code, output)) else: # run_type == 'calculate' logger.info("Calculating billing") exit_code, output = LibreNMS.call_script("billing-calculate.php") if exit_code != 0: logger.warning("Error {} in Calculating billing:\n{}".format( exit_code, output))
def do_work(self, device_id, group): if self.lock(device_id, timeout=LibreNMS.normalize_wait(self.config.discovery.frequency)): try: info("Discovering device {}".format(device_id)) LibreNMS.call_script('discovery.php', ('-h', device_id)) except subprocess.CalledProcessError as e: if e.returncode == 5: info("Device {} is down, cannot discover, waiting {}s for retry" .format(device_id, self.config.down_retry)) self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: self.unlock(device_id) else: self.unlock(device_id)
def do_work(self, device_id, group): if self.lock(device_id, timeout=self.config.services.frequency): try: info("Checking services on device {}".format(device_id)) LibreNMS.call_script("check-services.php", ("-h", device_id)) except subprocess.CalledProcessError as e: if e.returncode == 5: info( "Device {} is down, cannot poll service, waiting {}s for retry" .format(device_id, self.config.down_retry)) self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: self.unlock(device_id)
def run_maintenance(self): """ Runs update and cleanup tasks by calling daily.sh. Reloads the python script after the update. Sets a schema-update lock so no distributed pollers will update until the schema has been updated. """ attempt = 0 wait = 5 max_runtime = 86100 max_tries = int(max_runtime / wait) logger.info("Waiting for schema lock") while not self._lm.lock("schema-update", self.config.unique_name, max_runtime): attempt += 1 if attempt >= max_tries: # don't get stuck indefinitely logger.warning( "Reached max wait for other pollers to update, updating now" ) break sleep(wait) logger.info("Running maintenance tasks") exit_code, output = LibreNMS.call_script("daily.sh") if exit_code == 0: logger.info("Maintenance tasks complete\n{}".format(output)) else: logger.error("Error {} in daily.sh:\n{}".format(exit_code, output)) self._lm.unlock("schema-update", self.config.unique_name) self.restart()
def run_maintenance(self): """ Runs update and cleanup tasks by calling daily.sh. Reloads the python script after the update. Sets a schema-update lock so no distributed pollers will update until the schema has been updated. """ attempt = 0 wait = 5 max_runtime = 86100 max_tries = int(max_runtime / wait) info("Waiting for schema lock") while not self._lm.lock('schema-update', self.config.unique_name, max_runtime): attempt += 1 if attempt >= max_tries: # don't get stuck indefinitely warning( 'Reached max wait for other pollers to update, updating now' ) break sleep(wait) info("Running maintenance tasks") try: output = LibreNMS.call_script('daily.sh') info("Maintenance tasks complete\n{}".format(output)) except subprocess.CalledProcessError as e: error("Error in daily.sh:\n" + (e.output.decode() if e.output is not None else 'No output')) self._lm.unlock('schema-update', self.config.unique_name) self.restart()
def do_work(self, device_id, group): if self.lock(device_id, timeout=self.config.poller.frequency): logger.info("Polling device {}".format(device_id)) exit_code, output = LibreNMS.call_script("poller.php", ("-h", device_id)) if exit_code == 0: self.unlock(device_id) else: if exit_code == 6: logger.warning( "Polling device {} unreachable, waiting {}s for retry". format(device_id, self.config.down_retry)) # re-lock to set retry timer self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: logger.error( "Polling device {} failed with exit code {}: {}". format(device_id, exit_code, output)) self.unlock(device_id) else: logger.debug( "Tried to poll {}, but it is locked".format(device_id))
def do_work(self, device_id, group): logger.info("Checking alerts") exit_code, output = LibreNMS.call_script("alerts.php") if exit_code != 0: if exit_code == 1: logger.warning( "There was an error issuing alerts: {}".format(output)) else: raise CalledProcessError
def do_work(self, device_id, group): if self.lock(device_id, timeout=LibreNMS.normalize_wait( self.config.discovery.frequency)): try: info("Discovering device {}".format(device_id)) LibreNMS.call_script("discovery.php", ("-h", device_id)) except subprocess.CalledProcessError as e: if e.returncode == 5: info( "Device {} is down, cannot discover, waiting {}s for retry" .format(device_id, self.config.down_retry)) self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: self.unlock(device_id) else: self.unlock(device_id)
def do_work(self, device_id, group): if self.lock(device_id, timeout=self.config.poller.frequency): info('Polling device {}'.format(device_id)) try: LibreNMS.call_script('poller.php', ('-h', device_id)) except subprocess.CalledProcessError as e: if e.returncode == 6: warning('Polling device {} unreachable, waiting {}s for retry'.format(device_id, self.config.down_retry)) # re-lock to set retry timer self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: error('Polling device {} failed! {}'.format(device_id, e)) self.unlock(device_id) else: self.unlock(device_id) else: debug('Tried to poll {}, but it is locked'.format(device_id))
def do_work(self, context, group): if self.lock(group, "group", timeout=self.config.ping.frequency): try: logger.info("Running fast ping") exit_code, output = LibreNMS.call_script( "ping.php", ("-g", group)) if exit_code != 0: logger.warning( "Running fast ping for {} failed with error code {}: {}" .format(group, exit_code, output)) finally: self.unlock(group, "group")
def do_work(self, device_id, group): if self.lock(device_id, timeout=self.config.poller.frequency): info("Polling device {}".format(device_id)) try: LibreNMS.call_script("poller.php", ("-h", device_id)) except subprocess.CalledProcessError as e: if e.returncode == 6: warning( "Polling device {} unreachable, waiting {}s for retry". format(device_id, self.config.down_retry)) # re-lock to set retry timer self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: error("Polling device {} failed! {}".format(device_id, e)) self.unlock(device_id) else: self.unlock(device_id) else: debug("Tried to poll {}, but it is locked".format(device_id))
def do_work(self, device_id, group): if self.lock(device_id, timeout=self.config.services.frequency): logger.info("Checking services on device {}".format(device_id)) exit_code, output = LibreNMS.call_script("check-services.php", ("-h", device_id)) if exit_code == 0: self.unlock(device_id) else: if exit_code == 5: logger.info( "Device {} is down, cannot poll service, waiting {}s for retry" .format(device_id, self.config.down_retry)) self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: logger.warning( "Unknown error while checking services on device {} with exit code {}: {}" .format(device_id, exit_code, output))
def do_work(self, device_id, group): if self.lock(device_id, timeout=LibreNMS.normalize_wait( self.config.discovery.frequency)): logger.info("Discovering device {}".format(device_id)) exit_code, output = LibreNMS.call_script("discovery.php", ("-h", device_id)) if exit_code == 0: self.unlock(device_id) else: if exit_code == 5: logger.info( "Device {} is down, cannot discover, waiting {}s for retry" .format(device_id, self.config.down_retry)) self.lock(device_id, allow_relock=True, timeout=self.config.down_retry) else: logger.error( "Discovering device {} failed with exit code {}: {}". format(device_id, exit_code, output)) self.unlock(device_id)
def run_maintenance(self): """ Runs update and cleanup tasks by calling daily.sh. Reloads the python script after the update. Sets a schema-update lock so no distributed pollers will update until the schema has been updated. """ attempt = 0 wait = 5 max_runtime = 86100 max_tries = int(max_runtime / wait) info("Waiting for schema lock") while not self._lm.lock('schema-update', self.config.unique_name, max_runtime): attempt += 1 if attempt >= max_tries: # don't get stuck indefinitely warning('Reached max wait for other pollers to update, updating now') break sleep(wait) info("Running maintenance tasks") output = LibreNMS.call_script('daily.sh') info("Maintenance tasks complete\n{}".format(output)) self.restart()