centreon / centreon-archived

Centreon is a network, system and application monitoring tool. Centreon is the only AIOps Platform Providing Holistic Visibility to Complex IT Workflows from Cloud to Edge.
https://www.centreon.com
GNU General Public License v2.0
575 stars 240 forks source link

Wrong Hosttitle in GraphTitle on Graphpage #4964

Closed leo29041982 closed 7 years ago

leo29041982 commented 7 years ago

BUG REPORT INFORMATION

Centreon Web version: 2.8.4

Steps to reproduce the issue:

  1. Click on Graph-Icon on "Monitoring > Status Details > Services"
  2. on "Monitoring > Status Details > Services" the Graphtitle showes wrong Hostname.
  3. Values on Graph are from right Host/Service

Describe the results you received: Last Hostname from "SELECT CONCAT (h.name, " - ", s.description) as fullname FROM hosts h, services s WHERE h.host_id = s.host_id AND s.enabled = "1" AND s.service_id = 6" -> DEM_RZ_KAM_SW-RZ-KAM - NTP-Time

Describe the results you expected: Hostname from URL "main.php?p=204&mode=0&svc_id=DEM_RZ_KAM_RZVB-BZ1;NTP-Time"

Additional information you think important (e.g. issue happens only occasionally): Failure in www/include/views/graphs/graphs.php or www/class/centreonService.class.php

image

julienmathis commented 7 years ago

Hello,

Sorry, I can't reproduce your issue. Can you check the result of the query in the database ?

Thanks in advance

leo29041982 commented 7 years ago

i've added some Hosts. but it is always the last entry which is displayed.

left click... image

gets... image

SELECT CONCAT (h.name, " - ", s.description) as fullname FROM hosts h, services s WHERE h.host_id = s.host_id AND s.enabled = "1" AND s.service_id = 6


Result: fullname DEM_RZ_KAM_RZVB-BZ1 - NTP-Time DEM_RZ_KAM_RZVB-BZ2 - NTP-Time DEM_RZ_KAM_RZVB-RZA-BF1 - NTP-Time DEM_RZ_KAM_RZVB-RZA-BF2 - NTP-Time DEM_RZ_KAM_RZVB-RZA-BF3 - NTP-Time DEM_RZ_KAM_RZVB-RZA-CA1 - NTP-Time DEM_RZ_KAM_RZVB-RZA-CA2 - NTP-Time DEM_RZ_KAM_RZVB-RZA-D1 - NTP-Time DEM_RZ_KAM_RZVB-RZA-D2 - NTP-Time DEM_RZ_KAM_RZVB-RZA-K1 - NTP-Time DEM_RZ_KAM_RZVB-RZA-K2 - NTP-Time DEM_RZ_KAM_RZVB-RZA-K3 - NTP-Time DEM_RZ_KAM_RZVB-RZA-S1 - NTP-Time DEM_RZ_KAM_RZVB-RZA-TF1 Eingang - NTP-Time DEM_RZ_KAM_RZVB-RZA-TF2 - NTP-Time DEM_RZ_KAM_RZVB-RZA-TF3 - NTP-Time DEM_RZ_KAM_RZVB-RZA-W1 - NTP-Time DEM_RZ_KAM_RZVB-RZA-W2 - NTP-Time DEM_RZ_KAM_RZVB-RZB-BF1 - NTP-Time DEM_RZ_KAM_RZVB-RZB-CB1 - NTP-Time DEM_RZ_KAM_RZVB-RZB-CB2 - NTP-Time DEM_RZ_KAM_RZVB-RZB-D1 - NTP-Time DEM_RZ_KAM_RZVB-RZB-D2 - NTP-Time DEM_RZ_KAM_RZVB-RZB-K1 - NTP-Time DEM_RZ_KAM_RZVB-RZB-K2 - NTP-Time DEM_RZ_KAM_RZVB-RZB-K3 - NTP-Time DEM_RZ_KAM_RZVB-RZB-K4 - NTP-Time DEM_RZ_KAM_RZVB-RZB-TF1 - NTP-Time DEM_RZ_KAM_RZVB-RZB-TF2 - NTP-Time DEM_RZ_KAM_RZVB-RZB-W1 - NTP-Time DEM_RZ_KAM_RZVB-RZB-W2 - NTP-Time DEM_RZ_KAM_RZVB-RZB-W3 - NTP-Time WNS_KAM_Tank_CAM01 - NTP-Time WNS_KAM_Tank_CAM02 - NTP-Time WNS_KAM_Tank_CAM03 - NTP-Time WNS_KAM_Tank_CAM04 - NTP-Time WNS_KAM_Tank_CAM05 - NTP-Time WNS_KAM_Tank_CAM06 - NTP-Time WNS_KAM_Tank_CAM07 - NTP-Time WNS_KAM_Tank_CAM08 - NTP-Time

leo29041982 commented 7 years ago

This may solve the problem, same cause as #4955 , no Hostid checked.

File: www\include\views\graphs\graphs.php

    } else if (preg_match('/^(.+);(.+)/', $svc, $matches)) {
        list($hostname, $serviceDescription) = explode(";", $svc);
        $hostId = getMyHostID($hostname);
        $serviceId = getMyServiceID($serviceDescription, $hostId);
        $graphId = $hostId . '-' . $serviceId;                                 
        //old: $graphTitle = $serviceObj->getMonitoringFullName($serviceId);                   
        $graphTitle = $serviceObj->getMonitoringFullName($serviceId,  #$hostId);

$hostId possibly also with other function calls necessary

File: www\class\centreonService.class.php

//public function getMonitoringFullName($serviceId) public function getMonitoringFullName($serviceId, $hostId) $query = 'SELECT CONCAT (h.name, " - ", s.description) as fullname ' . 'FROM hosts h, services s ' . 'WHERE h.host_id = s.host_id ' . 'AND s.enabled = "1" ' //added line: . 'AND s.host_id = ' . $hostId . ' ' . 'AND s.host_id = ' . $hostId . ' ' . 'AND s.service_id = ' . $serviceId;

image

julienmathis commented 7 years ago

Your service is linked to multiple hosts ? right ?

leo29041982 commented 7 years ago

yes.

julienmathis commented 7 years ago

Hello,

Can you test the fix ?

Thanks

leo29041982 commented 7 years ago

it worked on my installation.

Lebowskijul commented 7 years ago

Fix is working also on my servers. Thanks a lot and sorry for the duplicate issue.