Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix poller_servcheck.php does not run any test when it runs automatically from cacti poller (Issue #31) #32

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

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.

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