Commit 4db1e2f6 authored by Micha Mueller's avatar Micha Mueller
Browse files

Reading values are now stored in signed int64_t for consistency with collectAgent and database

parent 9a937fe9
...@@ -322,7 +322,7 @@ HttpsServer::~HttpsServer() { ...@@ -322,7 +322,7 @@ HttpsServer::~HttpsServer() {
} }
std::string HttpsServer::calcAvg(SensorBase& s, uint64_t time) { std::string HttpsServer::calcAvg(SensorBase& s, uint64_t time) {
uint64_t avg = 0; int64_t avg = 0;
const reading_t * const cache = s.getCache(); const reading_t * const cache = s.getCache();
unsigned count = 0; unsigned count = 0;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <boost/lockfree/spsc_queue.hpp> #include <boost/lockfree/spsc_queue.hpp>
typedef struct { typedef struct {
uint64_t value; int64_t value;
uint64_t timestamp; uint64_t timestamp;
} reading_t; } reading_t;
...@@ -80,7 +80,7 @@ public: ...@@ -80,7 +80,7 @@ public:
void setName(const std::string& name, int cpuID=-1) { _name = formatName(name, cpuID); } void setName(const std::string& name, int cpuID=-1) { _name = formatName(name, cpuID); }
void setMqtt(const std::string& mqtt) { _mqtt = mqtt; } void setMqtt(const std::string& mqtt) { _mqtt = mqtt; }
void setCacheInterval(unsigned cacheInterval) { _cacheInterval = cacheInterval; } void setCacheInterval(unsigned cacheInterval) { _cacheInterval = cacheInterval; }
void setLastRawValue(uint64_t value) { _lastRawValue.value = value; } void setLastRawValue(int64_t value) { _lastRawValue.value = value; }
const std::size_t getSizeOfReadingQueue() const { return _readingQueue->read_available(); } const std::size_t getSizeOfReadingQueue() const { return _readingQueue->read_available(); }
std::size_t popReadingQueue(reading_t *reads, std::size_t max) const { return _readingQueue->pop(reads, max); } std::size_t popReadingQueue(reading_t *reads, std::size_t max) const { return _readingQueue->pop(reads, max); }
......
...@@ -233,7 +233,7 @@ void BACnetClient::readPropertyAckHandler(uint8_t * service_request, uint16_t se ...@@ -233,7 +233,7 @@ void BACnetClient::readPropertyAckHandler(uint8_t * service_request, uint16_t se
//bacapp_print_value(stdout, &object_value); //bacapp_print_value(stdout, &object_value);
//TODO what kind of data is returned? which cases do we need to handle? fit they into uint64_t at all?? //TODO what kind of data is returned? which cases do we need to handle? fit they into int64_t at all??
switch (value.tag) { switch (value.tag) {
case BACNET_APPLICATION_TAG_NULL: case BACNET_APPLICATION_TAG_NULL:
LOG(trace) << "TAG_NULL"; LOG(trace) << "TAG_NULL";
......
...@@ -106,37 +106,37 @@ bool GpfsmonSensorGroup::parseLine(std::string &&toparse){ ...@@ -106,37 +106,37 @@ bool GpfsmonSensorGroup::parseLine(std::string &&toparse){
std::string::size_type bytewrite_pos = toparse.find(" _bw_ "); std::string::size_type bytewrite_pos = toparse.find(" _bw_ ");
if( bytereads_pos != std::string::npos && bytewrite_pos != std::string::npos){ if( bytereads_pos != std::string::npos && bytewrite_pos != std::string::npos){
_data[IOBYTESREAD] = std::stoull(toparse.substr(bytereads_pos + 5, bytewrite_pos - bytereads_pos)); _data[IOBYTESREAD] = std::stoll(toparse.substr(bytereads_pos + 5, bytewrite_pos - bytereads_pos));
} else { } else {
return false; return false;
} }
std::string::size_type opens_pos = toparse.find(" _oc_ "); std::string::size_type opens_pos = toparse.find(" _oc_ ");
if( opens_pos != std::string::npos ){ if( opens_pos != std::string::npos ){
_data[IOBYTESWRITE] = std::stoull(toparse.substr(bytewrite_pos + 6, opens_pos - bytewrite_pos)); _data[IOBYTESWRITE] = std::stoll(toparse.substr(bytewrite_pos + 6, opens_pos - bytewrite_pos));
} else { } else {
return false; return false;
} }
std::string::size_type closes_pos = toparse.find(" _cc_ "); std::string::size_type closes_pos = toparse.find(" _cc_ ");
if( closes_pos != std::string::npos){ if( closes_pos != std::string::npos){
_data[IOOPENS] = std::stoull(toparse.substr(opens_pos + 6, closes_pos - opens_pos)); _data[IOOPENS] = std::stoll(toparse.substr(opens_pos + 6, closes_pos - opens_pos));
} else { } else {
return false; return false;
} }
std::string::size_type reads_pos = toparse.find(" _rdc_ "); std::string::size_type reads_pos = toparse.find(" _rdc_ ");
if( reads_pos != std::string::npos ){ if( reads_pos != std::string::npos ){
_data[IOCLOSES] = std::stoull(toparse.substr(closes_pos + 6, reads_pos - closes_pos)); _data[IOCLOSES] = std::stoll(toparse.substr(closes_pos + 6, reads_pos - closes_pos));
} else { } else {
return false; return false;
} }
std::string::size_type writes_pos = toparse.find(" _wc_ "); std::string::size_type writes_pos = toparse.find(" _wc_ ");
if( writes_pos != std::string::npos ){ if( writes_pos != std::string::npos ){
_data[IOREADS] = std::stoull(toparse.substr(reads_pos + 7, writes_pos - reads_pos)); _data[IOREADS] = std::stoll(toparse.substr(reads_pos + 7, writes_pos - reads_pos));
} else { } else {
return false; return false;
} }
std::string::size_type dir_pos = toparse.find(" _dir_"); std::string::size_type dir_pos = toparse.find(" _dir_");
if( dir_pos != std::string::npos ){ if( dir_pos != std::string::npos ){
_data[IOWRITES] = std::stoull(toparse.substr(writes_pos + 6, dir_pos - writes_pos)); _data[IOWRITES] = std::stoll(toparse.substr(writes_pos + 6, dir_pos - writes_pos));
} else { } else {
return false; return false;
} }
......
...@@ -35,7 +35,7 @@ private: ...@@ -35,7 +35,7 @@ private:
const std::string _cmd_io = "/usr/lpp/mmfs/bin/mmpmon -p -i /tmp/gpfsmon"; //todo change to real command const std::string _cmd_io = "/usr/lpp/mmfs/bin/mmpmon -p -i /tmp/gpfsmon"; //todo change to real command
std::vector<uint64_t> _data; //!< temp variable in parseLine defined here for efficiency. std::vector<int64_t> _data; //!< temp variable in parseLine defined here for efficiency.
constexpr static int BUFFER_SIZE=255; //!< constant buffer that is used to parse line by line (from popen) constexpr static int BUFFER_SIZE=255; //!< constant buffer that is used to parse line by line (from popen)
}; };
......
...@@ -143,7 +143,7 @@ bool IPMIHost::getSdrRecord(uint16_t recordId, std::vector<uint8_t>& record) { ...@@ -143,7 +143,7 @@ bool IPMIHost::getSdrRecord(uint16_t recordId, std::vector<uint8_t>& record) {
return success; return success;
} }
uint64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd, int64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
uint16_t start, uint16_t stop) { uint16_t start, uint16_t stop) {
uint8_t buf[256]; uint8_t buf[256];
int len = -1; int len = -1;
...@@ -193,9 +193,9 @@ uint64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd, ...@@ -193,9 +193,9 @@ uint64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
_errorCount = 0; _errorCount = 0;
uint64_t val = 0; int64_t val = 0;
for (i = start; i <= stop; i++) { for (i = start; i <= stop; i++) {
val |= ((uint64_t) buf[i]) << (stop - i) * 8; val |= ((int64_t) buf[i]) << (stop - i) * 8;
} }
return val; return val;
......
...@@ -22,7 +22,7 @@ public: ...@@ -22,7 +22,7 @@ public:
/* Translate recordId to SDR record */ /* Translate recordId to SDR record */
bool getSdrRecord(uint16_t recordId, std::vector<uint8_t>& record); bool getSdrRecord(uint16_t recordId, std::vector<uint8_t>& record);
/* Send raw command to BMC. Returns sensor reading as responded by BMC. */ /* Send raw command to BMC. Returns sensor reading as responded by BMC. */
uint64_t sendRawCmd(const std::vector<uint8_t>& rawCmd, uint16_t start, uint16_t stop); int64_t sendRawCmd(const std::vector<uint8_t>& rawCmd, uint16_t start, uint16_t stop);
/* Read the sensor specified by its record id. Returns sensor reading. */ /* Read the sensor specified by its record id. Returns sensor reading. */
double readSensorRecord(std::vector<uint8_t>& record); double readSensorRecord(std::vector<uint8_t>& record);
......
...@@ -115,7 +115,7 @@ void PDUSensorGroup::read() { ...@@ -115,7 +115,7 @@ void PDUSensorGroup::read() {
if (readStr == "") { if (readStr == "") {
throw std::runtime_error("Value not found!"); throw std::runtime_error("Value not found!");
} }
reading.value = stoul(readStr); reading.value = stoll(readStr);
#ifdef DEBUG #ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << ": \"" << reading.value << "\""; LOG(debug) << _groupName << "::" << s->getName() << ": \"" << reading.value << "\"";
#endif #endif
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class PerfSensorBase : virtual public SensorBase { class PerfSensorBase : virtual public SensorBase {
public: public:
static constexpr uint64_t MAXCOUNTERVALUE = ULLONG_MAX; //ToDo check if it is not ULLONG_MAX, or make it configurable! static constexpr int64_t MAXCOUNTERVALUE = LLONG_MAX; //ToDo check if it is not LLONG_MAX, or make it configurable!
PerfSensorBase(const std::string& name) : PerfSensorBase(const std::string& name) :
SensorBase(name), SensorBase(name),
......
...@@ -192,7 +192,8 @@ void PerfSensorGroup::read() { ...@@ -192,7 +192,8 @@ void PerfSensorGroup::read() {
} }
//iterate over all values returned by ::read() //iterate over all values returned by ::read()
for (unsigned i = 0; i < rf->nr; i++) { for (unsigned i = 0; i < rf->nr; i++) {
uint64_t val = rf->values[i].value; //TODO Perfcounter use unsigned 64bit. What happens with values > 63bit ?
int64_t val = rf->values[i].value;
//iterate over all counters and find the one with matching id //iterate over all counters and find the one with matching id
for (unsigned j = 0; j < _sensors.size(); j++) { for (unsigned j = 0; j < _sensors.size(); j++) {
if (rf->values[i].id == _ids[j]) { if (rf->values[i].id == _ids[j]) {
......
...@@ -122,12 +122,12 @@ void SNMPConnection::init() { ...@@ -122,12 +122,12 @@ void SNMPConnection::init() {
_isInitialized = true; _isInitialized = true;
} }
uint64_t SNMPConnection::issueGet(const oid* const OID, size_t OIDLen) { int64_t SNMPConnection::issueGet(const oid* const OID, size_t OIDLen) {
struct snmp_session* ss; struct snmp_session* ss;
struct snmp_pdu *pdu, *response; struct snmp_pdu *pdu, *response;
struct variable_list *vp; struct variable_list *vp;
int status; int status;
uint64_t ret = 0; int64_t ret = 0;
ss = snmp_open(&_snmpSession); ss = snmp_open(&_snmpSession);
......
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