Commit 3ba87e5b authored by Daniele Tafani's avatar Daniele Tafani
Browse files

Working version of the MontblancPusher - still needs timestamp fix

parent ef2bdc63
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
#include "simplemqttserver.h" #include "simplemqttserver.h"
#include "messaging.h" #include "messaging.h"
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
using namespace std; using namespace std;
int keepRunning; int keepRunning;
...@@ -53,17 +56,21 @@ void mqttCallback(SimpleMQTTMessage *msg) ...@@ -53,17 +56,21 @@ void mqttCallback(SimpleMQTTMessage *msg)
//In the 64 bit message case, the collect agent provides a timestamp //In the 64 bit message case, the collect agent provides a timestamp
if(msg->getPayloadLength()==sizeof(uint64_t)) { if(msg->getPayloadLength()==sizeof(uint64_t)) {
//printf("Providing timestamp...\n");
val = *((uint64_t*)msg->getPayload()); val = *((uint64_t*)msg->getPayload());
ts = Messaging::calculateTimestamp(); ts = Messaging::calculateTimestamp();
//printf("Val = %" PRIu64 ", timestamp = %" PRIu64 "\n", val, ts);
} }
//...otherwise it just retrieves it from the MQTT message payload. //...otherwise it just retrieves it from the MQTT message payload.
else if((msg->getPayloadLength()%sizeof(mqttPayload)==0) && (msg->getPayloadLength()>0)){ else if((msg->getPayloadLength()%sizeof(mqttPayload)==0) && (msg->getPayloadLength()>0)){
//printf("Retrieving timestamp...\n");
mqttPayload *payload = (mqttPayload*)msg->getPayload(); mqttPayload *payload = (mqttPayload*)msg->getPayload();
val = payload->value; // payload[n].value val = payload->value; // payload[n].value
ts = payload->timestamp; ts = payload->timestamp;
//printf("Val = %" PRIu64 ", timestamp = %" PRIu64 "\n", val, ts);
} }
/* /*
...@@ -72,6 +79,7 @@ void mqttCallback(SimpleMQTTMessage *msg) ...@@ -72,6 +79,7 @@ void mqttCallback(SimpleMQTTMessage *msg)
* the record in the database. * the record in the database.
*/ */
SensorId sid; SensorId sid;
mySensorDataStore->topicToSid(&sid,msg->getTopic());
if (mySensorDataStore->topicToSid(&sid,msg->getTopic())) { if (mySensorDataStore->topicToSid(&sid,msg->getTopic())) {
#if 0 #if 0
cout << "Topic decode successful:" cout << "Topic decode successful:"
...@@ -81,9 +89,8 @@ void mqttCallback(SimpleMQTTMessage *msg) ...@@ -81,9 +89,8 @@ void mqttCallback(SimpleMQTTMessage *msg)
<< "\nrack_id_msb: " << hex << (uint32_t)sid.dl.rack_id_msb << "\nrack_id_msb: " << hex << (uint32_t)sid.dl.rack_id_msb
<< "\nrack_id_lsb: " << hex << (uint32_t)sid.dl.rack_id_lsb << "\nrack_id_lsb: " << hex << (uint32_t)sid.dl.rack_id_lsb
<< "\nchassis_id: " << hex << (uint32_t)sid.dl.chassis_id << "\nchassis_id: " << hex << (uint32_t)sid.dl.chassis_id
<< "\nbic_id: " << hex << (uint32_t)sid.dl.bic_id << "\nbmc_id: " << hex << (uint32_t)sid.dl.bmc_id
<< "\nbnc_id: " << hex << (uint32_t)sid.dl.bnc_id << "\nsdb_id: " << hex << (uint32_t)sid.dl.sdb_id
<< "\nknc_id: " << hex << (uint32_t)sid.dl.knc_id
<< "\ndevice_id: " << hex << sid.dsid.device_id << "\ndevice_id: " << hex << sid.dsid.device_id
<< "\nsensor_id: " << hex << sid.dsid.sensor_id << "\nsensor_id: " << hex << sid.dsid.sensor_id
<< "\n"; << "\n";
......
...@@ -39,9 +39,8 @@ ...@@ -39,9 +39,8 @@
typedef union { typedef union {
uint64_t raw; /**< The raw bit-field representing the DeviceLocation */ uint64_t raw; /**< The raw bit-field representing the DeviceLocation */
struct { struct {
uint8_t knc_id; uint16_t sdb_id;
uint8_t bnc_id; uint8_t bmc_id;
uint8_t bic_id;
uint8_t chassis_id; uint8_t chassis_id;
uint8_t rack_id_lsb; uint8_t rack_id_lsb;
uint8_t rack_id_msb; uint8_t rack_id_msb;
...@@ -61,7 +60,8 @@ typedef union { ...@@ -61,7 +60,8 @@ typedef union {
* approach is, for example, to use MAC addresses as the device_id. * approach is, for example, to use MAC addresses as the device_id.
*/ */
typedef struct { typedef struct {
uint64_t sensor_number : 16; /**< The sensor_number of the sensor */ //uint64_t sensor_number : 16; /**< The sensor_number of the sensor */
uint64_t sensor_id : 16; /**< The sensor_number of the sensor */
uint64_t rsvd : 16; /**< Reserved */ uint64_t rsvd : 16; /**< Reserved */
uint64_t device_id : 32; /**< The location-independent device_id */ uint64_t device_id : 32; /**< The location-independent device_id */
} DeviceSensorId; } DeviceSensorId;
...@@ -120,6 +120,7 @@ public: ...@@ -120,6 +120,7 @@ public:
* @return Returns true if the topic string was valid and the SensorId object was populated. * @return Returns true if the topic string was valid and the SensorId object was populated.
*/ */
bool topicToSid(SensorId* sid, std::string topic); bool topicToSid(SensorId* sid, std::string topic);
//template <typename T> bool topicToSid(T* sid, uint64_t ts, uint64_t value)
/** /**
* @brief This function inserts a single sensor reading into * @brief This function inserts a single sensor reading into
...@@ -129,6 +130,7 @@ public: ...@@ -129,6 +130,7 @@ public:
* @param value The value of the sensor reading. * @param value The value of the sensor reading.
*/ */
void insert(SensorId* sid, uint64_t ts, uint64_t value); void insert(SensorId* sid, uint64_t ts, uint64_t value);
//template <typename T> void insert(T* sid, uint64_t ts, uint64_t value)
/** /**
* @brief A shortcut constructor for a SensorDataStore object * @brief A shortcut constructor for a SensorDataStore object
......
...@@ -59,6 +59,7 @@ string SensorDataStoreImpl::sidConvert(SensorId *sid) ...@@ -59,6 +59,7 @@ string SensorDataStoreImpl::sidConvert(SensorId *sid)
* SensorDataStore class. * SensorDataStore class.
*/ */
bool SensorDataStoreImpl::topicToSid(SensorId* sid, string topic) bool SensorDataStoreImpl::topicToSid(SensorId* sid, string topic)
//template <typename T> bool SensorDataStoreImpl::topicToSid(T* sid, string topic)
{ {
uint64_t pos = 0; uint64_t pos = 0;
const char* buf = topic.c_str(); const char* buf = topic.c_str();
...@@ -214,6 +215,7 @@ bool SensorDataStore::topicToSid(SensorId* sid, std::string topic) ...@@ -214,6 +215,7 @@ bool SensorDataStore::topicToSid(SensorId* sid, std::string topic)
* class. * class.
*/ */
void SensorDataStore::insert(SensorId* sid, uint64_t ts, uint64_t value) void SensorDataStore::insert(SensorId* sid, uint64_t ts, uint64_t value)
//template <typename T> void SensorDataStore::insert(T* sid, uint64_t ts, uint64_t value)
{ {
impl->insert(sid, ts, value); impl->insert(sid, ts, value);
} }
......
...@@ -108,7 +108,7 @@ $(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles ...@@ -108,7 +108,7 @@ $(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
echo "Building OpenIPMI library..."; \ echo "Building OpenIPMI library..."; \
if [ -e $(DCDBDEPSPATH)/patches/$(O).patch ]; then echo "Patching OpenIPMI..."; cd $(DCDBDEPSPATH)/$(O) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(O).patch || true); fi; \ if [ -e $(DCDBDEPSPATH)/patches/$(O).patch ]; then echo "Patching OpenIPMI..."; cd $(DCDBDEPSPATH)/$(O) && (patch -N -p1 < $(DCDBDEPSPATH)/patches/$(O).patch || true); fi; \
if [ "$(X)" = "Darwin" ]; then echo "Fixing OpenIPMI for Mac OS..."; cd $(DCDBDEPSPATH)/$(O) && find . -name 'Makefile*' | xargs sed -i '' -e 's/Map/map/g'; fi; \ if [ "$(X)" = "Darwin" ]; then echo "Fixing OpenIPMI for Mac OS..."; cd $(DCDBDEPSPATH)/$(O) && find . -name 'Makefile*' | xargs sed -i '' -e 's/Map/map/g'; fi; \
cd $(DCDBDEPSPATH)/$(O) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-swig=no --with-perl=no --with-python=no; \ cd $(DCDBDEPSPATH)/$(O) && ./configure --prefix=$(DCDBDEPLOYPATH) --with-swig=no --with-perl=no --with-python=no CFLAGS="$(CFLAGS)"; \
cd $(DCDBDEPSPATH)/$(O) && make -j $(MAKETHREADS) && make install && touch $(DCDBDEPSPATH)/$(O)/.installed; \ cd $(DCDBDEPSPATH)/$(O) && make -j $(MAKETHREADS) && make install && touch $(DCDBDEPSPATH)/$(O)/.installed; \
else \ else \
echo "Skipping OpenIPMI library (already built)..."; \ echo "Skipping OpenIPMI library (already built)..."; \
......
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