merge from 2.0

pull/499/head
winlin 10 years ago
commit b7138ba9c5

@ -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.

@ -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();

@ -28,6 +28,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <ifaddrs.h>
#include <arpa/inet.h>
#ifdef SRS_OSX
#include <sys/sysctl.h>
#endif
using namespace std;
#include <srs_kernel_log.hpp>
@ -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;
}

Loading…
Cancel
Save