aboutsummaryrefslogtreecommitdiffstats
path: root/src/ManagementServer.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-16 14:06:19 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-16 14:06:19 +0200
commite91ff1f3b5193713f2fef7876db40c4af5cbc01b (patch)
tree5c91bfbf153b09594b4922feba258ea05370a411 /src/ManagementServer.cpp
parent7a57fb48c25b0dae4e372b8e522f308c589bb35e (diff)
downloaddabmux-e91ff1f3b5193713f2fef7876db40c4af5cbc01b.tar.gz
dabmux-e91ff1f3b5193713f2fef7876db40c4af5cbc01b.tar.bz2
dabmux-e91ff1f3b5193713f2fef7876db40c4af5cbc01b.zip
Merge state management command into values, adapt munin accordingly
Diffstat (limited to 'src/ManagementServer.cpp')
-rw-r--r--src/ManagementServer.cpp60
1 files changed, 9 insertions, 51 deletions
diff --git a/src/ManagementServer.cpp b/src/ManagementServer.cpp
index c44738a..3300c89 100644
--- a/src/ManagementServer.cpp
+++ b/src/ManagementServer.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2009 Her Majesty the Queen in Right of Canada (Communications
Research Center Canada)
- Copyright (C) 2016
+ Copyright (C) 2017
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -146,35 +146,6 @@ std::string ManagementServer::getValuesJSON()
return ss.str();
}
-std::string ManagementServer::getStateJSON()
-{
- boost::mutex::scoped_lock lock(m_statsmutex);
-
- std::ostringstream ss;
- ss << "{\n";
-
- std::map<std::string,InputStat*>::iterator iter;
- int i = 0;
- for(iter = m_inputStats.begin(); iter != m_inputStats.end();
- ++iter, i++)
- {
- const std::string& id = iter->first;
- InputStat* stats = iter->second;
-
- if (i > 0) {
- ss << " ,\n";
- }
-
- ss << " \"" << id << "\" : ";
- ss << stats->encodeStateJSON();
- stats->reset();
- }
-
- ss << "}\n";
-
- return ss.str();
-}
-
void ManagementServer::restart()
{
m_restarter_thread = boost::thread(&ManagementServer::restart_thread,
@@ -244,9 +215,6 @@ void ManagementServer::handle_message(zmq::message_t& zmq_message)
else if (data == "values") {
answer << getValuesJSON();
}
- else if (data == "state") {
- answer << getStateJSON();
- }
else if (data == "getptree") {
boost::unique_lock<boost::mutex> lock(m_configmutex);
boost::property_tree::json_parser::write_json(answer, m_pt);
@@ -305,44 +273,34 @@ std::string InputStat::encodeValuesJSON()
"\"peak_left\": " << dB_l << ", "
"\"peak_right\": " << dB_r << ", "
"\"num_underruns\": " << num_underruns << ", "
- "\"num_overruns\": " << num_overruns <<
- " } }";
+ "\"num_overruns\": " << num_overruns << ", ";
- return ss.str();
-}
-
-std::string InputStat::encodeStateJSON()
-{
- std::ostringstream ss;
-
- ss << "{ \"state\" : ";
+ ss << "\"state\": ";
switch (determineState()) {
case NoData:
- ss << "\"NoData\"";
+ ss << "\"NoData (1)\"";
break;
case Unstable:
- ss << "\"Unstable\"";
+ ss << "\"Unstable (2)\"";
break;
case Silence:
- ss << "\"Silent\"";
+ ss << "\"Silent (3)\"";
break;
case Streaming:
- ss << "\"Streaming\"";
+ ss << "\"Streaming (4)\"";
break;
default:
- ss << "\"Unknown\"";
+ ss << "\"Unknown (0)\"";
}
- ss << " }";
+ ss << " } }";
return ss.str();
}
input_state_t InputStat::determineState()
{
- boost::mutex::scoped_lock lock(m_mutex);
-
time_t now = time(nullptr);
input_state_t state;