RPN expression possible bug?

Support questions about the Threshold plugin

Moderators: Developers, Moderators

Post Reply
dolla
Posts: 19
Joined: Tue Oct 05, 2010 6:11 pm

RPN expression possible bug?

Post by dolla »

I have a thold template which use a simple RPN expression:

Code: Select all

1,|ds:ssCpuRawIdle|,|ds:ssCpuRawTotal|,/,-,100,*
Basically it calculates the cpu usage from two ds values.
After that i see errors like this in cacti log:

Code: Select all

04/27/2012 11:20:08 AM - CMDPHP: Poller[0] ERROR: SQL Cell Failed!, Error:'1064', SQL:"SELECT calculated FROM data_source_stats_hourly_last WHERE local_data_id= AND rrd_name='sscpurawtotal'"
04/27/2012 11:20:08 AM - CMDPHP: Poller[0] 4800.4893
I trace to thold_functions.php, function name thold_calculate_expression, around line 658.
You could see below, it uses a different array item $thold['rrd_id'] (others use $thold['rra_id']), which seems to be null. Thus the SQL statement execution fails.

Simply change it to $thold['rra_id'] resolves this problem. And need to comment out the line "cacti_log" to suppress the second line of CMDPHP output.

Code: Select all

                        $thold_item = db_fetch_row("SELECT thold_data.id, thold_data.graph_id,
                                thold_data.percent_ds, thold_data.expression,
                                thold_data.data_type, thold_data.cdef, thold_data.rra_id,
                                thold_data.data_id, thold_data.lastread,
                                UNIX_TIMESTAMP(thold_data.lasttime) AS lasttime, thold_data.oldvalue,
                                data_template_rrd.data_source_name as name,
                                data_template_rrd.data_source_type_id, data_template_data.rrd_step,
                                data_template_rrd.rrd_maximum
                                FROM thold_data
                                LEFT JOIN data_template_rrd
                                ON (data_template_rrd.id = thold_data.data_id)
                                LEFT JOIN data_template_data
                                ON (data_template_data.local_data_id=thold_data.rra_id)
                                WHERE data_template_rrd.data_source_name='$dsname'
                                AND thold_data.rra_id=" . $thold['rra_id'], false); #### <====== look here

                        if (sizeof($thold_item)) {
                                $item = array();
                                $currenttime = 0;
                                $expression[$key] = thold_get_currentval($thold_item, $rrd_reindexed, $rrd_time_reindexed, $item, $currenttime);
                        } else {
                                $value = '';
                                if (api_plugin_is_enabled('dsstats') && read_config_option("dsstats_enable") == "on") {
                                        $value = db_fetch_cell("SELECT calculated
                                                FROM data_source_stats_hourly_last
                                                WHERE local_data_id=" . $thold['rrd_id'] . "    #### <====== look here
                                                AND rrd_name='$dsname'");
                                }

                                if (empty($value) || $value == '-90909090909') {
                                        $expression[$key] = get_current_value($thold['rra_id'], $dsname);   #### <====== look here
                                } else {
                                        $expression[$key] = $value;
                                }
                                cacti_log($expression[$key]);
                        }
It seems the version here still have $thold['rrd_id'] used in the same function.
http://svn.cacti.net/viewvc/thold/branc ... iew=markup
Is it possible a bug? Could someone help to confirm? Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests