mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
STAT: Support config server_id and generate one if empty. v4.0.257
This commit is contained in:
parent
8e6d207e56
commit
9923c749d4
9 changed files with 158 additions and 33 deletions
|
@ -238,8 +238,6 @@ SrsStatistic* SrsStatistic::_instance = NULL;
|
|||
|
||||
SrsStatistic::SrsStatistic()
|
||||
{
|
||||
_server_id = srs_generate_stat_vid();
|
||||
|
||||
clk = new SrsWallClock();
|
||||
kbps = new SrsKbps(clk);
|
||||
kbps->set_io(NULL, NULL);
|
||||
|
@ -521,7 +519,10 @@ SrsKbps* SrsStatistic::kbps_sample()
|
|||
|
||||
std::string SrsStatistic::server_id()
|
||||
{
|
||||
return _server_id;
|
||||
if (server_id_.empty()) {
|
||||
server_id_ = _srs_config->get_server_id();
|
||||
}
|
||||
return server_id_;
|
||||
}
|
||||
|
||||
srs_error_t SrsStatistic::dumps_vhosts(SrsJsonArray* arr)
|
||||
|
@ -589,6 +590,22 @@ srs_error_t SrsStatistic::dumps_clients(SrsJsonArray* arr, int start, int count)
|
|||
return err;
|
||||
}
|
||||
|
||||
void SrsStatistic::dumps_hints_kv(std::stringstream & ss)
|
||||
{
|
||||
if (!streams.empty()) {
|
||||
ss << "&streams=" << streams.size();
|
||||
}
|
||||
if (!clients.empty()) {
|
||||
ss << "&clients=" << clients.size();
|
||||
}
|
||||
if (kbps->get_recv_kbps_30s()) {
|
||||
ss << "&recv=" << kbps->get_recv_kbps_30s();
|
||||
}
|
||||
if (kbps->get_send_kbps_30s()) {
|
||||
ss << "&send=" << kbps->get_send_kbps_30s();
|
||||
}
|
||||
}
|
||||
|
||||
SrsStatisticVhost* SrsStatistic::create_vhost(SrsRequest* req)
|
||||
{
|
||||
SrsStatisticVhost* vhost = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue