@@ -27,6 +27,12 @@ namespace o2
2727namespace monitoring
2828{
2929
30+ static const std::map<std::string, Verbosity> verbosities = {
31+ {" /prod" , Verbosity::Prod},
32+ {" /info" , Verbosity::Info},
33+ {" /debug" , Verbosity::Debug}
34+ };
35+
3036std::unique_ptr<Backend> getStdOut (http::url) {
3137 return std::make_unique<backends::StdOut>();
3238}
@@ -42,6 +48,16 @@ std::unique_ptr<Backend> getInfluxDb(http::url uri) {
4248 if (uri.protocol == " http" ) {
4349 return std::make_unique<backends::InfluxDB>(uri.host , uri.port , uri.search );
4450 }
51+ if (uri.protocol == " unix" ) {
52+ std::string path = uri.path ;;
53+ auto found = std::find_if (begin (verbosities), end (verbosities),
54+ [&](const auto & s)
55+ {return path.find (s.first ) != std::string::npos; });
56+ if (found != end (verbosities)) {
57+ path.erase (path.rfind (' /' ));
58+ }
59+ return std::make_unique<backends::InfluxDB>(path);
60+ }
4561 throw std::runtime_error (" InfluxDB transport protocol not supported" );
4662}
4763
@@ -64,12 +80,6 @@ std::unique_ptr<Backend> getFlume(http::url uri) {
6480}
6581
6682void MonitoringFactory::SetVerbosity (std::string selected, std::unique_ptr<Backend>& backend) {
67- static const std::map<std::string, Verbosity> verbosities = {
68- {" /prod" , Verbosity::Prod},
69- {" /info" , Verbosity::Info},
70- {" /debug" , Verbosity::Debug}
71- };
72-
7383 auto found = verbosities.find (selected);
7484 if (found == verbosities.end ()) {
7585 throw std::runtime_error (" Unrecognised verbosity" );
@@ -86,6 +96,7 @@ std::unique_ptr<Backend> MonitoringFactory::GetBackend(std::string& url) {
8696 {" stdout" , getStdOut},
8797 {" influxdb-udp" , getInfluxDb},
8898 {" influxdb-http" , getInfluxDb},
99+ {" influxdb-unix" , getInfluxDb},
89100 {" apmon" , getApMon},
90101 {" flume" , getFlume},
91102 {" no-op" , getNoop}
@@ -103,7 +114,7 @@ std::unique_ptr<Backend> MonitoringFactory::GetBackend(std::string& url) {
103114
104115 auto backend = iterator->second (parsedUrl);
105116 if (!parsedUrl.path .empty () && parsedUrl.path != " /" ) {
106- SetVerbosity (parsedUrl.path , backend);
117+ SetVerbosity (parsedUrl.path . substr (parsedUrl. path . rfind ( " / " )) , backend);
107118 }
108119 return backend;
109120}
0 commit comments