Commit eb38c300 authored by Alessio Netti's avatar Alessio Netti
Browse files

PrintConfig functionality added to CollectAgent

parent 88f3104f
......@@ -244,7 +244,7 @@ void usage() {
012345678901234567890123456789012345678901234567890123456789012345678901234567890
*/
cout << "Usage:" << endl;
cout << " collectagent [-d] [-s] [-m<host>] [-r<host>] [-c<host>] [-u<username>] [-p<password>] [-t<ttl>] [-v<verbosity>] <path/to/configfiles/>" << endl;
cout << " collectagent [-d] [-s] [-x] [-m<host>] [-r<host>] [-c<host>] [-u<username>] [-p<password>] [-t<ttl>] [-v<verbosity>] <path/to/configfiles/>" << endl;
cout << " collectagent -h" << endl;
cout << endl;
......@@ -260,12 +260,14 @@ void usage() {
cout << endl;
cout << " -d Daemonize" << endl;
cout << " -s Print message stats" <<endl;
cout << " -x Parse and print the config but do not actually start collectagent" << endl;
cout << " -h This help page" << endl;
cout << endl;
}
int main(int argc, char* const argv[]) {
cout << "CollectAgent " << VERSION << " (libdcdb " << DCDB::Version::getVersion() << ")" << endl << endl;
bool validateConfig = false;
try{
......@@ -277,7 +279,7 @@ int main(int argc, char* const argv[]) {
}
// Defining options
const char* opts = "m:r:c:C:u:p:t:v:dDsh";
const char* opts = "m:r:c:C:u:p:t:v:dDsxh";
// Same mechanism as in DCDBPusher - checking if help string is requested before loading config
char ret;
......@@ -347,6 +349,9 @@ int main(int argc, char* const argv[]) {
case 's':
settings.statistics = 1;
break;
case 'x':
validateConfig = true;
break;
case 'h':
default:
usage();
......@@ -371,6 +376,46 @@ int main(int argc, char* const argv[]) {
signal(SIGABRT, abrtHandler);
signal(SIGSEGV, abrtHandler);
LOG_LEVEL vLogLevel = validateConfig ? LOG_LEVEL::info : LOG_LEVEL::debug;
LOG_VAR(vLogLevel) << "----- Configuration -----";
//print global settings in either case
LOG(info) << "Global Settings:";
LOG(info) << " MQTT-listenAddress: " << settings.mqttListenAddress;
LOG(info) << " CacheInterval: " << settings.cacheInterval << " [s]";
LOG(info) << " CleaningInterval: " << settings.cleaningInterval << " [s]";
LOG(info) << " MessageThreads: " << settings.messageThreads;
LOG(info) << " MessageSlots: " << settings.messageSlots;
LOG(info) << " Daemonize: " << (settings.daemonize ? "Enabled" : "Disabled");
LOG(info) << " Statistics: " << (settings.statistics ? "Enabled" : "Disabled");
LOG(info) << " Write-Dir: " << settings.tempDir;
LOG(info) << " Hierarchy: " << (settings.hierarchy!="" ? settings.hierarchy : "none");
LOG(info) << (validateConfig ? " Only validating config files." : " ValidateConfig: Disabled");
LOG(info) << "Cassandra Driver Settings:";
LOG(info) << " Address: " << settings.cassandraSettings.address;
LOG(info) << " TTL: " << settings.cassandraSettings.ttl;
LOG(info) << " NumThreadsIO: " << settings.cassandraSettings.numThreadsIo;
LOG(info) << " QueueSizeIO: " << settings.cassandraSettings.queueSizeIo;
LOG(info) << " CoreConnPerHost: " << settings.cassandraSettings.coreConnPerHost;
LOG(info) << " MaxConnPerHost: " << settings.cassandraSettings.maxConnPerHost;
LOG(info) << " MaxConcRequests: " << settings.cassandraSettings.maxConcRequests;
LOG(info) << " DebugLog: " << (settings.cassandraSettings.debugLog ? "Enabled" : "Disabled");
#ifdef SimpleMQTTVerbose
LOG(info) << " Username: " << settings.cassandraSettings.username;
LOG(info) << " Password: " << settings.cassandraSettings.password;
#else
LOG(info) << " Username and password not printed.";
#endif
LOG(info) << "RestAPI Settings:";
LOG(info) << " REST Server: " << settings.restListenAddress;
LOG_VAR(vLogLevel) << "----- End Configuration -----";
if (validateConfig)
return 0;
// Daemonizing the collectagent
if(settings.daemonize)
dcdbdaemon();
......
......@@ -57,6 +57,8 @@ bool Configuration::readGlobal() {
BOOST_FOREACH(boost::property_tree::iptree::value_type &global, cfg.get_child("global")) {
if (boost::iequals(global.first, "mqttListenAddress")) {
_global.mqttListenAddress = global.second.data();
} else if (boost::iequals(global.first, "hierarchy")) {
_global.hierarchy = global.second.data();
} else if (boost::iequals(global.first, "cleaningInterval")) {
_global.cleaningInterval = stoul(global.second.data());
} else if (boost::iequals(global.first, "messageThreads")) {
......
......@@ -42,6 +42,7 @@ typedef struct {
std::string mqttListenAddress;
std::string restListenAddress;
std::string tempDir;
std::string hierarchy;
uint64_t cleaningInterval;
uint64_t messageThreads;
uint64_t messageSlots;
......
......@@ -165,7 +165,6 @@ int main(int argc, char** argv) {
case 'h':
printSyntax();
return 1;
break;
default:
//do nothing (other options are read later on)
break;
......@@ -231,7 +230,6 @@ int main(int argc, char** argv) {
case 'h':
printSyntax();
return 1;
break;
default:
if (c != '?') cerr << "Unknown parameter: " << c << endl;
return 1;
......@@ -303,7 +301,7 @@ int main(int argc, char** argv) {
LOG(info) << " MQTT-QoS: " << globalSettings.qosLevel;
LOG(info) << " MQTT-prefix: " << pluginSettings.mqttPrefix;
LOG(info) << " Write-Dir: " << pluginSettings.tempdir;
LOG(info) << " Hierarchy: " << globalSettings.hierarchy;
LOG(info) << " Hierarchy: " << (globalSettings.hierarchy!="" ? globalSettings.hierarchy : "none");
LOG(info) << " CacheInterval: " << pluginSettings.cacheInterval / 1000 << " [s]";
if(globalSettings.validateConfig) {
LOG(info) << " Only validating config files.";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment