Open joschi99 opened 6 years ago
Hi,
You are talking about SQLite database, so this problem appears on distant poller?
Can you try this fix?
--- /usr/share/centreon/bin/generateSqlLite.origin 2018-02-03 14:44:25.450775054 +0100
+++ /usr/share/centreon/bin/generateSqlLite 2018-02-03 14:51:16.087316220 +0100
@@ -396,26 +396,31 @@
// Insert direct services
$insertedServices = array();
foreach ($result_host_services as $value) {
- if (!isset($insertedServices[$value['service_id']])) {
- $stmt = $dbh_sqlite->prepare("INSERT INTO service (service_id, service_description, service_template_model_stm_id) VALUES (
- :service_id, :service_description, :service_template_model_stm_id)");
- $stmt->bindParam(':service_id', $value['service_id'], PDO::PARAM_INT);
- $stmt->bindParam(':service_description', $value['service_description'], PDO::PARAM_STR);
- $stmt->bindParam(':service_template_model_stm_id', $value['service_template_model_stm_id'], PDO::PARAM_INT);
- $stmt->execute();
- $insertedServices[$value['service_id']] = true;
-
+ if (!isset($insertedServices[$value['service_id']."-".$value['host_id']])) {
+ if (!isset($insertedServicesUniq[$value['service_id']])) {
+ $stmt = $dbh_sqlite->prepare("INSERT INTO service (service_id, service_description, service_template_model_stm_id) VALUES (
+ :service_id, :service_description, :service_template_model_stm_id)");
+ $stmt->bindParam(':service_id', $value['service_id'], PDO::PARAM_INT);
+ $stmt->bindParam(':service_description', $value['service_description'], PDO::PARAM_STR);
+ $stmt->bindParam(':service_template_model_stm_id', $value['service_template_model_stm_id'], PDO::PARAM_INT);
+ $stmt->execute();
+ $insertedServicesUniq[$value['service_id']] = true;
+ }
+
$stmt = $dbh_sqlite->prepare("INSERT INTO host_service_relation (service_service_id, host_host_id) VALUES (
:service_service_id, :host_host_id)");
$stmt->bindParam(':service_service_id', $value['service_id'], PDO::PARAM_INT);
$stmt->bindParam(':host_host_id', $value['host_id'], PDO::PARAM_INT);
$stmt->execute();
+ $insertedServices[$value['service_id']."-".$value['host_id']] = true;
- $stmt = $dbh_sqlite->prepare("INSERT INTO extended_service_information (service_service_id, esi_notes) VALUES (
- :service_service_id, :esi_notes)");
- $stmt->bindParam(':service_service_id', $value['service_id'], PDO::PARAM_INT);
- $stmt->bindParam(':esi_notes', $value['esi_notes'], PDO::PARAM_STR);
- $stmt->execute();
+ if (!isset($insertedServicesUniq[$value['service_id']])) {
+ $stmt = $dbh_sqlite->prepare("INSERT INTO extended_service_information (service_service_id, esi_notes) VALUES (
+ :service_service_id, :esi_notes)");
+ $stmt->bindParam(':service_service_id', $value['service_id'], PDO::PARAM_INT);
+ $stmt->bindParam(':esi_notes', $value['esi_notes'], PDO::PARAM_STR);
+ $stmt->execute();
+ }
}
}
// Insert services by hostgroup
Yes, in our case the problem is related on the poller. But I don’t know if the problem is related also on central.
From: Laurent Pinsivy Sent: Samstag, 3. Februar 2018 14:14 To: centreon/centreon Cc: Jochen Platzgummer; Author Subject: Re: [centreon/centreon] [trap] - no match if service with trapdefinition is used for multiple hosts (#6039)
Hi, You are talking about SQLite database, so this problem appears on distant poller? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi @lpinsivy, I tested your fix on the poller and the trap seem's working correctly
@joschi99 the best way is to "detach" your service to have unitary service linked to host and based on template.
It is not a best practice to configure a service linked to many hosts
BUG REPORT INFORMATION
Centreon Web version: 2.8.17
Centreon Engine version: 1.8.1
Centreon Broker version: 3.0.12
OS:
Additional environment details (AWS, VirtualBox, physical, etc.): VMWare
Steps to reproduce the issue:
Describe the results you received: the trap is no elaborated correcty: no service matching trap found (sqlite)
Describe the results you expected: trap matched
Additional information you think important (e.g. issue happens only occasionally): if I use the same service only for 1 host, it is working