Commit 7d45a2a1 authored by Micha Mueller's avatar Micha Mueller
Browse files

Minor fixes. SNMP plugin now works

parent a2cdfa05
......@@ -61,6 +61,7 @@ public:
for (auto te : _templateSensorEntitys) {
delete te.second;
}
_sensorGroupInterfaces.clear();
_sensorGroups.clear();
_sensorEntitys.clear();
_templateSensorGroups.clear();
......@@ -135,7 +136,7 @@ public:
if (!val.second.empty()) {
SGroup* group = new SGroup(val.second.data());
if (readSensorGroup(*group, val.second)) {
_sensorGroups.push_back(group);
storeSensorGroup(group);
} else {
LOG(warning) << _groupName << " \"" << val.second.data() << "\" has bad values! Ignoring...";
}
......@@ -180,6 +181,7 @@ public:
for (auto te : _templateSensorEntitys) {
delete te.second;
}
_sensorGroupInterfaces.clear();
_sensorGroups.clear();
_sensorEntitys.clear();
_templateSensorGroups.clear();
......@@ -209,10 +211,15 @@ public:
* @return Vector containing pointers to all sensor groups of this plugin
*/
std::vector<SensorGroupInterface*>& getSensorGroups() final {
return _sensorGroups;
return _sensorGroupInterfaces;
}
private:
void storeSensorGroup(SGroup* sGroup) {
_sensorGroups.push_back(sGroup);
_sensorGroupInterfaces.push_back(sGroup);
}
protected:
/**
* Non-virtual interface method for class-internal use only.
* Reads and sets the common base values of a sensor base (currently none),
......@@ -314,7 +321,7 @@ protected:
if (isEntityOfGroup(*(it->second), *(g.second))) {
SGroup* group = new SGroup(*(g.second));
setEntityForGroup(sEntity, *group);
_sensorGroups.push_back(group);
storeSensorGroup(group);
}
}
} else {
......@@ -336,7 +343,7 @@ protected:
LOG(warning) << "Template " << _groupName << " " << val.second.data() << " already exists! Omitting...";
}
} else {
_sensorGroups.push_back(group);
storeSensorGroup(group);
}
} else {
LOG(warning) << _groupName << " " << group->getGroupName() << " could not be read! Omitting";
......@@ -346,7 +353,7 @@ protected:
for(auto g : _sensorGroups) {
if(isEntityOfGroup(sEntity, *g)) {
finalizeEntityGroup(sEntity, *g);
finalizeGroup(*g);
}
}
return true;
......@@ -373,6 +380,7 @@ protected:
return true;
}
protected:
/**
* Virtual interface method, responsible for setting global values specifically
* for its plugin.
......@@ -465,8 +473,9 @@ protected:
std::string _cfgPath;
std::string _mqttPrefix;
unsigned int _cacheInterval;
std::vector<SensorGroupInterface*> _sensorGroups;
std::vector<SEntity*> _sensorEntitys;
std::vector<SensorGroupInterface*> _sensorGroupInterfaces;
std::vector<SGroup*> _sensorGroups;
std::vector<SEntity*> _sensorEntitys;
sGroupMap_t _templateSensorGroups;
sEntityMap_t _templateSensorEntitys;
};
......
......@@ -23,7 +23,7 @@ public:
SensorGroupTemplate(const SensorGroupTemplate& other) :
SensorGroupInterface(other) {
for(auto s : other._sensors) {
S* sensor = new S(s);
S* sensor = new S(*s);
_sensors.push_back(sensor);
_baseSensors.push_back(sensor);
}
......
......@@ -122,7 +122,7 @@ void SNMPConnection::init() {
_isInitialized = true;
}
uint64_t SNMPConnection::issueGet(oid* OID, size_t OIDLen) {
uint64_t SNMPConnection::issueGet(const oid* const OID, size_t OIDLen) {
struct snmp_session* ss;
struct snmp_pdu *pdu, *response;
struct variable_list *vp;
......
......@@ -113,7 +113,7 @@ public:
*
* @return The requested value
*/
uint64_t issueGet(oid* OID, size_t OIDLen);
uint64_t issueGet(const oid* const OID, size_t OIDLen);
private:
bool _isInitialized;
......
......@@ -34,9 +34,9 @@ public:
}
}
size_t getOIDLen() const { return _oidLen; }
const oid* getOID() const { return _oid; }
std::string getOIDString() {
size_t getOIDLen() const { return _oidLen; }
const oid* const getOID() const { return _oid; }
std::string getOIDString() {
char buf[255];
int len = snprint_objid(buf, 255, _oid, _oidLen);
if (len == -1) {
......
......@@ -27,7 +27,7 @@ public:
}
}
void setConnection(SNMPConnection* connection) { _connection = connection; }
SNMPConnection* getConnection() const { return _connection; }
SNMPConnection* const getConnection() const { return _connection; }
private:
void read() override;
......
Markdown is supported
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