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

enh(core): generate centreon gorgone configuration file #8160

Merged
merged 11 commits into from
Dec 10, 2019
2 changes: 1 addition & 1 deletion www/class/config-generate/abstract/object.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private function setHeader()
"# #\n" .
"# GENERATED BY CENTREON #\n" .
"# #\n" .
"# Developped by : #\n" .
"# Developed by : #\n" .
"# - Julien Mathis #\n" .
"# - Romain Le Merlus #\n" .
"# #\n" .
Expand Down
39 changes: 35 additions & 4 deletions www/install/steps/process/configFileSetup.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Copyright 2005-2015 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2019 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -53,6 +53,7 @@
$host = 'localhost';
}

// mandatory parameters used by centCore or Gorgone.d in the legacy SSH mode
$patterns = array(
'/--ADDRESS--/',
'/--DBUSER--/',
Expand All @@ -79,22 +80,52 @@
$configuration['centreon_varlib']
);

// specific additional mandatory parameters used by Gorgone.d in a full ZMQ mode
// these patterns don't replace the original ones
$gorgonePatterns = [
'/--CENTREON_SPOOL--/',
'/--HTTPSERVERADDRESS--/',
'/--HTTPSERVERPORT--/',
'/--SSLMODE--/',
'/--CENTREON_TRAPDIR--/',
];

$gorgoneReplacements = [
"/var/spool/centreon",
"0.0.0.0",
"8085",
"false",
"/etc/snmp/centreon_traps",
];

$centreonEtcPath = rtrim($configuration['centreon_etc'], '/');

/**
* centreon.conf.php
*/
$centreonConfFile = rtrim($configuration['centreon_etc'], '/') . '/centreon.conf.php';
$centreonConfFile = $centreonEtcPath . '/centreon.conf.php';
$contents = file_get_contents('../../var/configFileTemplate');
$contents = preg_replace($patterns, $replacements, $contents);
file_put_contents($centreonConfFile, $contents);

/**
* conf.pm
*/
$centreonConfPmFile = rtrim($configuration['centreon_etc'], '/') . '/conf.pm';
$centreonConfPmFile = $centreonEtcPath . '/conf.pm';
$contents = file_get_contents('../../var/configFilePmTemplate');
$contents = preg_replace($patterns, $replacements, $contents);
file_put_contents($centreonConfPmFile, $contents);

/**
* gorgone.yaml
* configuration file used by the Gorgone module in a full ZMQ mode
*/
$centreonGorgonedConfFile = $centreonEtcPath . '/gorgoned.yml';
$contents = file_get_contents('../../var/configFileGorgoneTemplate');
$contents = preg_replace($patterns, $replacements, $contents);
$contents = preg_replace($gorgonePatterns, $gorgoneReplacements, $contents);
file_put_contents($centreonGorgonedConfFile, $contents);

$return['result'] = 0;
echo json_encode($return);
exit;
70 changes: 70 additions & 0 deletions www/install/var/configFileGorgoneTemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: gorgoned-central
description: Configuration for Central server
database:
db_centreon:
dsn: "mysql:host=--ADDRESS--:--DBPORT--;dbname=--CONFDB--"
username: "--DBUSER--"
password: "--DBPASS--"
db_centstorage:
dsn: "mysql:host=--ADDRESS--:--DBPORT--;dbname=--STORAGEDB--"
username: "--DBUSER--"
password: "--DBPASS--"
gorgonecore:
privkey: "--CENTREON_SPOOL--/.gorgone/rsakey.priv.pem"
pubkey: "--CENTREON_SPOOL--/.gorgone/rsakey.pub.pem"
cipher: "Cipher::AES"
keysize: 32
vector: 0123456789012345
modules:
- name: httpserver
package: "gorgone::modules::core::httpserver::hooks"
enable: true
address: "--HTTPSERVERADDRESS--"
port: "--HTTPSERVERPORT--"
ssl: --SSLMODE--
auth:
enabled: false
allowed_hosts:
enabled: true
subnets:
- 127.0.0.1/32

- name: action
package: "gorgone::modules::core::action::hooks"
enable: true

- name: cron
package: "gorgone::modules::core::cron::hooks"
enable: true

- name: proxy
package: "gorgone::modules::core::proxy::hooks"
enable: true

- name: nodes
package: "gorgone::modules::centreon::nodes::hooks"
enable: true

- name: legacycmd
package: "gorgone::modules::centreon::legacycmd::hooks"
enable: true
cmd_file: "--CENTREON_VARLIB--/centcore.cmd"
cache_dir: "--CENTREON_CACHEDIR--"
cache_dir_trap: "--CENTREON_TRAPDIR--"
remote_dir: "--CENTREON_VARLIB--/remote-data/"

- name: engine
package: "gorgone::modules::centreon::engine::hooks"
enable: true
command_file: "--CENTREON_VARLIB---engine/rw/centengine.cmd"

- name: broker
package: "gorgone::modules::centreon::broker::hooks"
enable: true
cache_dir: "--CENTREON_CACHEDIR--/broker-stats/"
cron:
- id: broker_stats
timespec: "*/2 * * * *"
action: BROKERSTATS
parameters:
timeout: 10