Negative numbers and Script/Command Data Input Method

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
dstdst
Posts: 2
Joined: Tue Nov 23, 2004 1:37 pm

Negative numbers and Script/Command Data Input Method

Post by dstdst »

I am using cacti version 0.8.6b

I am using the Script/Command Data Input Method to get values from a weather station. Since winter started kicking in I had negative values for temperature values which were considered bad data.

Browsing through the code and in line 215 of lib/poller.php I substituted the line:

if (preg_match("/^([a-zA-Z0-9_-]+):(\d+(\.\d+)?)$/", $values[$i], $matches)) {

and added the sign symbol as:

if (preg_match("/^([a-zA-Z0-9_-]+):[-+]?(\d+(\.\d+)?)$/", $values[$i], $matches)) {

so now from the debug I can see that partly is working ok but I was unable to find how the value is tranfered to rrd

my debuging says:

CMDPHP: Poller[0] Host[2] CMD: sh /var/virtual/cacti_vernet_gr/html/scripts/parsehwini.sh, output: intemp:9.2 outtemp:-7.6 inhum:45 outhum:58
POLLER: Poller[0] Parsed MULTI output field 'outtemp:-7.6' [map outtemp->outtemp]
POLLER: Poller[0] CACTI2RRD: /usr/local/rrdtool-1.0.49/bin/rrdtool update /var/virtual/cacti_vernet_gr/html/rra/weatherrahia.rrd --template intemp:outtemp:inhum:outhum 1101234901:9.2:7.6:45:58

The negative sign somewhere on the way is lost and a posite values is tranfered to rrd.

Any clues?

Dimitris
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

There is a patch for this problem. It is located in the following folder:

http://www.cacti.net/downloads/patches/ ... re-patched

If forget what the file it, but it fixes this problem.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
dstdst
Posts: 2
Joined: Tue Nov 23, 2004 1:37 pm

Post by dstdst »

it seems I got it...

In line 215 of lib/poller.php I substituted the line:

if (preg_match("/^([a-zA-Z0-9_-]+):(\d+(\.\d+)?)$/", $values[$i], $matches)) {

and added the sign symbol this time inside the parantheses as:

if (preg_match("/^([a-zA-Z0-9_-]+):([-+]?\d+(\.\d+)?)$/", $values[$i], $matches)) {

and that did it for me...

Dimitris
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

That fix does not include scientific notation. The patch that will be released soon will incorporate that notation as well. Nice work on the regular expression match though.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests