Welcome, Guest. Please login or register.

Author Topic: Workaround for: "Illegal division by zero at ./inc/libdb-msq.pm line 739."  (Read 2760 times)

SteffenS

  • Guest
Hello,

if you discover a device that not response values for interfaces (whyever), the discovery breaks with
"Illegal division by zero at ./inc/libdb-msq.pm line 739."

So I have changes line 739 in libdb-msq.pm from
Code: [Select]
my $avgpoe = sprintf("%.0f",$totpoe/$nethif);
to
Code: [Select]
if($nethif gt 0){my $avgpoe = sprintf("%.0f",$totpoe/$nethif);}else {my $avgpoe = sprintf("%.0f",$totpoe);}
to prevent the famous divison-by-zero-problem.

(Note: Version is nedi-096)

Greetings

Steffen

addendum:
After this change, discovery don't break now, but following message appears:
"Use of uninitialized value $db::avgpoe in numeric gt (>) at /opt/nedi//inc/libdb-msq.pm line 740."
Do anyone knows how to solve this?
« Last Edit: April 20, 2011, 10:49:13 AM by SteffenS »

tristanbob

  • Full Member
  • ***
  • Posts: 152
    • View Profile
SteffenS,

I was just about to report this exact error, but I saw your post.  For me, this was a Cisco ACE10 module in a 6500.

Code: [Select]
DevRRD       ------------------------------------------------------------------
DRRD:Updated ./rrd/DC-ACE/system.rrd
DRRD:Updated ./rrd/DC-ACE/vlan210.rrd
DRRD:Updated ./rrd/DC-ACE/bvi2.rrd
DRRD:Updated ./rrd/DC-ACE/vlan203.rrd
DRRD:Updated ./rrd/DC-ACE/vlan10.rrd
DRRD:Updated ./rrd/DC-ACE/vlan400.rrd
DRRD:Updated ./rrd/DC-ACE/bvi3.rrd
DRRD:Updated ./rrd/DC-ACE/vlan500.rrd
DRRD:Updated ./rrd/DC-ACE/vlan208.rrd
DRRD:Updated ./rrd/DC-ACE/bvi4.rrd
DRRD:Updated ./rrd/DC-ACE/vlan202.rrd
DRRD:Updated ./rrd/DC-ACE/vlan3.rrd
DRRD:Updated ./rrd/DC-ACE/bvi1.rrd
DRRD:Updated ./rrd/DC-ACE/vlan2.rrd
WDEV:DC-ACE written to nedinew.devices
Illegal division by zero at ./inc/libdb-msq.pm line 739.
tristanrhodes@nedi:/opt/nedi-new$

I didn't try your code, but perhaps you should just set the value to "0" if the bottom value is "0".   Something like this:

Code: [Select]
if($nethif gt 0){my $avgpoe = sprintf("%.0f",$totpoe/$nethif);}else {my $avgpoe = sprintf("%.0f",0);}
« Last Edit: April 20, 2011, 06:11:01 PM by tristanbob »
Please visit "Other"->"Invoices" on your NeDi installation to make an annual contribution and support Nedi!

jsnmngwn

  • Guest
"Use of uninitialized value $db::avgpoe in numeric gt (>) at /opt/nedi//inc/libdb-msq.pm line 740."

I got rid of this by changing the lines to:
Code:
Code: [Select]
    my $avgpoe;
    if($nethif gt 0){$avgpoe = sprintf("%.0f",$totpoe/$nethif);}else {$avgpoe = sprintf("%.0f",0);}