debug = options.debug try: amount_of_workers = int(args[0]) except (IndexError, ValueError): amount_of_workers = 1 devices_list = [] # (c) 2015, GPLv3, Daniel Preussker <*****@*****.**> <<<EOC2 if service_group is not False: query = "SELECT DISTINCT(`services`.`device_id`) FROM `services` LEFT JOIN `devices` ON `services`.`device_id` = `devices`.`device_id` WHERE `devices`.`poller_group` IN(" + service_group + ") AND `devices`.`disabled` = 0" else: query = "SELECT DISTINCT(`services`.`device_id`) FROM `services` LEFT JOIN `devices` ON `services`.`device_id` = `devices`.`device_id` WHERE `devices`.`disabled` = 0" # EOC2 db = LNMS.db_open(db_socket, db_server, db_port, db_username, db_password, db_dbname) cursor = db.cursor() cursor.execute(query) devices = cursor.fetchall() for row in devices: devices_list.append(int(row[0])) # (c) 2015, GPLv3, Daniel Preussker <*****@*****.**> <<<EOC3 if servicedisco and not IsNode: query = "SELECT MAX(`device_id`), MIN(`device_id`) FROM `services`" cursor.execute(query) devices = cursor.fetchall() maxlocks = devices[0][0] or 0 minlocks = devices[0][1] or 0 # EOC3 db.close()
""" This query specificly orders the results depending on the last_polled_timetaken variable Because this way, we put the devices likely to be slow, in the top of the queue thus greatening our chances of completing _all_ the work in exactly the time it takes to poll the slowest device! cool stuff he """ # (c) 2015, GPLv3, Daniel Preussker <*****@*****.**> <<<EOC2 if poller_group is not False: query = 'select device_id from devices where poller_group IN(' + poller_group + \ ') and disabled = 0 order by last_polled_timetaken desc' else: query = 'select device_id from devices where disabled = 0 order by last_polled_timetaken desc' # EOC2 db = LNMS.db_open(config['db_socket'], config['db_host'], config['db_port'], config['db_user'], config['db_pass'], config['db_name']) cursor = db.cursor() cursor.execute(query) devices = cursor.fetchall() for row in devices: devices_list.append(int(row[0])) # (c) 2015, GPLv3, Daniel Preussker <*****@*****.**> <<<EOC3 if distpoll and not IsNode: query = "select max(device_id),min(device_id) from devices" cursor.execute(query) devices = cursor.fetchall() maxlocks = devices[0][0] or 0 minlocks = devices[0][1] or 0 # EOC3 db.close()
""" # (c) 2015, GPLv3, Daniel Preussker <*****@*****.**> <<<EOC2 if discovery_group is not False: query = ( "select device_id from devices where poller_group IN(" + discovery_group + ") and disabled = 0 order by last_polled_timetaken desc" ) else: query = "select device_id from devices where disabled = 0 order by last_polled_timetaken desc" # EOC2 db = LNMS.db_open( config["db_socket"], config["db_host"], int(config["db_port"]), config["db_user"], config["db_pass"], config["db_name"], ) cursor = db.cursor() cursor.execute(query) devices = cursor.fetchall() for row in devices: devices_list.append(int(row[0])) # (c) 2015, GPLv3, Daniel Preussker <*****@*****.**> <<<EOC3 if distdisco and not IsNode: query = "select max(device_id),min(device_id) from devices" cursor.execute(query) devices = cursor.fetchall() maxlocks = devices[0][0] or 0 minlocks = devices[0][1] or 0