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-07-27 18:39:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f4ea48adcbd6702ec5e92ed83d1ed94e90e5458e
f4ea48ad
1 parent
b8ae5c63
rename network_device_index to network
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
19 行增加
和
19 行删除
trunk/conf/full.conf
trunk/conf/http.heartbeat.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_heartbeat.cpp
trunk/src/utest/srs_utest_config.cpp
trunk/conf/full.conf
查看文件 @
f4ea48a
...
...
@@ -48,7 +48,7 @@ daemon on;
#############################################################################################
# heartbeat to api server
# @remark, the ip report to server, is retrieve from system stat,
# which need the config item stats.network
_device_index
.
# which need the config item stats.network.
heartbeat
{
# whether heartbeat is enalbed.
# default: off
...
...
@@ -81,13 +81,13 @@ heartbeat {
# the main cycle will retrieve the system stat,
# for example, the cpu/mem/network/disk-io data,
# the http api, for instance, /api/v1/summaries will show these data.
# @remark the heartbeat depends on the network
_device_index
,
# @remark the heartbeat depends on the network,
# for example, the eth0 maybe the device which index is 0.
stats
{
# the index of device ip.
# we may retrieve more than one network device.
# default: 0
network
_device_index
0
;
network
0
;
# the device name to stat the disk iops.
# ignore the device of /proc/diskstats if not configed.
disk_device_name
sda
sdb
xvda
xvdb
;
...
...
trunk/conf/http.heartbeat.conf
查看文件 @
f4ea48a
...
...
@@ -11,7 +11,7 @@ heartbeat {
summaries
on
;
}
stats
{
network
_device_index
0
;
network
0
;
}
vhost
__
defaultVhost__
{
}
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
f4ea48a
...
...
@@ -1249,7 +1249,7 @@ int SrsConfig::check_config()
SrsConfDirective
*
conf
=
get_stats
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"network
_device_index
"
&&
n
!=
"disk_device_name"
)
{
if
(
n
!=
"network"
&&
n
!=
"disk_device_name"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported stats directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -1442,10 +1442,10 @@ int SrsConfig::check_config()
////////////////////////////////////////////////////////////////////////
// check stats
////////////////////////////////////////////////////////////////////////
if
(
get_stats_network
_device_index
()
<
0
)
{
if
(
get_stats_network
()
<
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive stats network_device_index invalid, network_device_index=%d, ret=%d"
,
get_stats_network_device_index
(),
ret
);
srs_error
(
"directive stats network invalid, network=%d, ret=%d"
,
get_stats_network
(),
ret
);
return
ret
;
}
...
...
@@ -3178,7 +3178,7 @@ SrsConfDirective* SrsConfig::get_stats()
return
root
->
get
(
"stats"
);
}
int
SrsConfig
::
get_stats_network
_device_index
()
int
SrsConfig
::
get_stats_network
()
{
SrsConfDirective
*
conf
=
get_stats
();
...
...
@@ -3186,7 +3186,7 @@ int SrsConfig::get_stats_network_device_index()
return
SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX
;
}
conf
=
conf
->
get
(
"network
_device_index
"
);
conf
=
conf
->
get
(
"network"
);
if
(
!
conf
||
conf
->
arg0
().
empty
())
{
return
SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX
;
}
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
f4ea48a
...
...
@@ -942,7 +942,7 @@ public:
* for heartbeat to report to server, or to get the local ip.
* for example, 0 means the eth0 maybe.
*/
virtual
int
get_stats_network
_device_index
();
virtual
int
get_stats_network
();
/**
* get the disk stat device name list.
* the device name configed in args of directive.
...
...
trunk/src/app/srs_app_heartbeat.cpp
查看文件 @
f4ea48a
...
...
@@ -61,7 +61,7 @@ void SrsHttpHeartbeat::heartbeat()
vector
<
string
>&
ips
=
srs_get_local_ipv4_ips
();
if
(
!
ips
.
empty
())
{
ip
=
ips
[
_srs_config
->
get_stats_network
_device_index
()
%
(
int
)
ips
.
size
()];
ip
=
ips
[
_srs_config
->
get_stats_network
()
%
(
int
)
ips
.
size
()];
}
std
::
stringstream
ss
;
...
...
trunk/src/utest/srs_utest_config.cpp
查看文件 @
f4ea48a
...
...
@@ -149,13 +149,13 @@ std::string __full_conf = ""
"# the main cycle will retrieve the system stat,
\n
"
"# for example, the cpu/mem/network/disk-io data,
\n
"
"# the http api, for instance, /api/v1/summaries will show these data.
\n
"
"# @remark the heartbeat depends on the network
_device_index
,
\n
"
"# @remark the heartbeat depends on the network,
\n
"
"# for example, the eth0 maybe the device which index is 0.
\n
"
"stats {
\n
"
" # the index of device ip.
\n
"
" # we may retrieve more than one network device.
\n
"
" # default: 0
\n
"
" network
_device_index
0;
\n
"
" network 0;
\n
"
" # the device name to stat the disk iops.
\n
"
" # ignore the device of /proc/diskstats if not configed.
\n
"
" disk_device_name sda sdb xvda xvdb;
\n
"
...
...
@@ -1844,7 +1844,7 @@ VOID TEST(ConfigMainTest, ParseFullConf)
EXPECT_STREQ
(
"my-srs-device"
,
conf
.
get_heartbeat_device_id
().
c_str
());
EXPECT_FALSE
(
conf
.
get_heartbeat_summaries
());
EXPECT_EQ
(
0
,
conf
.
get_stats_network
_device_index
());
EXPECT_EQ
(
0
,
conf
.
get_stats_network
());
ASSERT_TRUE
(
conf
.
get_stats_disk_device
()
!=
NULL
);
EXPECT_EQ
(
4
,
(
int
)
conf
.
get_stats_disk_device
()
->
args
.
size
());
...
...
@@ -4622,22 +4622,22 @@ VOID TEST(ConfigMainTest, CheckConf_stats)
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"stats{network
_device_index
0;}"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"stats{network 0;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"stats{network
_device_index
s 0;}"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"stats{networks 0;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"stats{network
_device_index
-100;}"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"stats{network -100;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"stats{network
_device_index
-1;}"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"stats{network -1;}"
));
}
if
(
true
)
{
...
...
请
注册
或
登录
后发表评论