diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 4b5c072bc..590cd6461 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -74,9 +74,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // update the disk iops interval: // SRS_SYS_CYCLE_INTERVAL * SRS_SYS_DISK_STAT_RESOLUTION_TIMES -// @remark, depends on SRS_SYS_CPU_STAT_RESOLUTION_TIMES, for the disk util -// depends on cpu time, so the disk stat times must be times of cpu stat time. -// for example, when cpu is 30, disk must be 30*1 or 30*2 ..., 30*N is ok. #define SRS_SYS_DISK_STAT_RESOLUTION_TIMES 60 // update rusage interval: diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp index e8e60ec55..67392f7f3 100644 --- a/trunk/src/app/srs_app_utility.cpp +++ b/trunk/src/app/srs_app_utility.cpp @@ -490,6 +490,9 @@ void srs_update_disk_stat() if (!srs_get_disk_diskstats_stat(r)) { return; } + if (!get_proc_system_stat(r.cpu)) { + return; + } SrsDiskStat& o = _srs_disk_stat; if (!o.ok) { @@ -513,16 +516,16 @@ void srs_update_disk_stat() } // diskstats - if (true) { - SrsProcSystemStat* cpu = srs_get_system_proc_stat(); + if (r.cpu.ok && o.cpu.ok) { SrsCpuInfo* cpuinfo = srs_get_cpuinfo(); + r.cpu.total_delta = r.cpu.total() - o.cpu.total(); - if (cpu->ok && cpu->total_delta > 0 + if (r.cpu.ok && r.cpu.total_delta > 0 && cpuinfo->ok && cpuinfo->nb_processors > 0 && o.ticks < r.ticks ) { // @see: print_partition_stats() of iostat.c - double delta_ms = cpu->total_delta * 10 / cpuinfo->nb_processors; + double delta_ms = r.cpu.total_delta * 10 / cpuinfo->nb_processors; unsigned int ticks = r.ticks - o.ticks; // busy in [0, 1], where 0.1532 means 15.32% diff --git a/trunk/src/app/srs_app_utility.hpp b/trunk/src/app/srs_app_utility.hpp index 5384c8e04..a8d6b6af9 100644 --- a/trunk/src/app/srs_app_utility.hpp +++ b/trunk/src/app/srs_app_utility.hpp @@ -341,6 +341,8 @@ public: // @see: print_partition_stats() of iostat.c // but its value is [0, +], for instance, 0.1532 means 15.32%. float busy; + // for stat the busy% + SrsProcSystemStat cpu; public: // @see: cat /proc/vmstat