mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Proxy: Support heartbeat with ports
This commit is contained in:
parent
d70e7357cf
commit
cf13689e7d
5 changed files with 82 additions and 5 deletions
|
@ -1,7 +1,6 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="private" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="-c console.conf" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" WORKING_DIR="file://$CMakeCurrentBuildDir$/../../../" PASS_PARENT_ENVS_2="true" PROJECT_NAME="srs" TARGET_NAME="srs" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="srs" RUN_TARGET_NAME="srs">
|
||||
<envs>
|
||||
<env name="SRS_RTC_SERVER_ENABLED" value="on" />
|
||||
<env name="MallocNanoZone" value="0" />
|
||||
</envs>
|
||||
<method v="2">
|
||||
|
|
|
@ -907,6 +907,14 @@ heartbeat {
|
|||
# Overwrite by env SRS_HEARTBEAT_SUMMARIES
|
||||
# default: off
|
||||
summaries off;
|
||||
# Whether report with listen ports.
|
||||
# if on, request with the ports of SRS:
|
||||
# {
|
||||
# "rtmp": ["1935"], "http": ["8080"], "api": ["1985"], "srt": ["10080"], "rtc": ["8000"]
|
||||
# }
|
||||
# Overwrite by env SRS_HEARTBEAT_PORTS
|
||||
# default: off
|
||||
ports off;
|
||||
}
|
||||
|
||||
# system statistics section.
|
||||
|
|
|
@ -2409,7 +2409,7 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
for (int i = 0; conf && i < (int)conf->directives.size(); i++) {
|
||||
string n = conf->at(i)->name;
|
||||
if (n != "enabled" && n != "interval" && n != "url"
|
||||
&& n != "device_id" && n != "summaries") {
|
||||
&& n != "device_id" && n != "summaries" && n != "ports") {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal heartbeat.%s", n.c_str());
|
||||
}
|
||||
}
|
||||
|
@ -8794,17 +8794,36 @@ bool SrsConfig::get_heartbeat_summaries()
|
|||
SRS_OVERWRITE_BY_ENV_BOOL("srs.heartbeat.summaries"); // SRS_HEARTBEAT_SUMMARIES
|
||||
|
||||
static bool DEFAULT = false;
|
||||
|
||||
|
||||
SrsConfDirective* conf = get_heartbeart();
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
conf = conf->get("summaries");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return SRS_CONF_PREFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_heartbeat_ports()
|
||||
{
|
||||
SRS_OVERWRITE_BY_ENV_BOOL("srs.heartbeat.ports"); // SRS_HEARTBEAT_PORTS
|
||||
|
||||
static bool DEFAULT = false;
|
||||
|
||||
SrsConfDirective* conf = get_heartbeart();
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("ports");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PREFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
|
|
|
@ -1119,6 +1119,7 @@ public:
|
|||
virtual std::string get_heartbeat_device_id();
|
||||
// Whether report with summaries of http api: /api/v1/summaries.
|
||||
virtual bool get_heartbeat_summaries();
|
||||
bool get_heartbeat_ports();
|
||||
// stats section
|
||||
private:
|
||||
// Get the stats directive.
|
||||
|
|
|
@ -18,6 +18,7 @@ using namespace std;
|
|||
#include <srs_core_autofree.hpp>
|
||||
#include <srs_app_http_conn.hpp>
|
||||
#include <srs_protocol_amf0.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
|
||||
SrsHttpHeartbeat::SrsHttpHeartbeat()
|
||||
{
|
||||
|
@ -67,6 +68,55 @@ srs_error_t SrsHttpHeartbeat::do_heartbeat()
|
|||
|
||||
srs_api_dump_summaries(summaries);
|
||||
}
|
||||
|
||||
if (_srs_config->get_heartbeat_ports()) {
|
||||
// For RTMP listen endpoints.
|
||||
if (true) {
|
||||
SrsJsonArray* o = SrsJsonAny::array();
|
||||
obj->set("rtmp", o);
|
||||
|
||||
vector<string> endpoints = _srs_config->get_listens();
|
||||
for (int i = 0; i < (int) endpoints.size(); i++) {
|
||||
o->append(SrsJsonAny::str(endpoints.at(i).c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// For HTTP Stream listen endpoints.
|
||||
if (_srs_config->get_http_stream_enabled()) {
|
||||
SrsJsonArray* o = SrsJsonAny::array();
|
||||
obj->set("http", o);
|
||||
|
||||
string endpoint = _srs_config->get_http_stream_listen();
|
||||
o->append(SrsJsonAny::str(endpoint.c_str()));
|
||||
}
|
||||
|
||||
// For HTTP API listen endpoints.
|
||||
if (_srs_config->get_http_api_enabled()) {
|
||||
SrsJsonArray* o = SrsJsonAny::array();
|
||||
obj->set("api", o);
|
||||
|
||||
string endpoint = _srs_config->get_http_api_listen();
|
||||
o->append(SrsJsonAny::str(endpoint.c_str()));
|
||||
}
|
||||
|
||||
// For SRT listen endpoints.
|
||||
if (_srs_config->get_srt_enabled()) {
|
||||
SrsJsonArray* o = SrsJsonAny::array();
|
||||
obj->set("srt", o);
|
||||
|
||||
uint16_t endpoint = _srs_config->get_srt_listen_port();
|
||||
o->append(SrsJsonAny::str(srs_int2str(endpoint).c_str()));
|
||||
}
|
||||
|
||||
// For WebRTC listen endpoints.
|
||||
if (_srs_config->get_rtc_server_enabled()) {
|
||||
SrsJsonArray* o = SrsJsonAny::array();
|
||||
obj->set("rtc", o);
|
||||
|
||||
int endpoint = _srs_config->get_rtc_server_listen();
|
||||
o->append(SrsJsonAny::str(srs_int2str(endpoint).c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
SrsHttpClient http;
|
||||
if ((err = http.initialize(uri.get_schema(), uri.get_host(), uri.get_port())) != srs_success) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue