mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 14:44:32 +02:00
IdoMysqlConnection: Add conninfo entry, set session to utc.
fíxes #4783 fíxes #4790
This commit is contained in:
parent
7a6139a219
commit
e63b752457
1
.gitignore
vendored
1
.gitignore
vendored
@ -40,3 +40,4 @@ docs/dev
|
|||||||
m4/ylwrap
|
m4/ylwrap
|
||||||
m4/test-driver
|
m4/test-driver
|
||||||
icinga2-*.tar.gz
|
icinga2-*.tar.gz
|
||||||
|
icinga2.spec
|
||||||
|
@ -82,6 +82,8 @@ void IdoMysqlConnection::ReconnectTimerHandler(void)
|
|||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_ConnectionMutex);
|
boost::mutex::scoped_lock lock(m_ConnectionMutex);
|
||||||
|
|
||||||
|
bool reconnect = false;
|
||||||
|
|
||||||
if (m_Connected) {
|
if (m_Connected) {
|
||||||
/* Check if we're really still connected */
|
/* Check if we're really still connected */
|
||||||
if (mysql_ping(&m_Connection) == 0)
|
if (mysql_ping(&m_Connection) == 0)
|
||||||
@ -89,6 +91,7 @@ void IdoMysqlConnection::ReconnectTimerHandler(void)
|
|||||||
|
|
||||||
mysql_close(&m_Connection);
|
mysql_close(&m_Connection);
|
||||||
m_Connected = false;
|
m_Connected = false;
|
||||||
|
reconnect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ihost, iuser, ipasswd, idb;
|
String ihost, iuser, ipasswd, idb;
|
||||||
@ -147,6 +150,15 @@ void IdoMysqlConnection::ReconnectTimerHandler(void)
|
|||||||
msgbuf << "MySQL IDO instance id: " << static_cast<long>(m_InstanceID) << " (schema version: '" + version + "')";
|
msgbuf << "MySQL IDO instance id: " << static_cast<long>(m_InstanceID) << " (schema version: '" + version + "')";
|
||||||
Log(LogInformation, "db_ido_mysql", msgbuf.str());
|
Log(LogInformation, "db_ido_mysql", msgbuf.str());
|
||||||
|
|
||||||
|
/* set session time zone to utc */
|
||||||
|
Query("SET SESSION TIME_ZONE='+00:00'");
|
||||||
|
|
||||||
|
/* record connection */
|
||||||
|
Query("INSERT INTO " + GetTablePrefix() + "conninfo " +
|
||||||
|
"(instance_id, connect_time, last_checkin_time, agent_name, agent_version, connect_type, data_start_time) VALUES ("
|
||||||
|
+ Convert::ToString(static_cast<long>(m_InstanceID)) + ", NOW(), NOW(), 'icinga2 db_ido_mysql', '2.0', '" + (reconnect ? "RECONNECT" : "INITIAL") + "', NOW())");
|
||||||
|
|
||||||
|
/* clear config tables for the initial config dump */
|
||||||
ClearConfigTables();
|
ClearConfigTables();
|
||||||
|
|
||||||
Query("UPDATE " + GetTablePrefix() + "objects SET is_active = 0");
|
Query("UPDATE " + GetTablePrefix() + "objects SET is_active = 0");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user