RedisWriter: publish the current config dump state via icinga:dump

refs #53
This commit is contained in:
Alexander A. Klimov 2019-08-09 15:11:39 +02:00 committed by Michael Friedrich
parent 1d3109458d
commit d9ff921934
1 changed files with 19 additions and 2 deletions

View File

@ -50,6 +50,19 @@
using namespace icinga;
static const char * const l_LuaResetDump = R"EOF(
local id = redis.call('XADD', KEYS[1], '*', 'type', '*', 'state', 'wip')
local xr = redis.call('XRANGE', KEYS[1], '-', '+')
for i = 1, #xr - 1 do
redis.call('XDEL', KEYS[1], xr[i][1])
end
return id
)EOF";
INITIALIZE_ONCE(&RedisWriter::ConfigStaticInitialize);
void RedisWriter::ConfigStaticInitialize()
@ -109,6 +122,8 @@ void RedisWriter::UpdateAllConfigObjects()
}
}
m_Rcon->FireAndForgetQuery({"EVAL", l_LuaResetDump, "1", "icinga:dump"});
const std::vector<String> globalKeys = {
m_PrefixConfigObject + "customvar",
m_PrefixConfigObject + "action_url",
@ -187,8 +202,6 @@ void RedisWriter::UpdateAllConfigObjects()
m_Rcon->FireAndForgetQueries(std::move(transaction));
}
m_Rcon->FireAndForgetQuery({"PUBLISH", "icinga:config:dump", lcType});
Log(LogNotice, "RedisWriter")
<< "Dumped " << bulkCounter << " objects of type " << type.second;
});
@ -202,6 +215,8 @@ void RedisWriter::UpdateAllConfigObjects()
}
}
}
m_Rcon->FireAndForgetQuery({"XADD", "icinga:dump", "*", "type", lcType, "state", "done"});
});
upq.Join();
@ -219,6 +234,8 @@ void RedisWriter::UpdateAllConfigObjects()
}
}
m_Rcon->FireAndForgetQuery({"XADD", "icinga:dump", "*", "type", "*", "state", "done"});
Log(LogInformation, "RedisWriter")
<< "Initial config/status dump finished in " << Utility::GetTime() - startTime << " seconds.";
}