mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Merge remote-tracking branch 'origin/develop' into ent-7074-Command-Center
This commit is contained in:
commit
760522aeff
@ -12,20 +12,19 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
global $config;
|
global $config;
|
||||||
global $agent_w;
|
|
||||||
|
|
||||||
check_login();
|
check_login();
|
||||||
ui_require_css_file('first_task');
|
ui_require_css_file('first_task');
|
||||||
?>
|
?>
|
||||||
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no services defined yet.') ]); ?>
|
<?php ui_print_info_message(['no_close' => true, 'message' => __('There are no services defined yet.') ]); ?>
|
||||||
|
<?php if ((bool) $agent_w === true) { ?>
|
||||||
<?php if ($agent_w) { ?>
|
|
||||||
<div class="new_task">
|
<div class="new_task">
|
||||||
<div class="image_task">
|
<div class="image_task">
|
||||||
<?php echo html_print_image('images/first_task/icono_grande_servicios.png', true, ['title' => __('Services')]); ?>
|
<?php echo html_print_image('images/first_task/icono_grande_servicios.png', true, ['title' => __('Services')]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="text_task">
|
<div class="text_task">
|
||||||
<h3> <?php echo __('Create Services'); ?></h3><p id="description_task">
|
<h3> <?php echo __('Create Services'); ?></h3>
|
||||||
|
<p id="description_task">
|
||||||
<?php
|
<?php
|
||||||
echo __(
|
echo __(
|
||||||
"A service is a way to group your IT resources based on their functionalities.
|
"A service is a way to group your IT resources based on their functionalities.
|
||||||
@ -36,8 +35,7 @@ ui_require_css_file('first_task');
|
|||||||
His company consists of three big departments: A management, an on-line shop and support."
|
His company consists of three big departments: A management, an on-line shop and support."
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form action="index.php?sec=estado&sec2=enterprise/godmode/services/services.service&action=new_service" method="post">
|
<form action="index.php?sec=estado&sec2=enterprise/godmode/services/services.service&action=new_service" method="post">
|
||||||
<input type="submit" class="button_task" value="<?php echo __('Create Services'); ?>" />
|
<input type="submit" class="button_task" value="<?php echo __('Create Services'); ?>" />
|
||||||
</form>
|
</form>
|
||||||
|
@ -764,19 +764,23 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($value)) {
|
if ($value === null) {
|
||||||
$query .= sprintf('%s IS NULL', $field);
|
$not = (($negative === true) ? 'NOT' : '');
|
||||||
|
$query .= sprintf('%s IS %s NULL', $field, $negative);
|
||||||
} else if (is_int($value) || is_bool($value)) {
|
} else if (is_int($value) || is_bool($value)) {
|
||||||
$query .= sprintf('%s = %d', $field, $value);
|
$not = (($negative === true) ? '!' : '');
|
||||||
|
$query .= sprintf('%s %s= %d', $field, $not, $value);
|
||||||
} else if (is_float($value) || is_double($value)) {
|
} else if (is_float($value) || is_double($value)) {
|
||||||
$query .= sprintf('%s = %f', $field, $value);
|
$not = (($negative === true) ? ' !' : '');
|
||||||
|
$query .= sprintf('%s %s= %f', $field, $not, $value);
|
||||||
} else if (is_array($value)) {
|
} else if (is_array($value)) {
|
||||||
$not = $negative ? ' NOT ' : '';
|
$not = (($negative === true) ? 'NOT' : '');
|
||||||
$query .= sprintf('%s %sIN ("%s")', $field, $not, implode('", "', $value));
|
$query .= sprintf('%s %s IN ("%s")', $field, $not, implode('", "', $value));
|
||||||
} else {
|
} else {
|
||||||
if ($value === '') {
|
if ($value === '') {
|
||||||
// Search empty string
|
// Search empty string.
|
||||||
$query .= sprintf("%s = ''", $field);
|
$not = (($negative === true) ? '!' : '');
|
||||||
|
$query .= sprintf("%s %s= ''", $field, $not);
|
||||||
} else if ($value[0] == '>') {
|
} else if ($value[0] == '>') {
|
||||||
$value = substr($value, 1, (strlen($value) - 1));
|
$value = substr($value, 1, (strlen($value) - 1));
|
||||||
$query .= sprintf("%s > '%s'", $field, $value);
|
$query .= sprintf("%s > '%s'", $field, $value);
|
||||||
@ -789,9 +793,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||||||
$query .= sprintf("%s < '%s'", $field, $value);
|
$query .= sprintf("%s < '%s'", $field, $value);
|
||||||
}
|
}
|
||||||
} else if ($value[0] == '%') {
|
} else if ($value[0] == '%') {
|
||||||
$query .= sprintf("%s LIKE '%s'", $field, $value);
|
$not = (($negative === true) ? ' NOT ' : '');
|
||||||
|
$query .= sprintf("%s %s LIKE '%s'", $field, $not, $value);
|
||||||
} else {
|
} else {
|
||||||
$query .= sprintf("%s = '%s'", $field, $value);
|
$not = (($negative === true) ? '!' : '');
|
||||||
|
$query .= sprintf("%s %s= '%s'", $field, $not, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1552,9 +1552,14 @@ function enterprise_hook($function_name, $parameters=false)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Document enterprise functions
|
* Include an enterprise file.
|
||||||
|
*
|
||||||
|
* @param string $filename Enterprise file to be included.
|
||||||
|
* @param array $variables Variables to be exported, as [varname => value].
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function enterprise_include($filename)
|
function enterprise_include($filename, $variables=[])
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -1576,6 +1581,10 @@ function enterprise_include($filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($filepath)) {
|
if (file_exists($filepath)) {
|
||||||
|
if (is_array($variables) === true) {
|
||||||
|
extract($variables);
|
||||||
|
}
|
||||||
|
|
||||||
include $filepath;
|
include $filepath;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1587,11 +1596,12 @@ function enterprise_include($filename)
|
|||||||
/**
|
/**
|
||||||
* Includes a file from enterprise section.
|
* Includes a file from enterprise section.
|
||||||
*
|
*
|
||||||
* @param string $filename Target file.
|
* @param string $filename Enterprise file to be included.
|
||||||
|
* @param array $variables Variables to be exported, as [varname => value].
|
||||||
*
|
*
|
||||||
* @return mixed Result code.
|
* @return mixed Result code.
|
||||||
*/
|
*/
|
||||||
function enterprise_include_once($filename)
|
function enterprise_include_once($filename, $variables=[])
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -1613,6 +1623,10 @@ function enterprise_include_once($filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($filepath)) {
|
if (file_exists($filepath)) {
|
||||||
|
if (is_array($variables) === true) {
|
||||||
|
extract($variables);
|
||||||
|
}
|
||||||
|
|
||||||
include_once $filepath;
|
include_once $filepath;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -915,7 +915,25 @@ function html_print_select(
|
|||||||
ui_require_javascript_file('select2.min');
|
ui_require_javascript_file('select2.min');
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= '<script>$("#'.$id.'").select2();</script>';
|
$output .= '<script type="text/javascript">';
|
||||||
|
$output .= '$("#'.$id.'").select2();';
|
||||||
|
|
||||||
|
if ($required !== false) {
|
||||||
|
$require_message = __('Please select an item from this list.');
|
||||||
|
$output .= '$("#'.$id.'").on("change", function(e) {
|
||||||
|
e.currentTarget.setCustomValidity("");
|
||||||
|
});';
|
||||||
|
|
||||||
|
$output .= '$("#'.$id.'").on("invalid", function(e) {
|
||||||
|
if ($(e.currentTarget).val() == null) {
|
||||||
|
e.currentTarget.setCustomValidity(
|
||||||
|
"'.$require_message.'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
@ -1331,8 +1349,14 @@ function html_print_select_multiple_modules_filtered(array $data):string
|
|||||||
'include/javascript/',
|
'include/javascript/',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
ui_require_css_file(
|
||||||
|
'multiselect_filtered',
|
||||||
|
'include/styles/',
|
||||||
|
true
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
ui_require_javascript_file('multiselect_filtered');
|
ui_require_javascript_file('multiselect_filtered');
|
||||||
|
ui_require_css_file('multiselect_filtered');
|
||||||
}
|
}
|
||||||
|
|
||||||
$uniqId = $data['uniqId'];
|
$uniqId = $data['uniqId'];
|
||||||
@ -1417,7 +1441,7 @@ function html_print_select_multiple_modules_filtered(array $data):string
|
|||||||
// Force_serialized.
|
// Force_serialized.
|
||||||
false,
|
false,
|
||||||
// Meta_fields.
|
// Meta_fields.
|
||||||
$data['mMetaFields']
|
($data['mMetaFields'] ?? is_metaconsole())
|
||||||
);
|
);
|
||||||
|
|
||||||
if ((empty($agents)) === true || $agents == -1) {
|
if ((empty($agents)) === true || $agents == -1) {
|
||||||
@ -1464,12 +1488,16 @@ function html_print_select_multiple_modules_filtered(array $data):string
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$all_modules = select_modules_for_agent_group(
|
if ($data['mAgents'] !== null) {
|
||||||
$data['mModuleGroup'],
|
$all_modules = select_modules_for_agent_group(
|
||||||
explode(',', $data['mAgents']),
|
$data['mModuleGroup'],
|
||||||
$data['mShowCommonModules'],
|
explode(',', $data['mAgents']),
|
||||||
false
|
$data['mShowCommonModules'],
|
||||||
);
|
false
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$all_modules = [];
|
||||||
|
}
|
||||||
|
|
||||||
if ($data['mShowSelectedOtherGroups']) {
|
if ($data['mShowSelectedOtherGroups']) {
|
||||||
$selected_modules_ids = explode(',', $data['mModules']);
|
$selected_modules_ids = explode(',', $data['mModules']);
|
||||||
|
@ -217,7 +217,12 @@ function fmModuleChange(uniqId) {
|
|||||||
if (data) {
|
if (data) {
|
||||||
jQuery.each(data, function(id, value) {
|
jQuery.each(data, function(id, value) {
|
||||||
var option = $("<option></option>")
|
var option = $("<option></option>")
|
||||||
.attr("value", value["id_agente_modulo"])
|
.attr(
|
||||||
|
"value",
|
||||||
|
value["id_node"]
|
||||||
|
? value["id_node"] + "|" + value["id_agente_modulo"]
|
||||||
|
: value["id_agente_modulo"]
|
||||||
|
)
|
||||||
.html(value["nombre"]);
|
.html(value["nombre"]);
|
||||||
$("#filtered-module-modules-" + uniqId).append(option);
|
$("#filtered-module-modules-" + uniqId).append(option);
|
||||||
});
|
});
|
||||||
|
@ -388,7 +388,7 @@ function initialiceLayout(data) {
|
|||||||
dashboardId: data.dashboardId,
|
dashboardId: data.dashboardId,
|
||||||
widgetId: widgetId
|
widgetId: widgetId
|
||||||
},
|
},
|
||||||
width: widgetId == 14 ? 750 : 450,
|
width: widgetId == 14 || widgetId == 2 ? 750 : 450,
|
||||||
maxHeight: 600,
|
maxHeight: 600,
|
||||||
minHeight: 400
|
minHeight: 400
|
||||||
},
|
},
|
||||||
|
@ -219,8 +219,19 @@ class Agent extends Entity
|
|||||||
|
|
||||||
if ($rs === false) {
|
if ($rs === false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
$error = $config['dbconnection']->error;
|
||||||
|
if (empty($error) === true) {
|
||||||
|
if (empty($updates['intervalo']) === true) {
|
||||||
|
$error = 'Missing agent interval';
|
||||||
|
} else if (empty($updates['id_group']) === true) {
|
||||||
|
$error = 'Missing id_group';
|
||||||
|
} else if (empty($updates['id_group']) === true) {
|
||||||
|
$error = 'Missing id_group';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new \Exception(
|
throw new \Exception(
|
||||||
__METHOD__.' error: '.$config['dbconnection']->error
|
__METHOD__.' error: '.$error
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ use PandoraFMS\Module;
|
|||||||
*/
|
*/
|
||||||
class AgentModuleWidget extends Widget
|
class AgentModuleWidget extends Widget
|
||||||
{
|
{
|
||||||
|
const MODULE_SEPARATOR = '|-|-|-|';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name widget.
|
* Name widget.
|
||||||
@ -299,10 +300,33 @@ class AgentModuleWidget extends Widget
|
|||||||
$values['mShowCommonModules'] = \get_parameter(
|
$values['mShowCommonModules'] = \get_parameter(
|
||||||
'filtered-module-show-common-modules-'.$this->cellId
|
'filtered-module-show-common-modules-'.$this->cellId
|
||||||
);
|
);
|
||||||
$values['mModules'] = \get_parameter(
|
$values['mModules'] = explode(
|
||||||
'filtered-module-modules-'.$this->cellId
|
',',
|
||||||
|
\get_parameter(
|
||||||
|
'filtered-module-modules-'.$this->cellId
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$values['mModules'] = implode(
|
||||||
|
self::MODULE_SEPARATOR,
|
||||||
|
array_reduce(
|
||||||
|
$values['mModules'],
|
||||||
|
function ($carry, $item) {
|
||||||
|
$d = explode('|', $item);
|
||||||
|
if (isset($d[1]) === true) {
|
||||||
|
$carry[] = $d[1];
|
||||||
|
} else {
|
||||||
|
$carry[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $carry;
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,15 +636,34 @@ class AgentModuleWidget extends Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract info all modules selected.
|
// Extract info all modules selected.
|
||||||
$target_modules = explode(',', $this->values['mModules']);
|
$target_modules = explode(
|
||||||
$all_modules = Module::search(
|
self::MODULE_SEPARATOR,
|
||||||
['id_agente_modulo' => $target_modules]
|
$this->values['mModules']
|
||||||
);
|
);
|
||||||
|
if (is_metaconsole() === true
|
||||||
|
&& $this->values['mShowCommonModules'] === '0'
|
||||||
|
) {
|
||||||
|
$all_modules = $target_modules;
|
||||||
|
} else {
|
||||||
|
$all_modules = Module::search(
|
||||||
|
['id_agente_modulo' => $target_modules]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($all_modules !== null) {
|
if ($all_modules !== null) {
|
||||||
$reduceAllModules = array_reduce(
|
$reduceAllModules = array_reduce(
|
||||||
$all_modules,
|
$all_modules,
|
||||||
function ($carry, $item) {
|
function ($carry, $item) {
|
||||||
$carry[$item->name()] = null;
|
if ($item === null) {
|
||||||
|
return $carry;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_object($item) === true) {
|
||||||
|
$carry[$item->name()] = null;
|
||||||
|
} else {
|
||||||
|
$carry[$item] = null;
|
||||||
|
}
|
||||||
|
|
||||||
return $carry;
|
return $carry;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -653,12 +696,24 @@ class AgentModuleWidget extends Widget
|
|||||||
$visualData[$agent_id]['agent_name'] = $agent->name();
|
$visualData[$agent_id]['agent_name'] = $agent->name();
|
||||||
$visualData[$agent_id]['agent_alias'] = $agent->alias();
|
$visualData[$agent_id]['agent_alias'] = $agent->alias();
|
||||||
|
|
||||||
$modules = $agent->searchModules(
|
if (is_metaconsole() === true
|
||||||
['id_agente_modulo' => $target_modules]
|
&& $this->values['mShowCommonModules'] === '1'
|
||||||
);
|
) {
|
||||||
|
$modules = $agent->searchModules(
|
||||||
|
['id_agente_modulo' => $target_modules]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$modules = $agent->searchModules(
|
||||||
|
['nombre' => array_keys($reduceAllModules)]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$visualData[$agent_id]['modules'] = $reduceAllModules;
|
$visualData[$agent_id]['modules'] = $reduceAllModules;
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
|
if ($module === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((bool) is_metaconsole() === true) {
|
if ((bool) is_metaconsole() === true) {
|
||||||
$reduceAllModules[$module->name()] = null;
|
$reduceAllModules[$module->name()] = null;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ class Module extends Entity
|
|||||||
* @param array $params Search parameters (fields from tagente_modulo).
|
* @param array $params Search parameters (fields from tagente_modulo).
|
||||||
* @param integer $limit Limit results to N rows.
|
* @param integer $limit Limit results to N rows.
|
||||||
*
|
*
|
||||||
* @return array|null of PandoraFMS\Module found or null if not found.
|
* @return object|array|null PandoraFMS\Module found if limited, array of Modules
|
||||||
|
* or null if not found.
|
||||||
* @throws \Exception On error.
|
* @throws \Exception On error.
|
||||||
*/
|
*/
|
||||||
public static function search(
|
public static function search(
|
||||||
@ -160,13 +161,24 @@ class Module extends Entity
|
|||||||
$obj->{$k}($v);
|
$obj->{$k}($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($obj->nombre() === 'delete_pending') {
|
if ($obj->nombre() === 'delete_pending'
|
||||||
|
|| $obj->nombre() === 'pendingdelete'
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Customize certain fields.
|
// Customize certain fields.
|
||||||
$obj->status = new ModuleStatus($obj->id_agente_modulo());
|
try {
|
||||||
$obj->moduleType = new ModuleType($obj->id_tipo_modulo());
|
$obj->status = new ModuleStatus($obj->id_agente_modulo());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$obj->status = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$obj->moduleType = new ModuleType($obj->id_tipo_modulo());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$obj->moduleType = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Include some enterprise dependencies.
|
// Include some enterprise dependencies.
|
||||||
enterprise_include_once('include/functions_config_agents.php');
|
enterprise_include_once('include/functions_config_agents.php');
|
||||||
|
@ -133,6 +133,7 @@ div.target {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
div.target.flex {
|
div.target.flex {
|
||||||
border: 2px dashed #ddd;
|
border: 2px dashed #ddd;
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
div#page {
|
div#page {
|
||||||
width: auto;
|
width: auto;
|
||||||
|
}
|
||||||
|
li#select_multiple_modules_filtered {
|
||||||
|
width: 650px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.networkconsole {
|
.networkconsole {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.networkconsole svg {
|
.networkconsole svg {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
@ -22,11 +23,9 @@ div#page {
|
|||||||
right: 50px;
|
right: 50px;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-dashboard-width {
|
.select-dashboard-width {
|
||||||
width: 110%;
|
width: 110%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#menu_tab li.nomn form#form-select-dashboard {
|
#menu_tab li.nomn form#form-select-dashboard {
|
||||||
margin-top: 0px !important;
|
margin-top: 0px !important;
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,20 @@ ul.wizard.inline li {
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.wizard li > label:not(.p-switch) {
|
ul.wizard li > label:not(.p-switch):first-of-type {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.wizard li > label:not(.p-switch):not(:first-of-type) {
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2.select2-container {
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
ul.wizard li > textarea {
|
ul.wizard li > textarea {
|
||||||
width: 600px;
|
width: 600px;
|
||||||
height: 15em;
|
height: 15em;
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
require_once 'include/functions_gis.php';
|
require_once 'include/functions_gis.php';
|
||||||
@ -48,6 +50,7 @@ if (is_ajax()) {
|
|||||||
$get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip');
|
$get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip');
|
||||||
$get_agents_group_json = (bool) get_parameter('get_agents_group_json');
|
$get_agents_group_json = (bool) get_parameter('get_agents_group_json');
|
||||||
$get_modules_group_json = (bool) get_parameter('get_modules_group_json');
|
$get_modules_group_json = (bool) get_parameter('get_modules_group_json');
|
||||||
|
$filter_modules_group_json = (bool) get_parameter('filter_modules_group_json');
|
||||||
$get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json');
|
$get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json');
|
||||||
$get_agent_modules_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_json_for_multiple_agents');
|
$get_agent_modules_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_json_for_multiple_agents');
|
||||||
$get_agent_modules_alerts_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_alerts_json_for_multiple_agents');
|
$get_agent_modules_alerts_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_alerts_json_for_multiple_agents');
|
||||||
@ -191,9 +194,14 @@ if (is_ajax()) {
|
|||||||
|
|
||||||
if ($get_modules_group_json) {
|
if ($get_modules_group_json) {
|
||||||
$id_group = (int) get_parameter('id_module_group', 0);
|
$id_group = (int) get_parameter('id_module_group', 0);
|
||||||
$id_agents = get_parameter('id_agents');
|
$id_agents = get_parameter('id_agents', null);
|
||||||
$selection = get_parameter('selection');
|
$selection = get_parameter('selection');
|
||||||
|
|
||||||
|
if ($id_agents === null) {
|
||||||
|
echo '[]';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((bool) is_metaconsole() === true) {
|
if ((bool) is_metaconsole() === true) {
|
||||||
if (count($id_agents) > 0) {
|
if (count($id_agents) > 0) {
|
||||||
$rows = db_get_all_rows_sql(
|
$rows = db_get_all_rows_sql(
|
||||||
@ -255,26 +263,49 @@ if (is_ajax()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$modules = [];
|
$modules = [];
|
||||||
$i = 1;
|
|
||||||
foreach ($final_modules as $module_name => $occurrences) {
|
foreach ($final_modules as $module_name => $occurrences) {
|
||||||
if ($occurrences === $nodes_consulted) {
|
if ($occurrences === $nodes_consulted) {
|
||||||
// Module already present in ALL nodes.
|
// Module already present in ALL nodes.
|
||||||
$modules[] = [
|
$modules[] = [
|
||||||
'id_agente_modulo' => ($i++),
|
'id_agente_modulo' => $module_name,
|
||||||
'nombre' => $module_name,
|
'nombre' => $module_name,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// All modules.
|
// All modules.
|
||||||
$modules = array_reduce(
|
$return = [];
|
||||||
$modules[$tserver],
|
$nodes = [];
|
||||||
function ($carry, $item) {
|
foreach ($agents as $tserver => $id_agents) {
|
||||||
$carry[] = $item;
|
try {
|
||||||
return $carry;
|
$nodes[$tserver] = new Node($tserver);
|
||||||
},
|
} catch (Exception $e) {
|
||||||
[]
|
hd($e);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
$return = array_reduce(
|
||||||
|
$modules[$tserver],
|
||||||
|
function ($carry, $item) use ($tserver, $nodes) {
|
||||||
|
$t = [];
|
||||||
|
foreach ($item as $k => $v) {
|
||||||
|
$t[$k] = $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
$t['id_node'] = $tserver;
|
||||||
|
if ($nodes[$tserver] !== null) {
|
||||||
|
$t['nombre'] = io_safe_output(
|
||||||
|
$nodes[$tserver]->server_name().' » '.$t['nombre']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$carry[] = $t;
|
||||||
|
return $carry;
|
||||||
|
},
|
||||||
|
$return
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$modules = $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($modules);
|
echo json_encode($modules);
|
||||||
@ -283,6 +314,103 @@ if (is_ajax()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($filter_modules_group_json) {
|
||||||
|
$modules = (array) get_parameter('modules', []);
|
||||||
|
$existing_modules = [];
|
||||||
|
|
||||||
|
$avoid_duplicates = [];
|
||||||
|
foreach ($modules as $def) {
|
||||||
|
$data = explode('|', $def);
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$id_node = (int) $data[0];
|
||||||
|
$id_agent = db_get_value(
|
||||||
|
'id_tagente',
|
||||||
|
'tmetaconsole_agent',
|
||||||
|
'id_agente',
|
||||||
|
(int) $data[1]
|
||||||
|
);
|
||||||
|
|
||||||
|
$mod = explode(' » ', $data[2]);
|
||||||
|
$module_name = $mod[1];
|
||||||
|
if (empty($module_name) === true) {
|
||||||
|
// Common modules.
|
||||||
|
$id_agent = db_get_value(
|
||||||
|
'id_tagente',
|
||||||
|
'tmetaconsole_agent',
|
||||||
|
'id_agente',
|
||||||
|
(int) $data[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
$id_node = db_get_value(
|
||||||
|
'id_tmetaconsole_setup',
|
||||||
|
'tmetaconsole_agent',
|
||||||
|
'id_agente',
|
||||||
|
(int) $data[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
$module_name = $data[1];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$id_agent = $data[0];
|
||||||
|
$module_name = $data[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id_agent === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$node = new Node($id_node);
|
||||||
|
$node->connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
$module = PandoraFMS\Module::search(
|
||||||
|
[
|
||||||
|
'id_agente' => $id_agent,
|
||||||
|
'nombre' => $module_name,
|
||||||
|
],
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($module !== null) {
|
||||||
|
$text = '';
|
||||||
|
$id = '';
|
||||||
|
if ($node !== null) {
|
||||||
|
$text = $node->server_name().' » ';
|
||||||
|
$id = $node->id().'|';
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= $module->agent()->alias().' » '.$module->nombre();
|
||||||
|
|
||||||
|
$id .= $module->id_agente_modulo();
|
||||||
|
if ($avoid_duplicates[$id] === 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$avoid_duplicates[$id] = 1;
|
||||||
|
$existing_modules[] = [
|
||||||
|
'id' => $id,
|
||||||
|
'text' => io_safe_output($text),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (is_metaconsole() === true) {
|
||||||
|
$node->disconnect();
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if ($node !== null) {
|
||||||
|
$node->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($existing_modules);
|
||||||
|
}
|
||||||
|
|
||||||
if ($get_modules_group_value_name_json) {
|
if ($get_modules_group_value_name_json) {
|
||||||
$id_agents = get_parameter('id_agents');
|
$id_agents = get_parameter('id_agents');
|
||||||
$selection = get_parameter('selection');
|
$selection = get_parameter('selection');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user