<?xml version="1.0" encoding="windows-1252"?>
<node id="656931" title="Re: Measuring MySQL resources consumption on Linux" created="2007-12-13 17:27:20" updated="2007-12-13 12:27:20">
<type id="11">
note</type>
<author id="585085">
kyle</author>
<data>
<field name="doctext">
&lt;blockquote&gt;
&lt;c&gt;
#
# calculate the average, avoiding any division by zero traps
#
my $avg_cpu_load = $total_cpu_load ? $total_cpu_load / $active_pid_num : 0 ;
&lt;/c&gt;
&lt;/blockquote&gt;
&lt;p&gt;I'd think if you want to avoid division by zero, you'd need to check the denominator for zero-ness rather than the numerator.  That is:
&lt;c&gt;
my $avg_cpu_load = $active_pid_num ? $total_cpu_load / $active_pid_num : 0;
&lt;/c&gt;
&lt;p&gt;Or am I misunderstanding something here?</field>
<field name="root_node">
559540</field>
<field name="parent_node">
559540</field>
</data>
</node>
