mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-03 08:01:38 +02:00
Merge pull request #1302 from spinza/master
Add logic to poller-wrapper.py to handle non-standard mysql ports in …
This commit is contained in:
@@ -33,6 +33,7 @@ Contributors to LibreNMS:
|
|||||||
- James Campbell <neokjames@gmail.com> (neokjames)
|
- James Campbell <neokjames@gmail.com> (neokjames)
|
||||||
- Steve Calvário <calvario.steve@gmail.com> (Calvario)
|
- Steve Calvário <calvario.steve@gmail.com> (Calvario)
|
||||||
- Christian Marg <marg@rz.tu-clausthal.de> (einhirn)
|
- Christian Marg <marg@rz.tu-clausthal.de> (einhirn)
|
||||||
|
- Louis Rossouw <lrossouw@gmail.com> (spinza)
|
||||||
|
|
||||||
[1]: http://observium.org/ "Observium web site"
|
[1]: http://observium.org/ "Observium web site"
|
||||||
|
|
||||||
|
|||||||
+16
-2
@@ -81,9 +81,20 @@ except:
|
|||||||
poller_path = config['install_dir'] + '/poller.php'
|
poller_path = config['install_dir'] + '/poller.php'
|
||||||
db_username = config['db_user']
|
db_username = config['db_user']
|
||||||
db_password = config['db_pass']
|
db_password = config['db_pass']
|
||||||
db_server = config['db_host']
|
|
||||||
|
if config['db_host'][:5].lower() == 'unix:':
|
||||||
|
db_server = config['db_host']
|
||||||
|
db_port = 0
|
||||||
|
elif ':' in config['db_host']:
|
||||||
|
db_server = config['db_host'].rsplit(':')[0]
|
||||||
|
db_port = int(config['db_host'].rsplit(':')[1])
|
||||||
|
else:
|
||||||
|
db_server = config['db_host']
|
||||||
|
db_port =0
|
||||||
|
|
||||||
db_dbname = config['db_name']
|
db_dbname = config['db_name']
|
||||||
|
|
||||||
|
|
||||||
# (c) 2015, GPLv3, Daniel Preussker <f0o@devilcode.org> <<<EOC1
|
# (c) 2015, GPLv3, Daniel Preussker <f0o@devilcode.org> <<<EOC1
|
||||||
if 'distributed_poller_group' in config:
|
if 'distributed_poller_group' in config:
|
||||||
poller_group = str(config['distributed_poller_group'])
|
poller_group = str(config['distributed_poller_group'])
|
||||||
@@ -167,7 +178,10 @@ except:
|
|||||||
devices_list = []
|
devices_list = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = MySQLdb.connect(host=db_server, user=db_username, passwd=db_password, db=db_dbname)
|
if db_port == 0:
|
||||||
|
db = MySQLdb.connect(host=db_server, user=db_username, passwd=db_password, db=db_dbname)
|
||||||
|
else:
|
||||||
|
db = MySQLdb.connect(host=db_server, port=db_port, user=db_username, passwd=db_password, db=db_dbname)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
except:
|
except:
|
||||||
print "ERROR: Could not connect to MySQL database!"
|
print "ERROR: Could not connect to MySQL database!"
|
||||||
|
|||||||
Reference in New Issue
Block a user