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

core(rrd) move global rrd cache option #7791

Merged
merged 32 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9d4e360
front
loiclau Aug 19, 2019
884a376
update sql
loiclau Aug 19, 2019
201acaf
fix back
loiclau Aug 21, 2019
8462920
add update script
loiclau Aug 21, 2019
6a36298
fix name
loiclau Aug 21, 2019
3665f40
update sql
loiclau Aug 21, 2019
e6ba712
clean form
loiclau Aug 21, 2019
7fc76f4
Merge branch 'master' into MON-4035-rrd-broker
loiclau Aug 21, 2019
219312c
beta3 update
loiclau Aug 21, 2019
9502b1e
Update www/class/centreonConfigCentreonBroker.php
loiclau Aug 22, 2019
dd46918
Update www/include/common/javascript/centreon/brokerConfig.js
loiclau Aug 22, 2019
c4c70a5
Update www/include/common/javascript/centreon/brokerConfig.js
loiclau Aug 22, 2019
d3672f9
fix style
loiclau Aug 22, 2019
7e3b521
fix style
loiclau Aug 22, 2019
c76ab0f
change text
loiclau Aug 22, 2019
4674969
update trad file
loiclau Aug 22, 2019
9ee3d2b
Merge branch 'master' into MON-4035-rrd-broker
loiclau Aug 22, 2019
349fd22
clean duplicate trad
loiclau Aug 22, 2019
aecb245
update test
loiclau Aug 22, 2019
7f14ea4
Merge branch 'master' into MON-4035-rrd-broker
loiclau Sep 12, 2019
192bdf6
update update
loiclau Sep 12, 2019
61f4c28
fix query
loiclau Sep 12, 2019
ad406c6
update sql
loiclau Sep 12, 2019
a885149
Merge branch 'master' into MON-4035-rrd-broker
loiclau Sep 12, 2019
6429d48
release
loiclau Sep 12, 2019
f98a5cd
fix sql update
loiclau Sep 12, 2019
638bfa0
force input order
loiclau Sep 13, 2019
b76016f
fix query
loiclau Sep 16, 2019
8ba70d0
clean db
loiclau Sep 19, 2019
965ab39
style
loiclau Sep 19, 2019
2b1a6dd
Merge branch 'master' into MON-4035-rrd-broker
loiclau Sep 20, 2019
1d61e08
move beta4 to beta3
loiclau Sep 20, 2019
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
248 changes: 107 additions & 141 deletions www/class/centreonConfigCentreonBroker.php

Large diffs are not rendered by default.

42 changes: 28 additions & 14 deletions www/class/config-generate/broker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ private function getExternalValues()
global $pearDB;

if (!is_null($this->cacheExternalValue)) {
return ;
return;
}

