Commit 01b3bb8f authored by Alessio Netti's avatar Alessio Netti
Browse files

SysFS: added support for wildcard resolution

parent 5c236dc1
......@@ -56,6 +56,23 @@ SysfsSensorGroup &SysfsSensorGroup::operator=(const SysfsSensorGroup &other) {
return *this;
}
void SysfsSensorGroup::execOnInit() {
if(std::strpbrk(_path.c_str(), "?*[]")) {
LOG(debug) << "Detected pattern " << _path << ".";
glob_t paths;
if(glob(_path.c_str(), 0, NULL, &paths)==0) {
if(paths.gl_pathc > 1) {
LOG(warning) << "Multiple matches found for pattern " << _path << ". Only the first one will be picked.";
}
_path = paths.gl_pathv[0];
LOG(debug) << "Using path " << _path << " from pattern.";
globfree(&paths);
} else {
LOG(warning) << "No matches found for pattern " << _path << "!";
}
}
}
bool SysfsSensorGroup::execOnStart() {
if (_retain && _file == NULL) {
_file = fopen(_path.c_str(), "r");
......
......@@ -30,6 +30,7 @@
#include "../../includes/SensorGroupTemplate.h"
#include "SysfsSensorBase.h"
#include "glob.h"
/**
* @brief SensorGroupTemplate specialization for this plugin.
......@@ -44,6 +45,7 @@ class SysfsSensorGroup : public SensorGroupTemplate<SysfsSensorBase> {
virtual ~SysfsSensorGroup();
SysfsSensorGroup &operator=(const SysfsSensorGroup &other);
void execOnInit() final override;
bool execOnStart() final override;
void execOnStop() final override;
......
......@@ -143,10 +143,10 @@ void JobAction::doShow(std::string jobId, std::string domainId) {
std::cout << std::endl;
break;
case DCDB::JD_JOBKEYNOTFOUND:
std::cout << "Job key " << jobId << " with domain ID " << domainId << "not found." << std::endl;
std::cout << "Job key " << jobId << " with domain ID " << domainId << " not found." << std::endl;
break;
case DCDB::JD_JOBIDNOTFOUND:
std::cout << "Job ID " << jobId << " with domain ID " << domainId << "not found." << std::endl;
std::cout << "Job ID " << jobId << " with domain ID " << domainId << " not found." << std::endl;
break;
default:
std::cout << "Internal error." << std::endl;
......
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