1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

support report summaries in heartbeat. 0.9.132

This commit is contained in:
winlin 2014-06-23 15:44:49 +08:00
parent db253bc76b
commit f173345e15
10 changed files with 157 additions and 97 deletions

View file

@ -61,26 +61,30 @@ void SrsHttpHeartbeat::heartbeat()
vector<string>& ips = srs_get_local_ipv4_ips();
if (!ips.empty()) {
ip = ips[0]; // TODO: FIXME: maybe need to config it.
ip = ips[_srs_config->get_heartbeat_device_index() % (int)ips.size()];
}
std::stringstream ss;
ss << JOBJECT_START
<< JFIELD_STR("device_id", device_id) << JFIELD_CONT
<< JFIELD_STR("ip", ip)
<< JOBJECT_END;
<< JFIELD_STR("ip", ip);
if (_srs_config->get_heartbeat_summaries()) {
ss << JFIELD_CONT << JFIELD_ORG("summaries", "");
srs_api_dump_summaries(ss);
}
ss << JOBJECT_END;
std::string data = ss.str();
std::string res;
SrsHttpClient http;
if ((ret = http.post(&uri, data, res)) != ERROR_SUCCESS) {
srs_error("http post hartbeart uri failed. "
srs_info("http post hartbeart uri failed. "
"url=%s, request=%s, response=%s, ret=%d",
url.c_str(), data.c_str(), res.c_str(), ret);
return;
}
srs_trace("http hook hartbeart success. "
srs_info("http hook hartbeart success. "
"url=%s, request=%s, response=%s, ret=%d",
url.c_str(), data.c_str(), res.c_str(), ret);