SNMPConfigurator.cpp 2.06 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/*
 * SNMPConfigurator.cpp
 *
 *  Created on: 05.07.2018
 *      Author: Axel Auweter (original), Micha Mueller
 */

#include "SNMPConfigurator.h"

SNMPConfigurator::SNMPConfigurator() {
Micha Mueller's avatar
Micha Mueller committed
11
12
	/* Initialize SNMP library */
	init_snmp("dcdbpusher_SNMPplugin");
13
14
15
16

	_entityName = "connection";
	_groupName = "group";
	_baseName = "sensor";
17
18
}

Micha Mueller's avatar
Micha Mueller committed
19
SNMPConfigurator::~SNMPConfigurator() {}
20

Micha Mueller's avatar
Micha Mueller committed
21
void SNMPConfigurator::sensorBase(SNMPSensorBase& s, CFG_VAL config) {
22
	ADD {
23
		ATTRIBUTE("OIDSuffix", setOIDSuffix);
24
25
26
27
	}

}

Micha Mueller's avatar
Micha Mueller committed
28
void SNMPConfigurator::sensorGroup(SNMPSensorGroup& s, CFG_VAL config) {
29
30
31
32
33
	ADD {
		//no group attributes currently
	}
}

Micha Mueller's avatar
Micha Mueller committed
34
void SNMPConfigurator::sensorEntity(SNMPConnection& s, CFG_VAL config) {
35
36
37
	ADD {
		//ATTRIBUTE("Type", setType) //TODO would be relevant if we would support more than just agent mode...
									 //at the moment we just ignore it, as it can be only "Agent" anyways
38
39
40
41
42
43
44
45
46
47
48
49
		ATTRIBUTE("Host", setHost);
		ATTRIBUTE("Port", setPort);
		ATTRIBUTE("Community", setSNMPCommunity);
		ATTRIBUTE("OIDPrefix", setOIDPrefix);
		ATTRIBUTE("Version", setVersion);
		ATTRIBUTE("Username", setUsername);
		ATTRIBUTE("SecLevel", setSecurityLevel);
		ATTRIBUTE("AuthProto", setAuthProto);
		ATTRIBUTE("PrivProto", setPrivProto);
		ATTRIBUTE("AuthKey", setAuthKey);
		ATTRIBUTE("PrivKey", setPrivKey);
		ATTRIBUTE("MqttPart", setMqttPart);
50
51
52
	}
}

Micha Mueller's avatar
Micha Mueller committed
53
54
55
bool SNMPConfigurator::isEntityOfGroup(SNMPConnection& e, SNMPSensorGroup& g) {
	return (g.getConnection() == &e);
}
Micha Mueller's avatar
Micha Mueller committed
56

Micha Mueller's avatar
Micha Mueller committed
57
58
59
void SNMPConfigurator::setEntityForGroup(SNMPConnection& e, SNMPSensorGroup& g) {
	g.setConnection(&e);
}
Micha Mueller's avatar
Micha Mueller committed
60

Micha Mueller's avatar
Micha Mueller committed
61
62
63
64
void SNMPConfigurator::finalizeGroup(SNMPSensorGroup& g) {
	g.setMqttPart(g.getConnection()->getMqttPart() + g.getMqttPart());
	g.setOIDPrefix(g.getConnection()->getOIDPrefix());
	g.getConnection()->init();
65
}
66
67
68
69
70
71
72
73
74
75
76
77
78

void SNMPConfigurator::printConfiguratorConfig(LOG_LEVEL ll) {
  LOG_VAR(ll) << "  No other plugin specific general attributes";

  LOG_VAR(ll) << " Connections:";
  if (_sensorEntitys.size() != 0) {
    for(auto e : _sensorEntitys) {
      e->printConfig(ll);
    }
  } else {
    LOG_VAR(ll) << "  No connections present!";
  }
}