Skip Menu |

This queue is for tickets about the Sys-Statistics-Linux CPAN distribution.

Report information
The Basics
Id: 63134
Status: resolved
Priority: 0/
Queue: Sys-Statistics-Linux

People
Owner: Nobody in particular
Requestors: gcrumb [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.56
Fixed in: (no value)



Subject: Divide by zero in CpuStats.pm in OpenVZ containers
Running CpuStats on an Ubuntu server running as an OpenVZ container under Proxmox occasionally results in the following error: Illegal division by zero at /usr/local/share/perl/5.10.1/Sys/Statistics/Linux/CpuStats.pm line 209. It seems that the following work-around would at least ignore the error: 202 $dcpu->{$k} -= $icpu->{$k}; 203 $icpu->{$k} = $v; 204 $uptime += $dcpu->{$k}; 205 } 206 +++ $uptime = 1 unless $uptime; +++ 207 foreach my $k (keys %{$dcpu}) { 208 if ($dcpu->{$k} > 0) { 209 $dcpu->{$k} = sprintf('%.2f', 100 * $dcpu->{$k} / $uptime); 210 } elsif ($dcpu->{$k} < 0) { -------------- System details follow: it@milpat:~$ uname -a Linux milpat 2.6.32-4-pve #1 SMP Thu Oct 21 09:35:29 CEST 2010 x86_64 GNU/Linux it@milpat:~$ perl -v This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi Ubuntu 10.04 minimal server install - a contributed download found on the OpenVZ wiki.
Hi, please show me the perl code of your script. Am Do 18. Nov 2010, 22:39:49, gcrumb schrieb: Show quoted text
> Running CpuStats on an Ubuntu server running as an OpenVZ container > under Proxmox occasionally results in the following error: > > Illegal division by zero at > /usr/local/share/perl/5.10.1/Sys/Statistics/Linux/CpuStats.pm line
209. Show quoted text
> > It seems that the following work-around would at least ignore the
error: Show quoted text
> > 202 $dcpu->{$k} -= $icpu->{$k}; > 203 $icpu->{$k} = $v; > 204 $uptime += $dcpu->{$k}; > 205 } > 206 > +++ $uptime = 1 unless $uptime; > +++ > 207 foreach my $k (keys %{$dcpu}) { > 208 if ($dcpu->{$k} > 0) { > 209 $dcpu->{$k} = sprintf('%.2f', 100 * $dcpu->
{$k} Show quoted text
> / $uptime); > 210 } elsif ($dcpu->{$k} < 0) { > > -------------- > System details follow: > > it@milpat:~$ uname -a > Linux milpat 2.6.32-4-pve #1 SMP Thu Oct 21 09:35:29 CEST 2010 x86_64 > GNU/Linux > > it@milpat:~$ perl -v > > This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi > > Ubuntu 10.04 minimal server install - a contributed download found on > the OpenVZ wiki.
Cheers Jonny
AND show me the version you are running, please print $Sys::Statistics::Linux::VERSION
Sorry - don't forget to send me a output of /proc/stat cat /proc/stat :-)
I am waiting for your feedback. Otherwise the ticket will be closed.
no answer, no help :(
Subject: Re: [rt.cpan.org #63134] Divide by zero in CpuStats.pm in OpenVZ containers
Date: Thu, 02 Dec 2010 08:08:21 +1100
To: bug-Sys-Statistics-Linux [...] rt.cpan.org
From: gcrumb <gcrumb [...] gmail.com>
On 12/02/2010 03:44 AM, Jonny Schulz via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=63134 > > > no answer, no help :(
Sorry, I've just been a little busy with other issues. I'll try to get you something useful today. -- Crumb's Corollary: Never bring a knife to a bun fight.
As described in my last email I am not able to help you because you running your linux in a virutal machine. I am sorry :-( See http://search.cpan.org/~bloonix/Sys-Statistics-Linux/lib/Sys/ Statistics/Linux.pm#VIRTUAL_MACHINES