From c49b92dae477189713d7fbe9ce50927fea6bbfa7 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 4 Feb 2026 07:22:17 -0500 Subject: [PATCH 1/3] Small issue with no tests --- poller_servcheck.php | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/poller_servcheck.php b/poller_servcheck.php index 0473761..561e501 100644 --- a/poller_servcheck.php +++ b/poller_servcheck.php @@ -174,7 +174,7 @@ $tests = db_fetch_assoc_prepared("SELECT * FROM plugin_servcheck_test WHERE enabled = 'on', - $sql_where", + $sql_where", $params); $max_processes = read_config_option('servcheck_processes'); @@ -248,23 +248,25 @@ $stat_search_ok = 0; $stat_search_ko = 0; -foreach ($tests as $test) { - $test_last = db_fetch_row_prepared('SELECT result, result_search - FROM plugin_servcheck_log - WHERE test_id = ? - ORDER BY id DESC LIMIT 1', - [$test['id']]); - - if (isset($test_last['result']) && ($test_last['result'] == 'ok' || $test_last['result'] == 'not yet')) { - $stat_ok++; - } else { - $stat_ko++; - } +if (cacti_sizeof($tests)) { + foreach ($tests as $test) { + $test_last = db_fetch_row_prepared('SELECT result, result_search + FROM plugin_servcheck_log + WHERE test_id = ? + ORDER BY id DESC LIMIT 1', + [$test['id']]); + + if (isset($test_last['result']) && ($test_last['result'] == 'ok' || $test_last['result'] == 'not yet')) { + $stat_ok++; + } else { + $stat_ko++; + } - if (isset($test_last['result_search']) && ($test_last['result_search'] == 'ok' || $test_last['result_search'] == 'not yet ' || $test_last['result_search'] == 'not tested')) { - $stat_search_ok++; - } else { - $stat_search_ko++; + if (isset($test_last['result_search']) && ($test_last['result_search'] == 'ok' || $test_last['result_search'] == 'not yet ' || $test_last['result_search'] == 'not tested')) { + $stat_search_ok++; + } else { + $stat_search_ko++; + } } } From 5319c9575a64cf82dd6fc4edb2de253e5300b715 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 4 Feb 2026 07:25:58 -0500 Subject: [PATCH 2/3] Syntax error in SQL --- poller_servcheck.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/poller_servcheck.php b/poller_servcheck.php index 561e501..eeaf18e 100644 --- a/poller_servcheck.php +++ b/poller_servcheck.php @@ -164,7 +164,7 @@ $params = []; $params[] = $poller_id; -$sql_where = 'AND poller_id = ?'; +$sql_where = ' AND poller_id = ?'; if ($test_id > 0) { $sql_where = ' AND id = ?'; @@ -173,7 +173,7 @@ $tests = db_fetch_assoc_prepared("SELECT * FROM plugin_servcheck_test - WHERE enabled = 'on', + WHERE enabled = 'on' $sql_where", $params); From 6df9de0ae17f1425af5309dc28e1627ea22dfa6c Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 4 Feb 2026 07:39:30 -0500 Subject: [PATCH 3/3] Update poller_servcheck.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- poller_servcheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poller_servcheck.php b/poller_servcheck.php index eeaf18e..6e664b7 100644 --- a/poller_servcheck.php +++ b/poller_servcheck.php @@ -262,7 +262,7 @@ $stat_ko++; } - if (isset($test_last['result_search']) && ($test_last['result_search'] == 'ok' || $test_last['result_search'] == 'not yet ' || $test_last['result_search'] == 'not tested')) { + if (isset($test_last['result_search']) && ($test_last['result_search'] == 'ok' || $test_last['result_search'] == 'not yet' || $test_last['result_search'] == 'not tested')) { $stat_search_ok++; } else { $stat_search_ko++;