Cacti returns output in wrong format

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
varh1i
Posts: 1
Joined: Thu Dec 17, 2015 10:24 am

Cacti returns output in wrong format

Post by varh1i »

I have a cacti 'Data input method' script/command (python script) that ssh's into a server and get's some stat with a bash script running on the remote server. Some values are decimal some are integer. Example output of bash script:

Loaded:4525 LoadedBytes:8057.0 Unloaded:14 UnloadedBytes:18.3 ClassTime:1.67
but they are not inserted to cacti correctly:

12/17/2015 02:10:02 PM - POLLER: Poller[0] Parsed MULTI output field 'Loaded:4525' [map Loaded->Loaded]
12/17/2015 02:10:02 PM - POLLER: Poller[0] Parsed MULTI output field 'LoadedBytes:8057,3' [map LoadedBytes->LoadedBytes]
12/17/2015 02:10:02 PM - POLLER: Poller[0] Parsed MULTI output field 'Unloaded:14' [map Unloaded->Unloaded]
12/17/2015 02:10:02 PM - POLLER: Poller[0] Parsed MULTI output field 'UnloadedBytes:18,3' [map UnloadedBytes->UnloadedBytes]
12/17/2015 02:10:02 PM - POLLER: Poller[0] Parsed MULTI output field 'ClassTime:1,67' [map ClassTime->ClassTime]
12/17/2015 02:10:02 PM - POLLER: Poller[0] CACTI2RRD: /usr/bin/rrdtool update /var/lib/cacti/rra/backend_classtime_9.rrd --template Loaded:LoadedBytes:Unloaded:UnloadedBytes:ClassTime 1450361401:4525:U:14:U:U
so I iterate over and append ".0" to the values:

IFS=' ' read -r -a result_array <<< "$RESULT"
for element in "${result_array[@]}"
do
IFS=':' read -r -a value <<< "$element"
if [[ ${value[1]} != *"."* ]]
then
value[1]="${value[1]}.0"
fi
final=$final"${value[0]}:${value[1]} "
done
Running the cron of cacti manually with:

sudo -u www-data php --define suhosin.memory_limit=512M /usr/share/cacti/site/poller.php 2>&1 >/dev/null
returns the correct output:

Loaded:4525.0 LoadedBytes:8057.3 Unloaded:14.0 UnloadedBytes:18.3 ClassTime:1.67
But when cacti runs it, poller returns output in a format like this:

Loaded:4525.0 LoadedBytes:8057,3.0 Unloaded:14.0 UnloadedBytes:18,3.0 ClassTime:1,67.0
Why?

I debugged cacti's php code and see it calls: exec_poll from /usr/share/cacti/site/lib/poller.php but similar thing happens. If I call exec_poll method from a seperate php file it returns the correct format but when I modify the cacti code to log out the output like

$fp = popen($command, "r");
$output = fgets($fp, 8192);
cacti_log("Output: " . $output , true, "POLLER");
it returns the wrong format.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests