Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(trap): no match if service is linked for multiple hosts #6378

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions bin/generateSqlLite
Original file line number Diff line number Diff line change
Expand Up @@ -396,26 +396,31 @@ try {
// 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();

$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();
$insertedServices[$value['service_id']."-".$value['host_id']] = true;

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
Expand Down