mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
refine the disk iops stat, get cpu info.
This commit is contained in:
parent
ef7a02e643
commit
4f4b15f500
3 changed files with 9 additions and 7 deletions
|
@ -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:
|
||||
|
|
|
@ -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%
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue