Python wrapper sql cleanup (#11628)

* Clean up wrapp mysql connect a bit

* fix typo
This commit is contained in:
Tony Murray
2020-05-19 10:14:09 -05:00
committed by GitHub
parent 3985ce74ce
commit 0b68c70a97
4 changed files with 9 additions and 108 deletions

View File

@@ -183,20 +183,6 @@ if __name__ == '__main__':
poller_path = config['install_dir'] + '/poller.php'
log_dir = config['log_dir']
# TODO: Use LibreNMS.DB
db_username = config['db_user']
db_password = config['db_pass']
db_port = int(config['db_port'])
if config['db_socket']:
db_server = config['db_host']
db_socket = config['db_socket']
else:
db_server = config['db_host']
db_socket = None
db_dbname = config['db_name']
if 'rrd' in config and 'step' in config['rrd']:
step = config['rrd']['step']
else:
@@ -292,7 +278,7 @@ if __name__ == '__main__':
query = 'select device_id from devices where disabled = 0 order by last_polled_timetaken desc'
# EOC2
db = LNMS.db_open(db_socket, db_server, db_port, db_username, db_password, db_dbname)
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()
@@ -366,7 +352,7 @@ if __name__ == '__main__':
show_stopper = False
db = LNMS.db_open(db_socket, db_server, db_port, db_username, db_password, db_dbname)
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()
query = "update pollers set last_polled=NOW(), devices='%d', time_taken='%d' where poller_name='%s'" % (
polled_devices,