$this->cacheExternalValue = array();
$stmt = $this->backend_instance->db->prepare("SELECT
CONCAT(cf.fieldname, '_', cttr.cb_tag_id, '_', ctfr.cb_type_id) as name, external FROM cb_field cf, cb_type_field_relation ctfr, cb_tag_type_relation cttr
Expand All @@ -108,7 +108,7 @@ private function getExternalValues()
private function generate($poller_id, $localhost)
{
$this->getExternalValues();

if (is_null($this->stmt_broker)) {
$this->stmt_broker = $this->backend_instance->db->prepare("SELECT
$this->attributes_select
Expand Down Expand Up @@ -144,7 +144,7 @@ private function generate($poller_id, $localhost)
$stats_activate = $row['stats_activate'];
$correlation_activate = $row['correlation_activate'];

# Base parameters
// Base parameters
$object['broker_id'] = $row['config_id'];
$object['broker_name'] = $row['config_name'];
$object['poller_id'] = $this->engine['id'];
Expand All @@ -171,7 +171,7 @@ private function generate($poller_id, $localhost)
$this->stmt_broker_parameters->execute();
$resultParameters = $this->stmt_broker_parameters->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC);

# Flow parameters
// Flow parameters
foreach ($resultParameters as $key => $value) {
// We search the BlockId
$blockId = 0;
Expand All @@ -184,6 +184,7 @@ private function generate($poller_id, $localhost)
}
}

$rrdCacheOption = 'disable';
foreach ($value as $subvalue) {
if (!isset($subvalue['fieldIndex']) ||
$subvalue['fieldIndex'] == "" ||
Expand All @@ -202,9 +203,22 @@ private function generate($poller_id, $localhost)
$object[$subvalue['config_group_id']][$key]['filters'][][$subvalue['config_key']] =
$subvalue['config_value'];
} else {
if ($subvalue['config_key'] === 'rrd_cached_option') {
$rrdCacheOption = $subvalue['config_value'];
continue;
}

if ($subvalue['config_key'] === 'rrd_cached') {
if ($rrdCacheOption === 'tcp') {
$object[$subvalue['config_group_id']][$key]['port'] = $subvalue['config_value'];
} elseif ($rrdCacheOption === 'unix') {
$object[$subvalue['config_group_id']][$key]['path'] = $subvalue['config_value'];
}
continue;
}

$object[$subvalue['config_group_id']][$key][$subvalue['config_key']] =
$subvalue['config_value'];

// We override with external values
if (isset($this->cacheExternalValue[$subvalue['config_key'] . '_' . $blockId])) {
$object[$subvalue['config_group_id']][$key][$subvalue['config_key']] =
Expand All @@ -223,7 +237,7 @@ private function generate($poller_id, $localhost)
}
$flow_count++;
}

// Check if we need to add values from external
foreach ($this->cacheExternalValue as $key2 => $value2) {
if (preg_match('/^(.+)_' . $blockId . '$/', $key2, $matches)) {
Expand All @@ -235,7 +249,7 @@ private function generate($poller_id, $localhost)
}
}

# Stats parameters
// Stats parameters
if ($stats_activate == '1') {
$object[$flow_count]['stats'] = array(
'type' => 'stats',
Expand All @@ -244,7 +258,7 @@ private function generate($poller_id, $localhost)
);
}

# Generate file
// Generate file
$this->generateFile($object, true, 'centreonBroker');
$this->writeFile($this->backend_instance->getPath());
}
Expand Down Expand Up @@ -289,7 +303,7 @@ public function generateFromPoller($poller)
{
$this->generate($poller['id'], $poller['localhost']);
}

private function getInfoDb($string)
{
/*
Expand Down Expand Up @@ -352,10 +366,10 @@ private function getInfoDb($string)
$db = $this->backend_instance->db_cs;
break;
}

$stmt = $db->prepare($query);
$stmt->execute();

$infos = array();
while (($row = $stmt->fetch(PDO::FETCH_ASSOC))) {
$val = $row[$s_column];
Expand All @@ -371,7 +385,7 @@ private function getInfoDb($string)
}
return $infos;
}

private function rpnCalc($rpn, $val)
{
if (!is_numeric($val)) {
Expand All @@ -387,7 +401,7 @@ private function rpnCalc($rpn, $val)
return $val;
}
}

private function rpnOperation($result, $item)
{
if (in_array($item, array('+', '-', '*', '/'))) {
Expand Down
21 changes: 0 additions & 21 deletions www/include/Administration/parameters/rrdtool/form.ihtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,6 @@
</td>
<td class="FormRowValue">{$form.rrdtool_version.html}</td>
</tr>

<tr class="list_lvl_1">
<td class="ListColLvl1_name" colspan="2">
<h4>{$form.header.rrdcached_title}</h4>
</td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="tip_rrdcached_enable">{$form.rrdcached_enable.label}
</td>
<td class="FormRowValue">{$form.rrdcached_enable.html}</td>
</tr>
<tr class="list_one">
<td class="FormRowField"><img class="helpTooltip" name="tip_rrdcached_port">{$form.rrdcached_port.label}
</td>
<td class="FormRowValue">{$form.rrdcached_port.html}</td>
</tr>
<tr class="list_two">
<td class="FormRowField"><img class="helpTooltip" name="tip_rrdcached_unix_path">{$form.rrdcached_unix_path.label}
</td>
<td class="FormRowValue">{$form.rrdcached_unix_path.html}</td>
</tr>
</table>
{if !$valid}
<div id="validForm" class="oreonbutton">
Expand Down
11 changes: 0 additions & 11 deletions www/include/Administration/parameters/rrdtool/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,6 @@
$form->addElement('text', 'rrdtool_path_bin', _("Directory + RRDTOOL Binary"), $attrsText);
$form->addElement('text', 'rrdtool_version', _("RRDTool Version"), $attrsText2);

/*
* Rrdcached
*/
$attrEnable = array('onclick' => 'toggleRrdcached(this)');
$form->addElement('header', 'rrdcached_title', _("Rrdcached configuration : work only with Centreon Broker"));
$rrdcachedEnable[] = $form->createElement('radio', 'rrdcached_enable', null, _("Yes"), '1', $attrEnable);
$rrdcachedEnable[] = $form->createElement('radio', 'rrdcached_enable', null, _("No"), '0', $attrEnable);
$form->addGroup($rrdcachedEnable, 'rrdcached_enable', _("Enable RRDCached"), '&nbsp;');
$form->addElement('text', 'rrdcached_port', _('TCP Port'), $attrsText2);
$form->addElement('text', 'rrdcached_unix_path', _('UNIX Socket path'), $attrsText);

$form->addElement('hidden', 'gopt_id');
$redirect = $form->addElement('hidden', 'o');
$redirect->setValue($o);
Expand Down
45 changes: 38 additions & 7 deletions www/include/common/javascript/centreon/brokerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ function clonifyTableFields(attributeName,displayName){
//table1.prepend(control);
firstPosition.after(newdiv);
}

}

// Finaly, we make each group of fields clonable (if not alreadyProcessed)
Expand Down Expand Up @@ -141,9 +140,41 @@ jQuery(function () {
});
});

