diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 45698d429..1e8121584 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -285,7 +285,7 @@ int SrsStreamCache::cycle() if (pprint->can_print()) { srs_trace("-> "SRS_CONSTS_LOG_HTTP_STREAM_CACHE" http: got %d msgs, age=%d, min=%d, mw=%d", - pprint->age(), count, SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); + count, pprint->age(), SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); } // free the messages. @@ -644,7 +644,7 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) if (pprint->can_print()) { srs_info("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d", - pprint->age(), count, SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); + count, pprint->age(), SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); } // sendout all messages. diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index acc193d3f..a779a2cc7 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -849,10 +849,12 @@ int SrsServer::do_cycle() srs_info("update memory info, usage/free."); srs_update_meminfo(); } +#endif if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) { srs_info("update platform info, uptime/load."); srs_update_platform_info(); } +#ifndef SRS_OSX if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) { srs_info("update network devices info."); srs_update_network_devices(); diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp index 66c4525fa..033437be4 100644 --- a/trunk/src/app/srs_app_utility.cpp +++ b/trunk/src/app/srs_app_utility.cpp @@ -28,6 +28,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#ifdef SRS_OSX +#include +#endif using namespace std; #include @@ -666,6 +669,7 @@ void srs_update_platform_info() r.srs_startup_time = srs_get_system_startup_time_ms(); +#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/uptime", "r"); if (f == NULL) { @@ -694,6 +698,43 @@ void srs_update_platform_info() fclose(f); } +#else + // man 3 sysctl + if (true) { + struct timeval tv; + size_t len = sizeof(timeval); + + int mib[2]; + mib[0] = CTL_KERN; + mib[1] = KERN_BOOTTIME; + if (sysctl(mib, 2, &tv, &len, NULL, 0) < 0) { + srs_warn("sysctl boottime failed, ignore"); + return; + } + + time_t bsec = tv.tv_sec; + time_t csec = ::time(NULL); + r.os_uptime = difftime(csec, bsec); + } + + // man 3 sysctl + if (true) { + struct loadavg la; + size_t len = sizeof(loadavg); + + int mib[2]; + mib[0] = CTL_VM; + mib[1] = VM_LOADAVG; + if (sysctl(mib, 2, &la, &len, NULL, 0) < 0) { + srs_warn("sysctl loadavg failed, ignore"); + return; + } + + r.load_one_minutes = (double)la.ldavg[0] / la.fscale; + r.load_five_minutes = (double)la.ldavg[1] / la.fscale; + r.load_fifteen_minutes = (double)la.ldavg[2] / la.fscale; + } +#endif r.ok = true; }