winshining / nginx-http-flv-module

A media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module provides, HTTP-FLV, GOP cache, VHosts (one IP for multi domain names) and JSON style statistics are supported now.
BSD 2-Clause "Simplified" License
2.72k stars 567 forks source link

[feature] 增加k/v的stat统计, 便于使用Prometheus 调用 #197

Closed ahsar closed 3 years ago

ahsar commented 3 years ago

[feature] 增加k/v的stat统计, 便于使用Prometheus 调用. 我使用

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
    <xsl:value-of select="/http-flv/server/application[1]/name"/>
        <xsl:text> </xsl:text>
    <xsl:value-of select="/http-flv/server/application[1]/live/nclients"/>
</xsl:template>
</xsl:stylesheet>

有些情况下, nclients统计的数量为0

ahsar commented 3 years ago

如果配置worker_processes > 1 或者 auto就不ok

winshining commented 3 years ago

README 里已经明确写了:

English: It's better to specify the directive worker_processes as 1, because ngx_rtmp_stat_module may not get statistics from a specified worker process in multi-processes mode, for HTTP requests are randomly distributed to worker processes. ngx_rtmp_control_module has the same problem. The problem can be optimized by this patch per-worker-listener.

中文: 最好将配置项 worker_processes 设置为 1,因为在多进程模式下,ngx_rtmp_stat_module 可能不会从指定的 worker 进程获取统计数据,因为 HTTP 请求是被随机分配给 worker 进程的。ngx_rtmp_control_module 也有同样的问题。这个问题可以通过这个补丁 per-worker-listener 优化。

要优化这个功能,需要修改 Nginx 本身的代码,请自行修改。