Commit 12cbba8c authored by lu43jih's avatar lu43jih
Browse files

Working on Gpfsmon plugin

parent 06d035bb
...@@ -97,10 +97,8 @@ libdcdbplugin_snmp.$(LIBEXT): src/sensors/snmp/SNMPSensorGroup.o src/sensors/snm ...@@ -97,10 +97,8 @@ libdcdbplugin_snmp.$(LIBEXT): src/sensors/snmp/SNMPSensorGroup.o src/sensors/snm
libdcdbplugin_procfs.$(LIBEXT): src/sensors/procfs/ProcfsSensorGroup.o src/sensors/procfs/ProcfsParser.o src/sensors/procfs/ProcfsConfigurator.o libdcdbplugin_procfs.$(LIBEXT): src/sensors/procfs/ProcfsSensorGroup.o src/sensors/procfs/ProcfsParser.o src/sensors/procfs/ProcfsConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex $(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lboost_regex
libdcdbplugin_gpfsmon.$(LIBEXT): src/sensors/gpfsmon/GpfsmonSensorGroup.o libdcdbplugin_gpfsmon.$(LIBEXT): src/sensors/gpfsmon/GpfsmonSensorGroup.o src/sensors/gpfsmon/GpfsmonConfigurator.o
$(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system $(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system
#src/sensors/gpfsmon/gpfsmonConfigurator.o
#libdcdbplugin_opa.$(LIBEXT): src/sensors/opa/OpaSensorGroup.o src/sensors/opa/OpaConfigurator.o #libdcdbplugin_opa.$(LIBEXT): src/sensors/opa/OpaSensorGroup.o src/sensors/opa/OpaConfigurator.o
# $(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lopamgt -libverbs -libumad -lssl # $(CXX) $(LIBFLAGS)$@ -o $@ $^ -L$(DCDBDEPLOYPATH)/lib/ -lboost_log -lboost_system -lopamgt -libverbs -libumad -lssl
/*
* gpfsmonConfigurator.cpp
*
* Created on: 26.11.2018
* Author: Your name goes here!
*/
#include "GpfsmonConfigurator.h"
GpfsmonConfigurator::GpfsmonConfigurator() {
_metricMap["TIMESTAMP_GPFS"]=TIMESTAMP_GPFS;
_metricMap["IOBYTESREAD"]=IOBYTESREAD;
_metricMap["IOBYTESWRITE"]=IOBYTESWRITE;
_metricMap["IOOPENS"]=IOOPENS;
_metricMap["IOCLOSES"]=IOCLOSES;
_metricMap["IOREADS"]=IOREADS;
_metricMap["IOWRITES"]=IOWRITES;
_metricMap["READDIR"]=READDIR;
_metricMap["INODE_UPDATES"]=INODE_UPDATES;
_groupName = "group";
_baseName = "sensor";
}
GpfsmonConfigurator::~GpfsmonConfigurator() {}
void GpfsmonConfigurator::sensorBase(GpfsmonSensorBase& s, CFG_VAL config) {
ADD {
if (boost::iequals(val.first, "metric")) {
auto it = _metricMap.find(val.second.data());
if(it != _metricMap.end()) {
if(it->second == TIMESTAMP_GPFS){
LOG(warning) << " metric \"" << val.second.data() << "\" not supported.";
} else {
s.setMetricType(it->second);
}
} else {
LOG(warning) << " metric \"" << val.second.data() << "\" not known.";
}
} else if(boost::iequals(val.first, "nodeName")){
s.setNodeName(val.second.data());
}
}
}
void GpfsmonConfigurator::sensorGroup(GpfsmonSensorGroup& s, CFG_VAL config) {
ADD {
//ToDo do I need something here?
}
}
...@@ -11,20 +11,23 @@ ...@@ -11,20 +11,23 @@
#include "../../includes/ConfiguratorTemplate.h" #include "../../includes/ConfiguratorTemplate.h"
#include "GpfsmonSensorGroup.h" #include "GpfsmonSensorGroup.h"
class gpfsmonConfigurator : public ConfiguratorTemplate<GpfsmonSensorBase, GpfsmonSensorGroup> { class GpfsmonConfigurator : public ConfiguratorTemplate<GpfsmonSensorBase, GpfsmonSensorGroup> {
public: public:
gpfsmonConfigurator(); GpfsmonConfigurator();
virtual ~gpfsmonConfigurator(); virtual ~GpfsmonConfigurator();
protected: protected:
/* Overwritten from ConfiguratorTemplate */ /* Overwritten from ConfiguratorTemplate */
void sensorBase(GpfsmonSensorBase& s, CFG_VAL config) override; void sensorBase(GpfsmonSensorBase& s, CFG_VAL config) override;
void sensorGroup(GpfsmonSensorGroup& s, CFG_VAL config) override; void sensorGroup(GpfsmonSensorGroup& s, CFG_VAL config) override;
private:
std::map<std::string, GPFS_METRIC> _metricMap;
}; };
extern "C" ConfiguratorInterface* create() { extern "C" ConfiguratorInterface* create() {
return new gpfsmonConfigurator; return new GpfsmonConfigurator;
} }
extern "C" void destroy(ConfiguratorInterface* c) { extern "C" void destroy(ConfiguratorInterface* c) {
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
class GpfsmonSensorBase : public SensorBase { class GpfsmonSensorBase : public SensorBase {
public: public:
GpfsmonSensorBase(const std::string& name, GPFS_METRIC metric_type, const std::string& node_name) : GpfsmonSensorBase(const std::string& name) :
SensorBase(name), _metric_type(metric_type), _node_name(node_name) { SensorBase(name), _metric_type(GPFS_METRIC::SIZE) {
setDelta(true); setDelta(true);
} }
......
...@@ -26,14 +26,11 @@ bool SensorCompare::operator()(const Gpfs_SB& lhs, const Gpfs_SB & rhs) const { ...@@ -26,14 +26,11 @@ bool SensorCompare::operator()(const Gpfs_SB& lhs, const Gpfs_SB & rhs) const {
GpfsmonSensorGroup::GpfsmonSensorGroup(const std::string& name) : GpfsmonSensorGroup::GpfsmonSensorGroup(const std::string& name) :
SensorGroupTemplate(name) { SensorGroupTemplate(name) {
createTempFile(); createTempFile();
searchDummy = std::make_shared<GpfsmonSensorBase>("", GPFS_METRIC::SIZE, "" ); searchDummy = std::make_shared<GpfsmonSensorBase>("Dummy");
} }
GpfsmonSensorGroup::~GpfsmonSensorGroup() { GpfsmonSensorGroup::~GpfsmonSensorGroup() {
/* data.clear();
* TODO
* Tear down attributes
*/
} }
void GpfsmonSensorGroup::start() { void GpfsmonSensorGroup::start() {
...@@ -75,61 +72,51 @@ void GpfsmonSensorGroup::read() { ...@@ -75,61 +72,51 @@ void GpfsmonSensorGroup::read() {
//ToDo parse nodename here //ToDo parse nodename here
std::string nodename = "blabla"; std::string nodename = "blabla";
searchDummy->setNodeName(nodename);
std::string::size_type bytereads_pos = toparse.find("_br_ "); std::string::size_type bytereads_pos = toparse.find("_br_ ");
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){
//cout << "token_substr = " << toparse.substr(bytereads_pos + 5, bytewrite_pos - bytereads_pos) << endl;
data[IOBYTESREAD] = std::stoull(toparse.substr(bytereads_pos + 5, bytewrite_pos - bytereads_pos)); data[IOBYTESREAD] = std::stoull(toparse.substr(bytereads_pos + 5, bytewrite_pos - bytereads_pos));
//cout << "iobytesread = " << iobytesread << endl;
} else { } else {
//ToDo log error?
break; break;
} }
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 ){
//cout << "token_substr = " << toparse.substr(bytewrite_pos + 6, opens_pos - bytewrite_pos) << endl;
data[IOBYTESWRITE] = std::stoull(toparse.substr(bytewrite_pos + 6, opens_pos - bytewrite_pos)); data[IOBYTESWRITE] = std::stoull(toparse.substr(bytewrite_pos + 6, opens_pos - bytewrite_pos));
//cout << "iobyteswrite = " << iobyteswrite << endl;
} else { } else {
break; break;
} }
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){
//cout << "token_substr = " << toparse.substr(opens_pos + 6, closes_pos - opens_pos) << endl;
data[IOOPENS] = std::stoull(toparse.substr(opens_pos + 6, closes_pos - opens_pos)); data[IOOPENS] = std::stoull(toparse.substr(opens_pos + 6, closes_pos - opens_pos));
//cout << "ioopens = " << ioopens << endl;
} else { } else {
break; break;
} }
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 ){
//cout << "token_substr = " << toparse.substr(closes_pos + 6, reads_pos - closes_pos) << endl;
data[IOCLOSES] = std::stoull(toparse.substr(closes_pos + 6, reads_pos - closes_pos)); data[IOCLOSES] = std::stoull(toparse.substr(closes_pos + 6, reads_pos - closes_pos));
//cout << "iocloses = " << iocloses << endl;
} else { } else {
break; break;
} }
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 ){
//cout << "token_substr = " << toparse.substr(reads_pos + 7, writes_pos - reads_pos) << endl;
data[IOREADS] = std::stoull(toparse.substr(reads_pos + 7, writes_pos - reads_pos)); data[IOREADS] = std::stoull(toparse.substr(reads_pos + 7, writes_pos - reads_pos));
//cout << "ioreads = " << ioreads << endl;
} else { } else {
break; break;
} }
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 ){
//cout << "token_substr = " << toparse.substr(writes_pos + 6, dir_pos - writes_pos) << endl;
data[IOWRITES] = std::stoull(toparse.substr(writes_pos + 6, dir_pos - writes_pos)); data[IOWRITES] = std::stoull(toparse.substr(writes_pos + 6, dir_pos - writes_pos));
//cout << "iowrites = " << iowrites << endl;
} else { } else {
break; break;
} }
for(unsigned int i=0; i< static_cast<unsigned int>(GPFS_METRIC::SIZE); ++i){
for(unsigned int i=1; i< static_cast<unsigned int>(GPFS_METRIC::SIZE); ++i){
reading.value = data[i]; reading.value = data[i];
searchDummy->setNodeName(nodename);
searchDummy->setMetricType(static_cast<GPFS_METRIC>(i)); searchDummy->setMetricType(static_cast<GPFS_METRIC>(i));
auto found = std::lower_bound(_sensors.begin(), _sensors.end(), searchDummy, SensorCompare()); auto found = std::lower_bound(_sensors.begin(), _sensors.end(), searchDummy, SensorCompare());
if(found != _sensors.end()){ if(found != _sensors.end()){
...@@ -169,3 +156,10 @@ void GpfsmonSensorGroup::createTempFile(){ ...@@ -169,3 +156,10 @@ void GpfsmonSensorGroup::createTempFile(){
LOG(error) << "Gpfsmon: unable to create temporary file for mmpmon"; LOG(error) << "Gpfsmon: unable to create temporary file for mmpmon";
} }
} }
GpfsmonSensorGroup& GpfsmonSensorGroup::operator=(const GpfsmonSensorGroup& other){
SensorGroupTemplate<GpfsmonSensorBase>::operator=(other);
data = other.data; //copy of vectors
searchDummy = std::make_shared<GpfsmonSensorBase>("Dummy"); //new pointer instead of shared...
return *this;
}
...@@ -23,17 +23,19 @@ public: ...@@ -23,17 +23,19 @@ public:
void start() override; void start() override;
void stop() override; void stop() override;
const static int BUFFER_SIZE=255; //!< constant buffer that is parse by a line given from the popen command GpfsmonSensorGroup& operator=(const GpfsmonSensorGroup& other);
private: private:
void read() override; void read() override;
void readAsync() override; void readAsync() override;
void createTempFile(); void createTempFile();
const std::string &cmd_io = "/usr/lpp/mmfs/bin/mmpmon -p -i /tmp/gpfsmon"; const std::string cmd_io = "/usr/lpp/mmfs/bin/mmpmon -p -i /tmp/gpfsmon"; //todo change to real command
Gpfs_SB searchDummy; Gpfs_SB searchDummy;
std::vector<uint64_t> data; //todo change file std::vector<uint64_t> data;
constexpr static int BUFFER_SIZE=255; //!< constant buffer that is parse by a line given from the popen command
}; };
......
/*
* gpfsmonConfigurator.cpp
*
* Created on: 26.11.2018
* Author: Your name goes here!
*/
#include "gpfsmonConfigurator.h"
gpfsmonConfigurator::gpfsmonConfigurator() {
/*
* TODO
* If you want sensor, group or entity to be named differently in the config file, you can change it here
*/
_groupName = "group";
_baseName = "sensor";
}
gpfsmonConfigurator::~gpfsmonConfigurator() {}
void gpfsmonConfigurator::sensorBase(GpfsmonSensorBase& s, CFG_VAL config) {
ADD {
/*
* TODO
* Add ATTRIBUTE macros for sensorBase attributes
*/
//ATTRIBUTE("attributeName", attributeSetter);
}
}
void gpfsmonConfigurator::sensorGroup(GpfsmonSensorGroup& s, CFG_VAL config) {
ADD {
/*
* TODO
* Add ATTRIBUTE macros for sensorGroup attributes
*/
}
}
Supports Markdown
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