Thanx for the tip. The following code
my $hash = RRDs::info( $datafile );
my $hStep = $hash->{'step'};
Dump $hStep;
$hStep='301';
Dump $hStep;
PV shows what I want in each case, but the two have different FLAGS. Any of them make any sense to you.
generates:
SV = PVIV(0x8b82158) at 0x832c55c
REFCNT = 1
FLAGS = (PADBUSY,PADMY,IOK,POK,pIOK,pPOK)
IV = 300
PV = 0x8c2ee40 "300"\0
CUR = 3
LEN = 4
SV = PVIV(0x8b82158) at 0x832c55c
REFCNT = 1
FLAGS = (PADBUSY,PADMY,POK,pPOK)
IV = 300
PV = 0x8c2ee40 "301"\0
CUR = 3
LEN = 4
| [reply] |
Neither of those variables that Dump() has displayed would cause the error you see. It would be fine to use either of those 2 with the modulus operator.
Somehow, your program is seeing some other value that equates to (or is) zero. (Are warnings enabled ?)
What's happening between my $step = $hash->{'step'}; and my $mid = $lupdate % $step ; in your code ?
Cheers, Rob
| [reply] [d/l] [select] |
Here is a traceback:
error: Illegal modulus zero at /var/www/distats.html line 187.
context: ...
183:
184: my $hash = RRDs::info( $datafile );
185: my $hStep = $hash->{'step'};
186: my $lupdate = $hash->{'last_update'};
187: my $mid = $lupdate % $hStep;
188: print( "$lupdate % $hStep = $mid\n" );
189: $m->print( " ** lu=$lupdate, step=$hStep ref '" . ref($hStep) . "'\n" );
190: Dump $hStep;
191: $hStep='301';
...
code stack: /var/www/distats.html:187
/usr/share/cricket/lib/ConfigTree/Cache.pm:93
/usr/share/cricket/lib/ConfigTree/Cache.pm:90
/var/www/distats.html:18
/var/www/_content:13
/var/www/autohandler:40
I have elsewhere above my code:
use strict;
use warnings;
One other factoid is that this is using Mason. Which shouldn't get in the way. I also have some Cricket includes as well, which you can see this is the result of a Cricket call back. Well... I guess this is where I strip out all the other code bits and just put this one bit of code in and see what happens.
| [reply] |
The first dump shows that the value of $hStep was set to the string "300" and converted to numeric (or vice versa.) My copy of RRDtool doesn't do that; only IOK is set and not POK. I'm using version 1.2.12 of RRDtool, the current is 1.2.15. You might want to check that you have a reasonably recent version of RRDtool, but as others have pointed out, that certainly isn't a direct cause of your zero modulus error.
| [reply] |