$NetBSD: patch-fc,v 1.1 2010/12/22 08:13:30 sekiya Exp $

--- agent/mibgroup/ucd-snmp/vmstat.c.orig	2010-12-22 15:46:31.000000000 +0900
+++ agent/mibgroup/ucd-snmp/vmstat.c	2010-12-22 15:48:47.000000000 +0900
@@ -129,7 +129,10 @@
         case CPUUSER:
              if ( info->history && info->history[0].total_hist ) {
                  value  = (info->user_ticks  - info->history[0].user_hist)*100;
-                 value /= (info->total_ticks - info->history[0].total_hist);
+                 if (info->total_ticks > info->history[0].total_hist)
+                     value /= (info->total_ticks - info->history[0].total_hist);
+                 else
+                     value = 0;
                  snmp_set_var_typed_integer(requests->requestvb,
                                             ASN_INTEGER, value);
              }
@@ -138,7 +141,10 @@
              if ( info->history && info->history[0].total_hist ) {
                      /* or sys2_ticks ??? */
                  value  = (info->sys_ticks  - info->history[0].sys_hist)*100;
-                 value /= (info->total_ticks - info->history[0].total_hist);
+		 if (info->total_ticks > info->history[0].total_hist)
+               	     value /= (info->total_ticks - info->history[0].total_hist);
+		 else
+		     value = 0;
                  snmp_set_var_typed_integer(requests->requestvb,
                                             ASN_INTEGER, value);
              }
@@ -146,7 +152,10 @@
         case CPUIDLE:
              if ( info->history && info->history[0].total_hist ) {
                  value  = (info->idle_ticks  - info->history[0].idle_hist)*100;
-                 value /= (info->total_ticks - info->history[0].total_hist);
+		 if (info->total_ticks > info->history[0].total_hist)
+               	     value /= (info->total_ticks - info->history[0].total_hist);
+		 else
+		     value = 0;
                  snmp_set_var_typed_integer(requests->requestvb,
                                             ASN_INTEGER, value);
              }
