diff --git a/cron/centKnowledgeSynchronizer.php b/cron/centKnowledgeSynchronizer.php index 3e7b11be8c6dd7f8066a84f419fd3b7c4c683052..71e6cef1d0831842921fe39f7e26bb1536712045 100644 --- a/cron/centKnowledgeSynchronizer.php +++ b/cron/centKnowledgeSynchronizer.php @@ -7,10 +7,19 @@ require_once "/etc/centreon/centreon.conf.php"; $centreon_path = "/usr/share/centreon/"; $module_path = $centreon_path . "www/class/centreon-knowledge/"; +$CentreonURL = "http://localhost/centreon"; require_once $centreon_path . "www/class/centreonDB.class.php"; require_once $module_path . "procedures.class.php"; require_once $module_path . "procedures_DB_Connector.class.php"; +$modules_path = $centreon_path . "www/include/configuration/configKnowledge/"; +require_once $modules_path . 'functions.php'; + +// Initiate connexion +$dbConnector = new CentreonDB(); +$conf = getWikiConfig($dbConnector); +$WikiURL = $conf['kb_wiki_url']; + // Define cron constants define('_WIKIURL_', $WikiURL); define('_CENTREONURL_', $CentreonURL); @@ -217,9 +226,6 @@ function editLinkForService($dbConnector, $objName) ****** MAIN ***** ************************* */ - -// Initiate connexion -$dbConnector = new CentreonDB(); // Get all pages title that where changed $allPagesModificationInMediaWiki = array_merge(getCreatedPages(), getEditedPages()); $centreonObjects = detectCentreonObjects($allPagesModificationInMediaWiki); diff --git a/doc/en/configuration_guide/advanced_configuration/traps.rst b/doc/en/configuration_guide/advanced_configuration/traps.rst index 4740fe4f96347f804309e784016908cded54a524..7feaf8b56aeda24c722d52e2a07f64ff2b69d63f 100644 --- a/doc/en/configuration_guide/advanced_configuration/traps.rst +++ b/doc/en/configuration_guide/advanced_configuration/traps.rst @@ -167,6 +167,9 @@ Here is an example of possible configuration of the file **/etc/centreon/centreo Configuration of the connection to the database ----------------------------------------------- +.. note:: + On a poller, the database access should be configure in **/etc/centreon/centreontrapd.pm** file. + It is possible of configure the file **/etc/centreon/conf.pm** in two ways: * Retain the connection to the MySQL server database (necessary for the central server and possible for the satellite servers). Content of the file:: diff --git a/doc/fr/configuration_guide/advanced_configuration/traps.rst b/doc/fr/configuration_guide/advanced_configuration/traps.rst index 9ea3985a3a46a95eb0e904da96bc9b6f14a687a2..0e853538c6dbdcd0fe5658da022382157babe8d6 100644 --- a/doc/fr/configuration_guide/advanced_configuration/traps.rst +++ b/doc/fr/configuration_guide/advanced_configuration/traps.rst @@ -185,6 +185,10 @@ Voici un exemple de configuration possible du fichier **/etc/centreon/centreontr Configuration de la connexion à la base de données -------------------------------------------------- +.. note:: + Sur un collecteur distant (satellite), la configuration de l'accès à la base de données + est à réaliser dans le fichier **/etc/centreon/centreontrapd.pm**. + Il est possible de configurer le fichier **/etc/centreon/conf.pm** de deux manières : * Conserver la connexion au serveur de base de données MySQL (nécessaire pour le serveur central et possible pour les serveurs satellites). Contenu du fichier : diff --git a/www/include/monitoring/status/Hosts/xml/hostXML.php b/www/include/monitoring/status/Hosts/xml/hostXML.php index 3b65b6c9ce08527e55deba80acc82818b2defedf..8df79a8390d2ad7c1107d8ae763c461b7447d01a 100644 --- a/www/include/monitoring/status/Hosts/xml/hostXML.php +++ b/www/include/monitoring/status/Hosts/xml/hostXML.php @@ -377,7 +377,7 @@ while ($data = $DBRESULT->fetchRow()) { $str = str_replace("\$HOSTSTATE\$", $obj->statusHost[$data['state']], $str); $str = str_replace("\$INSTANCEADDRESS\$", $instanceObj->getParam($data['instance_name'], 'ns_ip_address'), $str); - $obj->XML->writeElement("hnu", CentreonUtils::escapeSecure($hostObj->replaceMacroInString($data["name"], $str))); + $obj->XML->writeElement("hnu", CentreonUtils::escapeSecure($hostObj->replaceMacroInString($data["notes_url"], $str))); } else { $obj->XML->writeElement("hnu", "none"); } diff --git a/www/include/monitoring/status/Notifications/notifications.php b/www/include/monitoring/status/Notifications/notifications.php index 4cda7458ba321590d2c16a235f6bb9d74cca8bcc..c68e3af4b27aa2e0e82a5e76282f9b3ef49b399c 100644 --- a/www/include/monitoring/status/Notifications/notifications.php +++ b/www/include/monitoring/status/Notifications/notifications.php @@ -64,7 +64,7 @@ $host_class_label = array(0 => "success", 1 => "error", 2 => "alert"); $sql = "SELECT name, description, s.state FROM services s, hosts h %s WHERE h.host_id = s.host_id - AND description NOT LIKE 'meta_%%' + AND (description NOT LIKE 'meta_%%' OR description NOT LIKE 'ba_%%') AND s.last_hard_state_change > (UNIX_TIMESTAMP(NOW()) - ".(int)$refresh_rate.") %s UNION @@ -75,19 +75,28 @@ $sql = "SELECT name, description, s.state AND s.last_hard_state_change > (UNIX_TIMESTAMP(NOW()) - ".(int)$refresh_rate.") %s UNION + SELECT 'Business Activity', s.display_name, s.state + FROM services s, hosts h %s + WHERE h.host_id = s.host_id + AND description LIKE 'ba_%%' + AND s.last_hard_state_change > (UNIX_TIMESTAMP(NOW()) - ".(int)$refresh_rate.") + %s + UNION SELECT name, NULL, h.state FROM hosts h %s WHERE h.last_hard_state_change > (UNIX_TIMESTAMP(NOW()) - ".(int)$refresh_rate.") %s AND name != '_Module_Meta'"; if ($obj->is_admin) { - $sql = sprintf($sql, "", "", "", "", "", ""); + $sql = sprintf($sql, "", "", "", "", "", "", "", ""); } else { $sql = sprintf( $sql, - ", centreon_acl acl", - "AND acl.service_id = s.service_id AND acl.host_id = h.host_id " . $obj->access->queryBuilder("AND", "acl.group_id", $obj->grouplistStr), - ", centreon_acl acl", + ", centreon_acl acl", + "AND acl.service_id = s.service_id AND acl.host_id = h.host_id " . $obj->access->queryBuilder("AND", "acl.group_id", $obj->grouplistStr), + ", centreon_acl acl", + "AND acl.service_id = s.service_id AND acl.host_id = h.host_id " . $obj->access->queryBuilder("AND", "acl.group_id", $obj->grouplistStr), + ", centreon_acl acl", "AND acl.service_id = s.service_id AND acl.host_id = h.host_id " . $obj->access->queryBuilder("AND", "acl.group_id", $obj->grouplistStr), ", centreon_acl acl", "AND acl.host_id = h.host_id" . $obj->access->queryBuilder("AND", "acl.group_id", $obj->grouplistStr) diff --git a/www/include/monitoring/status/Services/xml/serviceXML.php b/www/include/monitoring/status/Services/xml/serviceXML.php index c8e8ba4abe501de5bfe2c706d042b28143883379..9ad0e6baf81be0d556769e92f43e6692bead5309 100644 --- a/www/include/monitoring/status/Services/xml/serviceXML.php +++ b/www/include/monitoring/status/Services/xml/serviceXML.php @@ -421,6 +421,8 @@ if (!PEAR::isError($DBRESULT)) { $obj->XML->text(CentreonUtils::escapeSecure($data["name"]), true, false); $obj->XML->endElement(); + $hostObj = new CentreonHost($obj->DB); + $hostNotesUrl = "none"; if ($data["h_notes_url"]) { $hostNotesUrl = str_replace("\$HOSTNAME\$", $data["name"], $data["h_notes_url"]); @@ -431,19 +433,21 @@ if (!PEAR::isError($DBRESULT)) { $hostNotesUrl = str_replace("\$HOSTSTATEID\$", $data["host_state"], $hostNotesUrl); $hostNotesUrl = str_replace("\$INSTANCEADDRESS\$", $instanceObj->getParam($data["instance_name"], "ns_ip_address"), $hostNotesUrl); } - $obj->XML->writeElement("hnu", CentreonUtils::escapeSecure($hostNotesUrl)); + $obj->XML->writeElement("hnu", CentreonUtils::escapeSecure($hostObj->replaceMacroInString($data["name"], $hostNotesUrl))); + + $hostObj = new CentreonHost($obj->DB); $hostActionUrl = "none"; if ($data["h_action_url"]) { $hostActionUrl = str_replace("\$HOSTNAME\$", $data["name"], $data["h_action_url"]); - $hostActionUrl = str_replace("\$HOSTALIAS\$", $data["alias"], $hostNotesUrl); + $hostActionUrl = str_replace("\$HOSTALIAS\$", $data["alias"], $hostActionUrl); $hostActionUrl = str_replace("\$HOSTADDRESS\$", $data["address"], $hostActionUrl); $hostActionUrl = str_replace("\$INSTANCENAME\$", $data["instance_name"], $hostActionUrl); $hostActionUrl = str_replace("\$HOSTSTATE\$", $obj->statusHost[$data["host_state"]], $hostActionUrl); $hostActionUrl = str_replace("\$HOSTSTATEID\$", $data["host_state"], $hostActionUrl); $hostActionUrl = str_replace("\$INSTANCEADDRESS\$", $instanceObj->getParam($data["instance_name"], "ns_ip_address"), $hostActionUrl); } - $obj->XML->writeElement("hau", CentreonUtils::escapeSecure($hostActionUrl)); + $obj->XML->writeElement("hau", CentreonUtils::escapeSecure($hostObj->replaceMacroInString($data["name"], $hostActionUrl))); $obj->XML->writeElement("hnn", CentreonUtils::escapeSecure($data["h_notes"])); $obj->XML->writeElement("hico", $data["h_icon_images"]); @@ -512,6 +516,8 @@ if (!PEAR::isError($DBRESULT)) { $obj->XML->writeElement("snn", 'none'); } + $srvObj = new CentreonService($obj->DB); + if ($data["notes_url"] != "") { $data["notes_url"] = str_replace("\$SERVICEDESC\$", $data["description"], $data["notes_url"]); $data["notes_url"] = str_replace("\$SERVICESTATEID\$", $data["state"], $data["notes_url"]); @@ -527,7 +533,7 @@ if (!PEAR::isError($DBRESULT)) { $data["notes_url"] = str_replace("\$INSTANCENAME\$", $data['instance_name'], $data['notes_url']); $data["notes_url"] = str_replace("\$INSTANCEADDRESS\$", $instanceObj->getParam($data['instance_name'], 'ns_ip_address'), $data["notes_url"]); } - $obj->XML->writeElement("snu", CentreonUtils::escapeSecure($data["notes_url"])); + $obj->XML->writeElement("snu", CentreonUtils::escapeSecure($srvObj->replaceMacroInString($data["service_id"], $data["notes_url"]))); } else { $obj->XML->writeElement("snu", 'none'); } @@ -547,7 +553,7 @@ if (!PEAR::isError($DBRESULT)) { $data["action_url"] = str_replace("\$INSTANCENAME\$", $data['instance_name'], $data['action_url']); $data["action_url"] = str_replace("\$INSTANCEADDRESS\$", $instanceObj->getParam($data['instance_name'], 'ns_ip_address'), $data["action_url"]); } - $obj->XML->writeElement("sau", CentreonUtils::escapeSecure($data["action_url"])); + $obj->XML->writeElement("sau", CentreonUtils::escapeSecure($srvObj->replaceMacroInString($data["service_id"], $data["action_url"]))); } else { $obj->XML->writeElement("sau", 'none'); } diff --git a/www/install/createTablesCentstorage.sql b/www/install/createTablesCentstorage.sql index aedb3cf769b158757e20ae745a7c68e6e0b7f645..7fec70ea1c4a20be94c4915b19ef7e84ab3dc9ee 100644 --- a/www/install/createTablesCentstorage.sql +++ b/www/install/createTablesCentstorage.sql @@ -52,7 +52,7 @@ CREATE TABLE `config` ( LOCK TABLES `config` WRITE; /*!40000 ALTER TABLE `config` DISABLE KEYS */; -INSERT INTO `config` VALUES (1,'@CENTSTORAGE_RRD@/metrics/','@CENTSTORAGE_RRD@/status/','@CENTSTORAGE_RRD@/nagios-perf/',180,365,'1',10,360,2,NULL,'1',31,365,'@MONITORING_VAR_LOG@/nagios.log',0,'1', 0, 0); +INSERT INTO `config` VALUES (1,'@CENTSTORAGE_RRD@/metrics/','@CENTSTORAGE_RRD@/status/','@CENTSTORAGE_RRD@/nagios-perf/',180,365,'1',10,360,2,NULL,'1',31,365,'@MONITORING_VAR_LOG@/centengine.log.log',0,'1', 0, 0); /*!40000 ALTER TABLE `config` ENABLE KEYS */; UNLOCK TABLES; /*!40101 SET @saved_cs_client = @@character_set_client */; diff --git a/www/install/sql/centstorage/Update-DB-2.8.0-beta1_to_2.8.0-beta2.sql b/www/install/sql/centstorage/Update-DB-2.8.0-beta1_to_2.8.0-beta2.sql new file mode 100644 index 0000000000000000000000000000000000000000..147868902154a73411579311f4b4ce675683d943 --- /dev/null +++ b/www/install/sql/centstorage/Update-DB-2.8.0-beta1_to_2.8.0-beta2.sql @@ -0,0 +1,2 @@ +-- Issue #4649 - [logAnalyserBroker] Doesn't work +UPDATE `config` SET nagios_log_file = '/var/log/centreon-engine/centengine.log', archive_log = 1;