/* Hooks for some fields */
// Hooks for some fields
var rrdArguments = {
// Hook on load tab
onLoad: function (element, argument) {
argument = window.JSON.parse(argument);
return function () {
var entry = element.name.match('(input|output)(\\[\\d\\])\\[(\\w*)\\]');
var option = entry.input;
var target = entry[1] + entry[2] + '[' + argument.target + ']';

if (document.querySelector('input[name="' + option + '"]:checked').value === 'disable') {
document.getElementsByName(target)[1].disabled = true;
}
}
},
// Hook on change the target
onChange: function (argument) {
return function (self) {
var entry = self.name.match('(input|output)(\\[\\d\\])\\[(\\w*)\\]');
var option = entry.input;
var target = entry[1] + entry[2] + '[' + argument.target + ']';

if (document.querySelector('input[name="' + option + '"]:checked').value === 'disable') {
document.getElementsByName(target)[1].value = '';
document.getElementsByName(target)[1].disabled = true;
} else {
document.getElementsByName(target)[1].disabled = false;
}
}
}
}

// Hooks for some fields
var luaArguments = {
/* Hook on load tab */
// Hook on load tab
onLoad: function (element, argument) {
argument = window.JSON.parse(argument);
return function () {
Expand All @@ -155,7 +186,7 @@ var luaArguments = {
luaArguments.changeInput(type, target)
}
},
/* Hook on change the target */
// Hook on change the target
onChange: function (argument) {
return function (self) {
var entry = self.name.match('(input|output)(\\[\\d\\])\\[(\\w*)\\]');
Expand All @@ -166,9 +197,9 @@ var luaArguments = {
luaArguments.changeInput(type,target)
}
},
/* Internal function for apply the input change */
// Internal function for apply the input change
changeInput: function (type, name) {
/* Get all attributes */
// Get all attributes
var attrs = {};
name = '[name="' + name + '"]:input';
jQuery.each(jQuery(name)[0].attributes, function (idx, attr) {
Expand All @@ -180,7 +211,7 @@ var luaArguments = {
var $elParent = jQuery(name).parent();
var value = jQuery(name).val();
jQuery(name).remove();
/* Find the good input for the type by default text => string */
// Find the good input for the type by default text => string
if (type === 'number') {
var newEl = jQuery('<input />')
.attr(attrs)
Expand Down
16 changes: 10 additions & 6 deletions www/install/insertBaseConf.sql
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@ INSERT INTO `cb_field` (`cb_field_id`, `fieldname`, `displayname`, `description`
(33, 'fifo', 'File for Centreon Broker statistics', 'File where Centreon Broker statistics will be stored', 'text', NULL),
(34, 'queries_per_transaction', 'Maximum queries per transaction', 'The maximum queries per transaction before commit.', 'int', NULL),
(35, 'read_timeout', 'Transaction commit timeout', 'The transaction timeout before running commit.', 'int', NULL),
(36, 'path', 'Unix socket', 'The Unix socket used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it.', 'text', 'T=options:C=value:CK=key:K=rrdcached_unix_path'),
(37, 'port', 'TCP port', 'The TCP port used to communicate with rrdcached. This is a global option, go to Administration > Options > RRDTool to modify it.', 'int', 'T=options:C=value:CK=key:K=rrdcached_port'),
(36, 'rrd_cached_option', 'Cache Option', 'Use RRD cache.', 'radio', NULL),
(37, 'rrd_cached', 'Cache Link', 'The Unix socket or the TCP port used to communicate with rrdcached.', 'text', NULL),
(38, 'max_size', 'Max file size in bytes', 'The maximum size of log file.', 'int', NULL),
(39, 'check_replication', 'Replication enabled', 'When enabled, the broker engine will check whether or not the replication is up to date before attempting to update data.', 'radio', NULL),
(40, 'rebuild_check_interval', 'Rebuild check interval in seconds', 'The interval between check if some metrics must be rebuild. The default value is 300s', 'int', NULL),
Expand Down Expand Up @@ -620,7 +620,8 @@ INSERT INTO `cb_list` (`cb_list_id`, `cb_field_id`, `default_value`) VALUES
(10, 62, 'false'),
(1, 63, 'yes'),
(1, 70, 'no'),
(11, 73, 'string');
(11, 73, 'string'),
(12, 36, 'disable');

--
-- Contenu de la table `cb_list_values`
Expand Down Expand Up @@ -658,7 +659,10 @@ INSERT INTO `cb_list_values` (`cb_list_id`, `value_name`, `value_value`) VALUES
(10, 'False', 'false'),
(11, 'String', 'string'),
(11, 'Number', 'number'),
(11, 'Password', 'password');
(11, 'Password', 'password'),
(12, 'Disable', 'disable'),
(12, 'TCP Port', 'tcp'),
(12, 'UNIX Socket', 'unix');

--
-- Contenu de la table `cb_module_relation`
Expand Down Expand Up @@ -726,7 +730,6 @@ INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required`
(11, 11, 1, 1),
(11, 12, 1, 2),
(11, 41, 0, 3),
(13, 36, 0, 4),
loiclau marked this conversation as resolved.
Show resolved Hide resolved
(13, 37, 0, 3),
(13, 13, 1, 1),
(13, 14, 1, 2),
Expand Down Expand Up @@ -843,7 +846,8 @@ INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required`
-- Contenu de la table `cb_type_field_relation`
--
INSERT INTO `cb_type_field_relation` (`cb_type_id`, `cb_field_id`, `is_required`, `order_display`, `jshook_name`, `jshook_arguments`) VALUES
(33, 73, 0, 5, 'luaArguments', '{"target": "lua_parameter__value_%d"}');
(33, 73, 0, 5, 'luaArguments', '{"target": "lua_parameter__value_%d"}'),
(13, 36, 0, 4, 'rrdArguments', '{"target": "rrd_cached"}');

--
-- Contenu de la table `widget_parameters_field_type`
Expand Down
Loading