winlin

rename network_device_index to network

@@ -48,7 +48,7 @@ daemon on; @@ -48,7 +48,7 @@ daemon on;
48 ############################################################################################# 48 #############################################################################################
49 # heartbeat to api server 49 # heartbeat to api server
50 # @remark, the ip report to server, is retrieve from system stat, 50 # @remark, the ip report to server, is retrieve from system stat,
51 -# which need the config item stats.network_device_index. 51 +# which need the config item stats.network.
52 heartbeat { 52 heartbeat {
53 # whether heartbeat is enalbed. 53 # whether heartbeat is enalbed.
54 # default: off 54 # default: off
@@ -81,13 +81,13 @@ heartbeat { @@ -81,13 +81,13 @@ heartbeat {
81 # the main cycle will retrieve the system stat, 81 # the main cycle will retrieve the system stat,
82 # for example, the cpu/mem/network/disk-io data, 82 # for example, the cpu/mem/network/disk-io data,
83 # the http api, for instance, /api/v1/summaries will show these data. 83 # the http api, for instance, /api/v1/summaries will show these data.
84 -# @remark the heartbeat depends on the network_device_index, 84 +# @remark the heartbeat depends on the network,
85 # for example, the eth0 maybe the device which index is 0. 85 # for example, the eth0 maybe the device which index is 0.
86 stats { 86 stats {
87 # the index of device ip. 87 # the index of device ip.
88 # we may retrieve more than one network device. 88 # we may retrieve more than one network device.
89 # default: 0 89 # default: 0
90 - network_device_index 0; 90 + network 0;
91 # the device name to stat the disk iops. 91 # the device name to stat the disk iops.
92 # ignore the device of /proc/diskstats if not configed. 92 # ignore the device of /proc/diskstats if not configed.
93 disk_device_name sda sdb xvda xvdb; 93 disk_device_name sda sdb xvda xvdb;
@@ -11,7 +11,7 @@ heartbeat { @@ -11,7 +11,7 @@ heartbeat {
11 summaries on; 11 summaries on;
12 } 12 }
13 stats { 13 stats {
14 - network_device_index 0; 14 + network 0;
15 } 15 }
16 vhost __defaultVhost__ { 16 vhost __defaultVhost__ {
17 } 17 }
@@ -1249,7 +1249,7 @@ int SrsConfig::check_config() @@ -1249,7 +1249,7 @@ int SrsConfig::check_config()
1249 SrsConfDirective* conf = get_stats(); 1249 SrsConfDirective* conf = get_stats();
1250 for (int i = 0; conf && i < (int)conf->directives.size(); i++) { 1250 for (int i = 0; conf && i < (int)conf->directives.size(); i++) {
1251 string n = conf->at(i)->name; 1251 string n = conf->at(i)->name;
1252 - if (n != "network_device_index" && n != "disk_device_name") { 1252 + if (n != "network" && n != "disk_device_name") {
1253 ret = ERROR_SYSTEM_CONFIG_INVALID; 1253 ret = ERROR_SYSTEM_CONFIG_INVALID;
1254 srs_error("unsupported stats directive %s, ret=%d", n.c_str(), ret); 1254 srs_error("unsupported stats directive %s, ret=%d", n.c_str(), ret);
1255 return ret; 1255 return ret;
@@ -1442,10 +1442,10 @@ int SrsConfig::check_config() @@ -1442,10 +1442,10 @@ int SrsConfig::check_config()
1442 //////////////////////////////////////////////////////////////////////// 1442 ////////////////////////////////////////////////////////////////////////
1443 // check stats 1443 // check stats
1444 //////////////////////////////////////////////////////////////////////// 1444 ////////////////////////////////////////////////////////////////////////
1445 - if (get_stats_network_device_index() < 0) { 1445 + if (get_stats_network() < 0) {
1446 ret = ERROR_SYSTEM_CONFIG_INVALID; 1446 ret = ERROR_SYSTEM_CONFIG_INVALID;
1447 - srs_error("directive stats network_device_index invalid, network_device_index=%d, ret=%d",  
1448 - get_stats_network_device_index(), ret); 1447 + srs_error("directive stats network invalid, network=%d, ret=%d",
  1448 + get_stats_network(), ret);
1449 return ret; 1449 return ret;
1450 } 1450 }
1451 1451
@@ -3178,7 +3178,7 @@ SrsConfDirective* SrsConfig::get_stats() @@ -3178,7 +3178,7 @@ SrsConfDirective* SrsConfig::get_stats()
3178 return root->get("stats"); 3178 return root->get("stats");
3179 } 3179 }
3180 3180
3181 -int SrsConfig::get_stats_network_device_index() 3181 +int SrsConfig::get_stats_network()
3182 { 3182 {
3183 SrsConfDirective* conf = get_stats(); 3183 SrsConfDirective* conf = get_stats();
3184 3184
@@ -3186,7 +3186,7 @@ int SrsConfig::get_stats_network_device_index() @@ -3186,7 +3186,7 @@ int SrsConfig::get_stats_network_device_index()
3186 return SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX; 3186 return SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX;
3187 } 3187 }
3188 3188
3189 - conf = conf->get("network_device_index"); 3189 + conf = conf->get("network");
3190 if (!conf || conf->arg0().empty()) { 3190 if (!conf || conf->arg0().empty()) {
3191 return SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX; 3191 return SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX;
3192 } 3192 }
@@ -942,7 +942,7 @@ public: @@ -942,7 +942,7 @@ public:
942 * for heartbeat to report to server, or to get the local ip. 942 * for heartbeat to report to server, or to get the local ip.
943 * for example, 0 means the eth0 maybe. 943 * for example, 0 means the eth0 maybe.
944 */ 944 */
945 - virtual int get_stats_network_device_index(); 945 + virtual int get_stats_network();
946 /** 946 /**
947 * get the disk stat device name list. 947 * get the disk stat device name list.
948 * the device name configed in args of directive. 948 * the device name configed in args of directive.
@@ -61,7 +61,7 @@ void SrsHttpHeartbeat::heartbeat() @@ -61,7 +61,7 @@ void SrsHttpHeartbeat::heartbeat()
61 61
62 vector<string>& ips = srs_get_local_ipv4_ips(); 62 vector<string>& ips = srs_get_local_ipv4_ips();
63 if (!ips.empty()) { 63 if (!ips.empty()) {
64 - ip = ips[_srs_config->get_stats_network_device_index() % (int)ips.size()]; 64 + ip = ips[_srs_config->get_stats_network() % (int)ips.size()];
65 } 65 }
66 66
67 std::stringstream ss; 67 std::stringstream ss;
@@ -149,13 +149,13 @@ std::string __full_conf = "" @@ -149,13 +149,13 @@ std::string __full_conf = ""
149 "# the main cycle will retrieve the system stat, \n" 149 "# the main cycle will retrieve the system stat, \n"
150 "# for example, the cpu/mem/network/disk-io data, \n" 150 "# for example, the cpu/mem/network/disk-io data, \n"
151 "# the http api, for instance, /api/v1/summaries will show these data. \n" 151 "# the http api, for instance, /api/v1/summaries will show these data. \n"
152 - "# @remark the heartbeat depends on the network_device_index, \n" 152 + "# @remark the heartbeat depends on the network, \n"
153 "# for example, the eth0 maybe the device which index is 0. \n" 153 "# for example, the eth0 maybe the device which index is 0. \n"
154 "stats { \n" 154 "stats { \n"
155 " # the index of device ip. \n" 155 " # the index of device ip. \n"
156 " # we may retrieve more than one network device. \n" 156 " # we may retrieve more than one network device. \n"
157 " # default: 0 \n" 157 " # default: 0 \n"
158 - " network_device_index 0; \n" 158 + " network 0; \n"
159 " # the device name to stat the disk iops. \n" 159 " # the device name to stat the disk iops. \n"
160 " # ignore the device of /proc/diskstats if not configed. \n" 160 " # ignore the device of /proc/diskstats if not configed. \n"
161 " disk_device_name sda sdb xvda xvdb; \n" 161 " disk_device_name sda sdb xvda xvdb; \n"
@@ -1844,7 +1844,7 @@ VOID TEST(ConfigMainTest, ParseFullConf) @@ -1844,7 +1844,7 @@ VOID TEST(ConfigMainTest, ParseFullConf)
1844 EXPECT_STREQ("my-srs-device", conf.get_heartbeat_device_id().c_str()); 1844 EXPECT_STREQ("my-srs-device", conf.get_heartbeat_device_id().c_str());
1845 EXPECT_FALSE(conf.get_heartbeat_summaries()); 1845 EXPECT_FALSE(conf.get_heartbeat_summaries());
1846 1846
1847 - EXPECT_EQ(0, conf.get_stats_network_device_index()); 1847 + EXPECT_EQ(0, conf.get_stats_network());
1848 ASSERT_TRUE(conf.get_stats_disk_device() != NULL); 1848 ASSERT_TRUE(conf.get_stats_disk_device() != NULL);
1849 EXPECT_EQ(4, (int)conf.get_stats_disk_device()->args.size()); 1849 EXPECT_EQ(4, (int)conf.get_stats_disk_device()->args.size());
1850 1850
@@ -4622,22 +4622,22 @@ VOID TEST(ConfigMainTest, CheckConf_stats) @@ -4622,22 +4622,22 @@ VOID TEST(ConfigMainTest, CheckConf_stats)
4622 4622
4623 if (true) { 4623 if (true) {
4624 MockSrsConfig conf; 4624 MockSrsConfig conf;
4625 - EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"stats{network_device_index 0;}")); 4625 + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"stats{network 0;}"));
4626 } 4626 }
4627 4627
4628 if (true) { 4628 if (true) {
4629 MockSrsConfig conf; 4629 MockSrsConfig conf;
4630 - EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"stats{network_device_indexs 0;}")); 4630 + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"stats{networks 0;}"));
4631 } 4631 }
4632 4632
4633 if (true) { 4633 if (true) {
4634 MockSrsConfig conf; 4634 MockSrsConfig conf;
4635 - EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"stats{network_device_index -100;}")); 4635 + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"stats{network -100;}"));
4636 } 4636 }
4637 4637
4638 if (true) { 4638 if (true) {
4639 MockSrsConfig conf; 4639 MockSrsConfig conf;
4640 - EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"stats{network_device_index -1;}")); 4640 + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"stats{network -1;}"));
4641 } 4641 }
4642 4642
4643 if (true) { 4643 if (true) {