j-schulz / p5-Sys-Statistics-Linux

Front-end module to collect system statistics
Other
1 stars 0 forks source link

Illegal division by zero at .../lib/perl5/Sys/Statistics/Linux/CpuStats.pm line 236. #4

Open wangvisual opened 8 years ago

wangvisual commented 8 years ago

Using of this module randomly cause error about divided by zero, after check seems it is caused by a kernel bug that sometimes idle & iowait ticks overflow ref: https://bugzilla.redhat.com/show_bug.cgi?id=805392 http://www.gossamer-threads.com/lists/linux/kernel/1701730

If my test run, $istat has value: 'cpu1' => { 'idle' => '82224491', 'iowait' => '757276', 'irq' => '0', 'nice' => '3', 'softirq' => '13579', 'steal' => '0', 'system' => '1803885', 'user' => '14423126' }, $lstat has value: 'cpu1' => { 'idle' => '82224573', 'iowait' => '757272', 'irq' => '0', 'nice' => '3', 'softirq' => '13579', 'steal' => '0', 'system' => '1803888', 'user' => '14423145' }, we can see iowait decreased from 757276 to 757272.

uname -a Linux hostname 2.6.32-504.16.2.el6.x86_64 #1 SMP Tue Mar 10 17:01:00 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

cat /proc/stat cpu 231005401 328 24305567 1724313362 9131606 16 606249 0 0 cpu0 18114574 11 1942362 78100614 1238727 0 30579 0 0 cpu1 14440744 3 1804650 82403006 757440 0 13579 0 0 cpu2 11867634 10 1394803 85523241 678391 0 5842 0 0 cpu3 9642813 11 1145929 88044339 544402 6 68795 0 0 cpu4 11469571 26 1633960 85610025 626996 3 89894 0 0 cpu5 21012158 4 1347634 76303172 752765 0 30365 0 0 cpu6 19576599 52 1729580 77706340 426357 0 12753 0 0 cpu7 15255703 3 1350905 82475907 382522 0 6376 0 0 cpu8 10148595 75 1272317 87684415 368407 0 4802 0 0 cpu9 9289880 0 936363 88957025 295387 0 3798 0 0 cpu10 7674422 16 871001 90608208 331472 0 1723 0 0 cpu11 11378156 46 1558065 85820739 599386 2 106762 0 0 cpu12 12152163 46 1942788 84704727 536214 1 123651 0 0 cpu13 11855095 12 1540351 85321984 649367 2 96438 0 0 cpu14 8074072 0 693820 90562754 176492 0 974 0 0 cpu15 8066181 0 788793 90414550 220102 0 2605 0 0 cpu16 7988000 0 675314 90642082 181822 0 2150 0 0 cpu17 7167552 0 588073 91591393 140289 0 1979 0 0 cpu18 7116288 0 546016 91710411 120397 0 1539 0 0 cpu19 8715193 4 542832 90128419 104660 0 1635 0 0 intr 4740961403 199 3 0 2 2 0 0 0 176 0 0 0 4 0 0 0 0 0 56 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3317 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4637178 1515638 1099513 794107 520075 4033430 821098 856523 171762808 124655939 117056690 130010513 96343601 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ctxt 6342416189 btime 1459644406 processes 61351975 procs_running 2 procs_blocked 0 softirq 8280119341 0 3016200541 276674 1546243333 14688302 0 4361233 216319158 563942 3481466158

package Sys::Statistics::Linux; our $VERSION = '0.66';

wangvisual commented 8 years ago

Another reference for later /proc/stat format, not related to this bug but maybe helpful:

http://stackoverflow.com/questions/23367857/accurate-calculation-of-cpu-usage-given-in-percentage-in-linux