正在显示
3 个修改的文件
包含
45 行增加
和
2 行删除
| @@ -285,7 +285,7 @@ int SrsStreamCache::cycle() | @@ -285,7 +285,7 @@ int SrsStreamCache::cycle() | ||
| 285 | 285 | ||
| 286 | if (pprint->can_print()) { | 286 | if (pprint->can_print()) { |
| 287 | srs_trace("-> "SRS_CONSTS_LOG_HTTP_STREAM_CACHE" http: got %d msgs, age=%d, min=%d, mw=%d", | 287 | srs_trace("-> "SRS_CONSTS_LOG_HTTP_STREAM_CACHE" http: got %d msgs, age=%d, min=%d, mw=%d", |
| 288 | - pprint->age(), count, SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); | 288 | + count, pprint->age(), SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | // free the messages. | 291 | // free the messages. |
| @@ -644,7 +644,7 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -644,7 +644,7 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 644 | 644 | ||
| 645 | if (pprint->can_print()) { | 645 | if (pprint->can_print()) { |
| 646 | srs_info("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d", | 646 | srs_info("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d", |
| 647 | - pprint->age(), count, SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); | 647 | + count, pprint->age(), SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); |
| 648 | } | 648 | } |
| 649 | 649 | ||
| 650 | // sendout all messages. | 650 | // sendout all messages. |
| @@ -849,10 +849,12 @@ int SrsServer::do_cycle() | @@ -849,10 +849,12 @@ int SrsServer::do_cycle() | ||
| 849 | srs_info("update memory info, usage/free."); | 849 | srs_info("update memory info, usage/free."); |
| 850 | srs_update_meminfo(); | 850 | srs_update_meminfo(); |
| 851 | } | 851 | } |
| 852 | +#endif | ||
| 852 | if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) { | 853 | if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) { |
| 853 | srs_info("update platform info, uptime/load."); | 854 | srs_info("update platform info, uptime/load."); |
| 854 | srs_update_platform_info(); | 855 | srs_update_platform_info(); |
| 855 | } | 856 | } |
| 857 | +#ifndef SRS_OSX | ||
| 856 | if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) { | 858 | if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) { |
| 857 | srs_info("update network devices info."); | 859 | srs_info("update network devices info."); |
| 858 | srs_update_network_devices(); | 860 | srs_update_network_devices(); |
| @@ -28,6 +28,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -28,6 +28,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 28 | #include <ifaddrs.h> | 28 | #include <ifaddrs.h> |
| 29 | #include <arpa/inet.h> | 29 | #include <arpa/inet.h> |
| 30 | 30 | ||
| 31 | +#ifdef SRS_OSX | ||
| 32 | +#include <sys/sysctl.h> | ||
| 33 | +#endif | ||
| 31 | using namespace std; | 34 | using namespace std; |
| 32 | 35 | ||
| 33 | #include <srs_kernel_log.hpp> | 36 | #include <srs_kernel_log.hpp> |
| @@ -666,6 +669,7 @@ void srs_update_platform_info() | @@ -666,6 +669,7 @@ void srs_update_platform_info() | ||
| 666 | 669 | ||
| 667 | r.srs_startup_time = srs_get_system_startup_time_ms(); | 670 | r.srs_startup_time = srs_get_system_startup_time_ms(); |
| 668 | 671 | ||
| 672 | +#ifndef SRS_OSX | ||
| 669 | if (true) { | 673 | if (true) { |
| 670 | FILE* f = fopen("/proc/uptime", "r"); | 674 | FILE* f = fopen("/proc/uptime", "r"); |
| 671 | if (f == NULL) { | 675 | if (f == NULL) { |
| @@ -694,6 +698,43 @@ void srs_update_platform_info() | @@ -694,6 +698,43 @@ void srs_update_platform_info() | ||
| 694 | 698 | ||
| 695 | fclose(f); | 699 | fclose(f); |
| 696 | } | 700 | } |
| 701 | +#else | ||
| 702 | + // man 3 sysctl | ||
| 703 | + if (true) { | ||
| 704 | + struct timeval tv; | ||
| 705 | + size_t len = sizeof(timeval); | ||
| 706 | + | ||
| 707 | + int mib[2]; | ||
| 708 | + mib[0] = CTL_KERN; | ||
| 709 | + mib[1] = KERN_BOOTTIME; | ||
| 710 | + if (sysctl(mib, 2, &tv, &len, NULL, 0) < 0) { | ||
| 711 | + srs_warn("sysctl boottime failed, ignore"); | ||
| 712 | + return; | ||
| 713 | + } | ||
| 714 | + | ||
| 715 | + time_t bsec = tv.tv_sec; | ||
| 716 | + time_t csec = ::time(NULL); | ||
| 717 | + r.os_uptime = difftime(csec, bsec); | ||
| 718 | + } | ||
| 719 | + | ||
| 720 | + // man 3 sysctl | ||
| 721 | + if (true) { | ||
| 722 | + struct loadavg la; | ||
| 723 | + size_t len = sizeof(loadavg); | ||
| 724 | + | ||
| 725 | + int mib[2]; | ||
| 726 | + mib[0] = CTL_VM; | ||
| 727 | + mib[1] = VM_LOADAVG; | ||
| 728 | + if (sysctl(mib, 2, &la, &len, NULL, 0) < 0) { | ||
| 729 | + srs_warn("sysctl loadavg failed, ignore"); | ||
| 730 | + return; | ||
| 731 | + } | ||
| 732 | + | ||
| 733 | + r.load_one_minutes = (double)la.ldavg[0] / la.fscale; | ||
| 734 | + r.load_five_minutes = (double)la.ldavg[1] / la.fscale; | ||
| 735 | + r.load_fifteen_minutes = (double)la.ldavg[2] / la.fscale; | ||
| 736 | + } | ||
| 737 | +#endif | ||
| 697 | 738 | ||
| 698 | r.ok = true; | 739 | r.ok = true; |
| 699 | } | 740 | } |
-
请 注册 或 登录 后发表评论