added uptime to statisctics

This commit is contained in:
Roman Arutyunyan
2012-06-22 14:07:03 +04:00
parent f48bcc5235
commit ae71903de4
2 changed files with 38 additions and 21 deletions

View File

@ -17,6 +17,9 @@ static char * ngx_rtmp_stat_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child); void *parent, void *child);
static time_t start_time;
#define NGX_RTMP_STAT_ALL 0xff #define NGX_RTMP_STAT_ALL 0xff
#define NGX_RTMP_STAT_GLOBAL 0x01 #define NGX_RTMP_STAT_GLOBAL 0x01
#define NGX_RTMP_STAT_LIVE 0x02 #define NGX_RTMP_STAT_LIVE 0x02
@ -448,6 +451,7 @@ ngx_rtmp_stat_handler(ngx_http_request_t *r)
ngx_chain_t *cl, *l, **ll, ***lll; ngx_chain_t *cl, *l, **ll, ***lll;
size_t n; size_t n;
off_t len; off_t len;
static u_char tbuf[NGX_TIME_T_LEN + 1];
r->keepalive = 0; r->keepalive = 0;
slcf = ngx_http_get_module_loc_conf(r, ngx_rtmp_stat_module); slcf = ngx_http_get_module_loc_conf(r, ngx_rtmp_stat_module);
@ -482,6 +486,11 @@ ngx_rtmp_stat_handler(ngx_http_request_t *r)
#endif #endif
NGX_RTMP_STAT_L("<built>" __DATE__ " " __TIME__ "</built>\r\n"); NGX_RTMP_STAT_L("<built>" __DATE__ " " __TIME__ "</built>\r\n");
NGX_RTMP_STAT_L("<uptime>");
NGX_RTMP_STAT(tbuf, ngx_snprintf(tbuf, sizeof(tbuf),
"%T", ngx_cached_time->sec - start_time) - tbuf);
NGX_RTMP_STAT_L("</uptime>\r\n");
ngx_rtmp_stat_bw(r, lll, &ngx_rtmp_bw_in, &ngx_rtmp_bw_out); ngx_rtmp_stat_bw(r, lll, &ngx_rtmp_bw_in, &ngx_rtmp_bw_out);
cscf = cmcf->servers.elts; cscf = cmcf->servers.elts;
@ -552,6 +561,8 @@ ngx_rtmp_stat_postconfiguration(ngx_conf_t *cf)
} }
*h = ngx_rtmp_stat_handler; *h = ngx_rtmp_stat_handler;
start_time = ngx_cached_time->sec;
return NGX_OK; return NGX_OK;
} }

View File

@ -40,6 +40,12 @@
<td><xsl:value-of select="out"/></td> <td><xsl:value-of select="out"/></td>
<td><xsl:value-of select="round(bwin div 1024)"/></td> <td><xsl:value-of select="round(bwin div 1024)"/></td>
<td><xsl:value-of select="round(bwout div 1024)"/></td> <td><xsl:value-of select="round(bwout div 1024)"/></td>
<td colspan="5"/>
<td>
<xsl:call-template name="showtime">
<xsl:with-param name="time" select="/rtmp/uptime * 1000"/>
</xsl:call-template>
</td>
</tr> </tr>
<xsl:apply-templates select="server"/> <xsl:apply-templates select="server"/>
</table> </table>
@ -130,7 +136,7 @@
<xsl:param name="time"/> <xsl:param name="time"/>
<xsl:variable name="sec"> <xsl:variable name="sec">
<xsl:value-of select="floor(time div 1000)"/> <xsl:value-of select="floor($time div 1000)"/>
</xsl:variable> </xsl:variable>
<xsl:if test="$sec &gt;= 86400"> <xsl:if test="$sec &gt;= 86400">