configuration.h 1.96 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//
// Created by Netti, Alessio on 30.11.18.
//

#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_

#include <boost/property_tree/ptree.hpp>
#include <string>
#include <unistd.h>

#include <boost/foreach.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/algorithm/string.hpp>

Alessio Netti's avatar
Logging    
Alessio Netti committed
16
#include "logging.h"
Alessio Netti's avatar
Alessio Netti committed
17
#include "pluginsettings.h"
18
19
20
21
22
23
24
25
26
27
28
29
30

#define LISTENHOST "localhost"
#define LISTENPORT "1883"
#define CASSANDRAHOST "127.0.0.1"
#define CASSANDRAPORT "9042"
#define RESTAPIHOST "0.0.0.0"
#define RESTAPIPORT "8080"

typedef struct {
    std::string address;
    std::string username;
    std::string password;
    uint32_t ttl;
Alessio Netti's avatar
Alessio Netti committed
31
32
33
34
35
36
    uint32_t numThreadsIo;
    uint32_t queueSizeIo;
    uint32_t coreConnPerHost;
    uint32_t maxConnPerHost;
    uint32_t maxConcRequests;
    bool debugLog;
37
38
39
40
41
42
43
} cassandra_t;

typedef struct {
    bool daemonize;
    bool statistics;
    std::string mqttListenAddress;
    std::string restListenAddress;
Alessio Netti's avatar
Logging    
Alessio Netti committed
44
    std::string tempDir;
Alessio Netti's avatar
Alessio Netti committed
45
    uint64_t cleaningInterval;
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    uint64_t messageThreads;
    uint64_t messageSlots;
    uint64_t cacheInterval;
    cassandra_t cassandraSettings;
    boost::log::trivial::severity_level logLevelFile;
    boost::log::trivial::severity_level logLevelCmd;
} globalCA_t;


/**
 * Class responsible of reading the collectagent global configuration.
 */
class Configuration {

public:
    /**
     * Create new Configuration. Sets global config file to read from to cfgFile.
     * @param cfgFilePath	Path to where all config-files are located
     */
    Configuration(const std::string& cfgFilePath);

    virtual ~Configuration();

    /**
     * Reads the global values from collectagent.conf (located at _cfgFilePath).
     * Sets _global correspondingly.
     *
     * @return	true on success, false otherwise
     */
    bool readGlobal();

    /**
     * Return global settings
     */
    globalCA_t& getGlobal();

private:

    std::string _cfgFilePath;
    globalCA_t 	_global;

87
    logger_t lg;
88
89
90
91
};

#endif /* CONFIGURATION_H_ */