Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-08-02 09:54:21 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
721acc350a5501ba8f7b48276b8087566fcf5e56
721acc35
1 parent
d5f03200
fix #142, tcp stat slow bug, use /proc/net/sockstat instead, refer to 'ss -s'. 0.9.183.
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
60 行增加
和
57 行删除
README.md
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_utility.cpp
trunk/src/app/srs_app_utility.hpp
trunk/src/core/srs_core.hpp
README.md
查看文件 @
721acc3
...
...
@@ -207,6 +207,7 @@ Supported operating systems and hardware:
*
2013-10-17, Created.
<br/>
## History
*
v1.0, 2014-08-02, fix
[
#142
](
https://github.com/winlinvip/simple-rtmp-server/issues/142
)
, fix tcp stat slow bug, use /proc/net/sockstat instead, refer to 'ss -s'. 0.9.183.
*
v1.0, 2014-07-31, fix
[
#141
](
https://github.com/winlinvip/simple-rtmp-server/issues/141
)
, support tun0(vpn network device) ip retrieve. 0.9.179.
*
v1.0, 2014-07-27, support build on OSX(Darwin). 0.9.177
*
v1.0, 2014-07-27, api connections add udp, add disk iops. 0.9.176
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
721acc3
...
...
@@ -68,6 +68,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_RUSAGE_RESOLUTION_TIMES
#define SRS_SYS_RUSAGE_RESOLUTION_TIMES 30
// update network devices info interval:
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES
#define SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES 30
// update rusage interval:
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_CPU_STAT_RESOLUTION_TIMES
#define SRS_SYS_CPU_STAT_RESOLUTION_TIMES 30
...
...
@@ -88,10 +92,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES
#define SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES 90
// update network devices info interval:
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES
#define SRS_SYS_NETWORK_RTMP_SERVER_RESOLUTION_TIMES 90
SrsListener
::
SrsListener
(
SrsServer
*
server
,
SrsListenerType
type
)
{
fd
=
-
1
;
...
...
trunk/src/app/srs_app_utility.cpp
查看文件 @
721acc3
...
...
@@ -781,7 +781,7 @@ SrsNetworkRtmpServer::SrsNetworkRtmpServer()
ok
=
false
;
sample_time
=
rbytes
=
sbytes
=
0
;
nb_conn_sys
=
nb_conn_srs
=
0
;
nb_conn_sys_et
=
nb_conn_sys_tw
=
nb_conn_sys_ls
=
0
;
nb_conn_sys_et
=
nb_conn_sys_tw
=
0
;
nb_conn_sys_udp
=
0
;
}
...
...
@@ -812,88 +812,88 @@ enum {
void
srs_update_rtmp_server
(
int
nb_conn
,
SrsKbps
*
kbps
)
{
SrsNetworkRtmpServer
&
r
=
_srs_network_rtmp_server
;
// reset total.
r
.
nb_conn_sys
=
0
;
int
nb_socks
=
0
;
int
nb_tcp4_hashed
=
0
;
int
nb_tcp_orphans
=
0
;
int
nb_tcp_tws
=
0
;
int
nb_tcp_total
=
0
;
int
nb_tcp_mem
=
0
;
int
nb_udp4
=
0
;
if
(
true
)
{
FILE
*
f
=
fopen
(
"/proc/net/
tcp
"
,
"r"
);
FILE
*
f
=
fopen
(
"/proc/net/
sockstat
"
,
"r"
);
if
(
f
==
NULL
)
{
srs_warn
(
"open proc network
tcp
failed, ignore"
);
srs_warn
(
"open proc network
sockstat
failed, ignore"
);
return
;
}
// ignore title.
static
char
buf
[
1024
];
fgets
(
buf
,
sizeof
(
buf
),
f
);
int
nb_conn_sys_established
=
0
;
int
nb_conn_sys_time_wait
=
0
;
int
nb_conn_sys_listen
=
0
;
int
nb_conn_sys_other
=
0
;
// @see: http
://tester-higkoo.googlecode.com/svn-history/r14/trunk/Tools/iostat/iostat
.c
// @see: http
s://github.com/shemminger/iproute2/blob/master/misc/ss
.c
while
(
fgets
(
buf
,
sizeof
(
buf
),
f
))
{
int
st
=
0
;
int
ret
=
sscanf
(
buf
,
"%*s %*s %*s %2x
\n
"
,
&
st
);
if
(
ret
==
1
)
{
if
(
st
==
SYS_TCP_ESTABLISHED
)
{
nb_conn_sys_established
++
;
}
else
if
(
st
==
SYS_TCP_TIME_WAIT
)
{
nb_conn_sys_time_wait
++
;
}
else
if
(
st
==
SYS_TCP_LISTEN
)
{
nb_conn_sys_listen
++
;
}
else
{
nb_conn_sys_other
++
;
}
}
if
(
ret
==
EOF
)
{
break
;
// @see: get_sockstat_line()
if
(
strncmp
(
buf
,
"sockets: used "
,
14
)
==
0
)
{
int
ret
=
sscanf
(
buf
,
"%*s %*s %d
\n
"
,
&
nb_socks
);
srs_assert
(
ret
==
1
);
}
else
if
(
strncmp
(
buf
,
"TCP: "
,
5
)
==
0
)
{
int
ret
=
sscanf
(
buf
,
"%*s %*s %d %*s %d %*s %d %*s %d %*s %d
\n
"
,
&
nb_tcp4_hashed
,
&
nb_tcp_orphans
,
&
nb_tcp_tws
,
&
nb_tcp_total
,
&
nb_tcp_mem
);
srs_assert
(
ret
==
5
);
}
else
if
(
strncmp
(
buf
,
"UDP: "
,
5
)
==
0
)
{
int
ret
=
sscanf
(
buf
,
"%*s %*s %d
\n
"
,
&
nb_udp4
);
srs_assert
(
ret
==
1
);
}
}
r
.
nb_conn_sys
=
nb_conn_sys_established
+
nb_conn_sys_time_wait
+
nb_conn_sys_listen
+
nb_conn_sys_other
;
r
.
nb_conn_sys_et
=
nb_conn_sys_established
;
r
.
nb_conn_sys_tw
=
nb_conn_sys_time_wait
;
r
.
nb_conn_sys_ls
=
nb_conn_sys_listen
;
fclose
(
f
);
}
int
nb_tcp_estab
=
0
;
if
(
true
)
{
FILE
*
f
=
fopen
(
"/proc/net/
ud
p"
,
"r"
);
FILE
*
f
=
fopen
(
"/proc/net/
snm
p"
,
"r"
);
if
(
f
==
NULL
)
{
srs_warn
(
"open proc network
ud
p failed, ignore"
);
srs_warn
(
"open proc network
snm
p failed, ignore"
);
return
;
}
// ignore title.
static
char
buf
[
1024
];
fgets
(
buf
,
sizeof
(
buf
),
f
);
// all udp is close state.
int
nb_conn_sys_close
=
0
;
// @see: http
://tester-higkoo.googlecode.com/svn-history/r14/trunk/Tools/iostat/iostat
.c
// @see: http
s://github.com/shemminger/iproute2/blob/master/misc/ss
.c
while
(
fgets
(
buf
,
sizeof
(
buf
),
f
))
{
int
st
=
0
;
int
ret
=
sscanf
(
buf
,
"%*s %*s %*s %2x
\n
"
,
&
st
);
if
(
ret
==
EOF
)
{
break
;
// @see: get_snmp_int("Tcp:", "CurrEstab", &sn.tcp_estab)
// tcp stat title
if
(
strncmp
(
buf
,
"Tcp: "
,
5
)
==
0
)
{
// read tcp stat data
if
(
!
fgets
(
buf
,
sizeof
(
buf
),
f
))
{
break
;
}
// parse tcp stat data
if
(
strncmp
(
buf
,
"Tcp: "
,
5
)
==
0
)
{
int
ret
=
sscanf
(
buf
,
"%*s %*d %*d %*d %*d %*d %*d %*d %*d %d
\n
"
,
&
nb_tcp_estab
);
srs_assert
(
ret
==
1
);
}
}
nb_conn_sys_close
++
;
}
r
.
nb_conn_sys
+=
nb_conn_sys_close
;
r
.
nb_conn_sys_udp
=
nb_conn_sys_close
;
fclose
(
f
);
}
// @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c
// TODO: FIXME: ignore the slabstat, @see: get_slabstat()
if
(
true
)
{
// @see: print_summary()
r
.
nb_conn_sys
=
nb_tcp_total
+
nb_tcp_tws
;
r
.
nb_conn_sys_et
=
nb_tcp_estab
;
r
.
nb_conn_sys_tw
=
nb_tcp_tws
;
r
.
nb_conn_sys_udp
=
nb_udp4
;
}
if
(
true
)
{
r
.
ok
=
true
;
...
...
@@ -1113,7 +1113,6 @@ void srs_api_dump_summaries(std::stringstream& ss)
<<
__SRS_JFIELD_ORG
(
"conn_sys"
,
nrs
->
nb_conn_sys
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_sys_et"
,
nrs
->
nb_conn_sys_et
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_sys_tw"
,
nrs
->
nb_conn_sys_tw
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_sys_ls"
,
nrs
->
nb_conn_sys_ls
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_sys_udp"
,
nrs
->
nb_conn_sys_udp
)
<<
__SRS_JFIELD_CONT
<<
__SRS_JFIELD_ORG
(
"conn_srs"
,
nrs
->
nb_conn_srs
)
<<
__SRS_JOBJECT_END
...
...
trunk/src/app/srs_app_utility.hpp
查看文件 @
721acc3
...
...
@@ -595,11 +595,14 @@ public:
int
skbps_5m
;
// connections
// @see: /proc/net/snmp
// @see: /proc/net/sockstat
int
nb_conn_sys
;
int
nb_conn_sys_et
;
// established
int
nb_conn_sys_tw
;
// time wait
int
nb_conn_sys_ls
;
// listen
int
nb_conn_sys_udp
;
// udp
// retrieve from srs interface
int
nb_conn_srs
;
public
:
...
...
trunk/src/core/srs_core.hpp
查看文件 @
721acc3
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "18
2
"
#define VERSION_REVISION "18
3
"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
...
...
请
注册
或
登录
后发表评论