[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[monit-dev] [monit] r367 committed - fix solaris crash if the system is
From: |
monit |
Subject: |
[monit-dev] [monit] r367 committed - fix solaris crash if the system is idle (division by zero) |
Date: |
Wed, 13 Apr 2011 21:11:51 +0000 |
Revision: 367
Author: address@hidden
Date: Wed Apr 13 14:11:18 2011
Log: fix solaris crash if the system is idle (division by zero)
http://code.google.com/p/monit/source/detail?r=367
Modified:
/trunk/CHANGES.txt
/trunk/process/sysdep_SOLARIS.c
=======================================
--- /trunk/CHANGES.txt Wed Apr 6 00:27:58 2011
+++ /trunk/CHANGES.txt Wed Apr 13 14:11:18 2011
@@ -11,6 +11,9 @@
* Fix Debian bug #621047: monit fails to build after SSLv2 removal
+* Fix crash on Solaris which may occur if the system shows zero load.
+ Thanks to Paul Sun for report.
+
Version 5.2.5
=======================================
--- /trunk/process/sysdep_SOLARIS.c Wed Jan 19 10:40:32 2011
+++ /trunk/process/sysdep_SOLARIS.c Wed Apr 13 14:11:18 2011
@@ -368,17 +368,23 @@
total += (cpu_stat[i].cpu_sysinfo.cpu[0]+
cpu_stat[i].cpu_sysinfo.cpu[1]+ cpu_stat[i].cpu_sysinfo.cpu[2]+
cpu_stat[i].cpu_sysinfo.cpu[3]);
}
- if (old_total == 0.0 ) {
+ if (old_total == 0) {
si->total_cpu_user_percent = -10;
si->total_cpu_syst_percent = -10;
si->total_cpu_wait_percent = -10;
} else {
- si->total_cpu_user_percent = (int)((1000 * (cpu_user - old_cpu_user))
/ (total - old_total));
- si->total_cpu_syst_percent = (int)((1000 * (cpu_syst - old_cpu_syst))
/ (total - old_total));
- si->total_cpu_wait_percent = (int)((1000 * (cpu_wait - old_cpu_wait))
/ (total - old_total));
+ long diff_total = total - old_total;
+ if (diff_total) {
+ si->total_cpu_user_percent = (int)((1000 * (cpu_user -
old_cpu_user)) / diff_total);
+ si->total_cpu_syst_percent = (int)((1000 * (cpu_syst -
old_cpu_syst)) / diff_total);
+ si->total_cpu_wait_percent = (int)((1000 * (cpu_wait -
old_cpu_wait)) / diff_total);
+ } else {
+ si->total_cpu_user_percent = 0;
+ si->total_cpu_syst_percent = 0;
+ si->total_cpu_wait_percent = 0;
+ }
}
-
old_cpu_user = cpu_user;
old_cpu_syst = cpu_syst;
old_cpu_wait = cpu_wait;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [monit-dev] [monit] r367 committed - fix solaris crash if the system is idle (division by zero),
monit <=