mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
Implement socket_path attribute for the IdoMysqlConnection class
fixes #7901
This commit is contained in:
parent
6c1ec9e8c0
commit
078125bdec
@ -1409,6 +1409,7 @@ Attributes:
|
|||||||
----------------|----------------
|
----------------|----------------
|
||||||
host |**Optional.** MySQL database host address. Defaults to "localhost".
|
host |**Optional.** MySQL database host address. Defaults to "localhost".
|
||||||
port |**Optional.** MySQL database port. Defaults to 3306.
|
port |**Optional.** MySQL database port. Defaults to 3306.
|
||||||
|
socket_path |**Optional.** MySQL socket path.
|
||||||
user |**Optional.** MySQL database user with read/write permission to the icinga database. Defaults to "icinga".
|
user |**Optional.** MySQL database user with read/write permission to the icinga database. Defaults to "icinga".
|
||||||
password |**Optional.** MySQL database user's password. Defaults to "icinga".
|
password |**Optional.** MySQL database user's password. Defaults to "icinga".
|
||||||
database |**Optional.** MySQL database name. Defaults to "icinga".
|
database |**Optional.** MySQL database name. Defaults to "icinga".
|
||||||
|
@ -179,17 +179,19 @@ void IdoMysqlConnection::Reconnect(void)
|
|||||||
|
|
||||||
ClearIDCache();
|
ClearIDCache();
|
||||||
|
|
||||||
String ihost, iuser, ipasswd, idb;
|
String ihost, isocket_path, iuser, ipasswd, idb;
|
||||||
const char *host, *user , *passwd, *db;
|
const char *host, *socket_path, *user , *passwd, *db;
|
||||||
long port;
|
long port;
|
||||||
|
|
||||||
ihost = GetHost();
|
ihost = GetHost();
|
||||||
|
isocket_path = GetSocketPath();
|
||||||
iuser = GetUser();
|
iuser = GetUser();
|
||||||
ipasswd = GetPassword();
|
ipasswd = GetPassword();
|
||||||
idb = GetDatabase();
|
idb = GetDatabase();
|
||||||
|
|
||||||
host = (!ihost.IsEmpty()) ? ihost.CStr() : NULL;
|
host = (!ihost.IsEmpty()) ? ihost.CStr() : NULL;
|
||||||
port = GetPort();
|
port = GetPort();
|
||||||
|
socket_path = (!isocket_path.IsEmpty()) ? isocket_path.CStr() : NULL;
|
||||||
user = (!iuser.IsEmpty()) ? iuser.CStr() : NULL;
|
user = (!iuser.IsEmpty()) ? iuser.CStr() : NULL;
|
||||||
passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : NULL;
|
passwd = (!ipasswd.IsEmpty()) ? ipasswd.CStr() : NULL;
|
||||||
db = (!idb.IsEmpty()) ? idb.CStr() : NULL;
|
db = (!idb.IsEmpty()) ? idb.CStr() : NULL;
|
||||||
@ -202,7 +204,7 @@ void IdoMysqlConnection::Reconnect(void)
|
|||||||
BOOST_THROW_EXCEPTION(std::bad_alloc());
|
BOOST_THROW_EXCEPTION(std::bad_alloc());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mysql_real_connect(&m_Connection, host, user, passwd, db, port, NULL, CLIENT_FOUND_ROWS)) {
|
if (!mysql_real_connect(&m_Connection, host, user, passwd, db, port, socket_path, CLIENT_FOUND_ROWS)) {
|
||||||
Log(LogCritical, "IdoMysqlConnection")
|
Log(LogCritical, "IdoMysqlConnection")
|
||||||
<< "Connection to database '" << db << "' with user '" << user << "' on '" << host << ":" << port
|
<< "Connection to database '" << db << "' with user '" << user << "' on '" << host << ":" << port
|
||||||
<< "' failed: \"" << mysql_error(&m_Connection) << "\"";
|
<< "' failed: \"" << mysql_error(&m_Connection) << "\"";
|
||||||
|
@ -30,6 +30,7 @@ class IdoMysqlConnection : DbConnection
|
|||||||
[config] int port {
|
[config] int port {
|
||||||
default {{{ return 3306; }}}
|
default {{{ return 3306; }}}
|
||||||
};
|
};
|
||||||
|
[config] String socket_path;
|
||||||
[config] String user {
|
[config] String user {
|
||||||
default {{{ return "icinga"; }}}
|
default {{{ return "icinga"; }}}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user