RedisWriter: compute checksums of command arguments and env vars

refs #14
This commit is contained in:
Alexander A. Klimov 2018-07-26 13:46:36 +02:00 committed by Michael Friedrich
parent a908f84750
commit b04b1d954e
1 changed files with 37 additions and 1 deletions

View File

@ -18,6 +18,7 @@
******************************************************************************/
#include "redis/rediswriter.hpp"
#include "icinga/command.hpp"
#include "icinga/customvarobject.hpp"
#include "icinga/host.hpp"
#include "icinga/service.hpp"
@ -315,8 +316,43 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
if (parentZone)
checkSums->Set("parent_checksum", GetIdentifier(parentZone));
}
} else {
/* zone_checksum for endpoints already is calculated above. */
auto command (dynamic_pointer_cast<Command>(object));
if (command) {
Dictionary::Ptr arguments = command->GetArguments();
Dictionary::Ptr argumentChecksums = new Dictionary;
if (arguments) {
ObjectLock argumentsLock (arguments);
for (auto& kv : arguments) {
argumentChecksums->Set(kv.first, HashValue(kv.second));
}
}
checkSums->Set("arguments_checksum", HashValue(arguments));
checkSums->Set("argument_checksums", argumentChecksums);
propertiesBlacklist.emplace("arguments");
Dictionary::Ptr envvars = command->GetEnv();
Dictionary::Ptr envvarChecksums = new Dictionary;
if (envvars) {
ObjectLock argumentsLock (envvars);
for (auto& kv : envvars) {
envvarChecksums->Set(kv.first, HashValue(kv.second));
}
}
checkSums->Set("envvars_checksum", HashValue(envvars));
checkSums->Set("envvar_checksums", envvarChecksums);
propertiesBlacklist.emplace("env");
}
}
}
/* Custom var checksums. */