Skip to content

Conversation

@MSS970
Copy link
Contributor

@MSS970 MSS970 commented Mar 3, 2025

poller_servcheck.php does not run any test when it runs automatically from cacti poller

The issue is related to the logic at line 117 to 121:

$tests = db_fetch_assoc_prepared('SELECT *
FROM plugin_servcheck_test
WHERE enabled = "on"
AND poller_id = ? AND id = ?',
array($poller_id, $test_id));

The code could be enhanced as follows:
if ($test_id == 0) {
$sql_condition = ' ';
} else {
$sql_condition = ' AND id = ' . $test_id;
}

$tests = db_fetch_assoc_prepared('SELECT *
FROM plugin_servcheck_test
WHERE enabled = "on"
AND poller_id = ? ' .
$sql_condition,
array($poller_id));

furthermore, typo in arrays.php line 326 "disabled" should be "disable"

in servecheck_test.php, add the following after line 1019 ($sql_order = get_order_string();):

// `statistics` is not a table column, the columns are:
// `stats_ok` and `stats_bad`, hence, the ORDER BY should be based on these 2 columns
if ($sql_order == 'ORDER BY `statistics` ASC') {
	$sql_order = 'ORDER BY `stats_ok` ASC, `stats_bad` ASC';
} elseif ($sql_order == 'ORDER BY `statistics` DESC') {
	$sql_order = 'ORDER BY `stats_ok` DESC, `stats_bad` DESC';
}

fix poller_servcheck.php does not run any test when it runs automatically from cacti poller
fix poller_servcheck.php does not run any test when it runs automatically from cacti poller
order by the statistics
Copy link
Contributor Author

@MSS970 MSS970 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly review the fixes and authorize (if possible)

Copy link
Member

@TheWitness TheWitness left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like maybe an error in the display text array.

@MSS970
Copy link
Contributor Author

MSS970 commented Mar 3, 2025

Hey @TheWitness
How are you?

Can you advise which file you suspect to have an error in the display text array? what is the array name?

$sql_condition = ' ';
} else {
$sql_condition = ' AND id = ' . $test_id;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, good catch @MSS970

@MSS970
Copy link
Contributor Author

MSS970 commented Mar 3, 2025

Hi @TheWitness ,

Do you see any issue with pull request, or it is good to go.

Regards,
MSS970

@TheWitness
Copy link
Member

@MSS970 , I should be able to look at it tomorrow. Busy tonight.

@MSS970
Copy link
Contributor Author

MSS970 commented Mar 6, 2025

Hi @TheWitness ,
Appreciate your support on the above.

@xmacan
Copy link
Member

xmacan commented Mar 6, 2025

@TheWitness I think that you can approve this. @MSS970 fixed my bugs

@TheWitness
Copy link
Member

Okay. I'll merge now and look back in my morning

@TheWitness TheWitness merged commit 536a1fb into Cacti:main Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants