mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
Added two new fields to agent/module report item. Ticket #4183
This commit is contained in:
parent
6baa765d75
commit
60c0ae7ada
@ -140,6 +140,7 @@ switch ($action) {
|
|||||||
case 'general':
|
case 'general':
|
||||||
case 'network_interfaces_report':
|
case 'network_interfaces_report':
|
||||||
case 'availability':
|
case 'availability':
|
||||||
|
case 'agent_module':
|
||||||
$get_data_editor = true;
|
$get_data_editor = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -514,8 +515,18 @@ switch ($action) {
|
|||||||
break;
|
break;
|
||||||
case 'agent_module':
|
case 'agent_module':
|
||||||
$description = $item['description'];
|
$description = $item['description'];
|
||||||
|
$es = json_decode($item['external_source'], true);
|
||||||
|
$agents_id = get_parameter('id_agents');
|
||||||
|
|
||||||
|
if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
|
||||||
|
$module = "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$module = $es['module'];
|
||||||
|
}
|
||||||
$group = $item['id_group'];
|
$group = $item['id_group'];
|
||||||
$modulegroup = $item ['id_module_group'];
|
$modulegroup = $item['id_module_group'];
|
||||||
|
$idAgentModule = $module;
|
||||||
break;
|
break;
|
||||||
case 'inventory':
|
case 'inventory':
|
||||||
$description = $item['description'];
|
$description = $item['description'];
|
||||||
@ -981,6 +992,39 @@ You can of course remove the warnings, that's why we include the source and do n
|
|||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr id="agents_row" style="" class="datos">
|
||||||
|
<td style="font-weight:bold;"><?php echo __('Agents'); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
$agents = agents_get_group_agents($group);
|
||||||
|
if ((empty($agents)) || $agents == -1) $agents = array();
|
||||||
|
|
||||||
|
$agents_select = array();
|
||||||
|
foreach ($id_agents as $id) {
|
||||||
|
foreach ($agents as $key => $a) {
|
||||||
|
if ($key == (int)$id) {
|
||||||
|
$agents_select[$key] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html_print_select($agents, 'id_agents[]', $agents_id, $script = '', "", 0, false, true, true, '', false, "min-width: 180px");
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr id="modules_row" style="" class="datos">
|
||||||
|
<td style="font-weight:bold;"><?php echo __('Modules'); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
$all_modules = array();
|
||||||
|
foreach ($module as $id_modul) {
|
||||||
|
$all_modules[] = modules_get_agentmodule_name($id_modul);
|
||||||
|
}
|
||||||
|
html_print_select($all_modules, 'module[]', $module, $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr id="row_agent_multi" style="" class="datos">
|
<tr id="row_agent_multi" style="" class="datos">
|
||||||
<td style="font-weight:bold;"><?php echo __('Agents'); ?></td>
|
<td style="font-weight:bold;"><?php echo __('Agents'); ?></td>
|
||||||
@ -1789,7 +1833,79 @@ ui_require_javascript_file ('pandora_inventory', ENTERPRISE_DIR.'/include/javasc
|
|||||||
$(document).ready (function () {
|
$(document).ready (function () {
|
||||||
chooseType();
|
chooseType();
|
||||||
chooseSQLquery();
|
chooseSQLquery();
|
||||||
|
|
||||||
|
$("#id_agents").change(agent_changed_by_multiple_agents);
|
||||||
|
|
||||||
|
$("#combo_group").change (
|
||||||
|
function () {
|
||||||
|
jQuery.post ("ajax.php",
|
||||||
|
{"page" : "operation/agentes/ver_agente",
|
||||||
|
"get_agents_group_json" : 1,
|
||||||
|
"id_group" : this.value,
|
||||||
|
"privilege" : "AW",
|
||||||
|
"keys_prefix" : "_"
|
||||||
|
},
|
||||||
|
function (data, status) {
|
||||||
|
$("#id_agents").html('');
|
||||||
|
jQuery.each (data, function (id, value) {
|
||||||
|
// Remove keys_prefix from the index
|
||||||
|
id = id.substring(1);
|
||||||
|
|
||||||
|
option = $("<option></option>")
|
||||||
|
.attr ("value", value["id_agente"])
|
||||||
|
.html (value["nombre"]);
|
||||||
|
$("#id_agents").append (option);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$("#combo_modulegroup").change (
|
||||||
|
function () {
|
||||||
|
jQuery.post ("ajax.php",
|
||||||
|
{"page" : "operation/agentes/ver_agente",
|
||||||
|
"get_modules_group_json" : 1,
|
||||||
|
"id_module_group" : this.value,
|
||||||
|
"id_agents" : $("#id_agents").val()
|
||||||
|
},
|
||||||
|
function (data, status) {
|
||||||
|
$("#module").html('');
|
||||||
|
jQuery.each (data, function (id, value) {
|
||||||
|
option = $("<option></option>")
|
||||||
|
.attr ("value", value["id_agente_modulo"])
|
||||||
|
.html (value["nombre"]);
|
||||||
|
$("#module").append (option);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$("#id_agents").change (
|
||||||
|
function () {
|
||||||
|
jQuery.post ("ajax.php",
|
||||||
|
{"page" : "operation/agentes/ver_agente",
|
||||||
|
"get_modules_group_json" : 1,
|
||||||
|
"id_module_group" : $("#combo_modulegroup").val(),
|
||||||
|
"id_agents" : $("#id_agents").val()
|
||||||
|
},
|
||||||
|
function (data, status) {
|
||||||
|
$("#module").html('');
|
||||||
|
jQuery.each (data, function (id, value) {
|
||||||
|
option = $("<option></option>")
|
||||||
|
.attr ("value", value["id_agente_modulo"])
|
||||||
|
.html (value["nombre"]);
|
||||||
|
$("#module").append (option);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$("#text-time_to, #text-time_from").timepicker({
|
$("#text-time_to, #text-time_from").timepicker({
|
||||||
showSecond: true,
|
showSecond: true,
|
||||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||||
@ -1817,7 +1933,6 @@ $(document).ready (function () {
|
|||||||
async: false,
|
async: false,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
console.log(data);
|
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
case 'sparse':
|
case 'sparse':
|
||||||
@ -1831,7 +1946,6 @@ $(document).ready (function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function create_custom_graph() {
|
function create_custom_graph() {
|
||||||
@ -2328,6 +2442,8 @@ function chooseType() {
|
|||||||
$("#row_last_value").hide();
|
$("#row_last_value").hide();
|
||||||
$("#row_filter_search").hide();
|
$("#row_filter_search").hide();
|
||||||
$("#row_percentil").hide();
|
$("#row_percentil").hide();
|
||||||
|
$("#agents_row").hide();
|
||||||
|
$("#modules_row").hide();
|
||||||
|
|
||||||
// SLA list default state
|
// SLA list default state
|
||||||
$("#sla_list").hide();
|
$("#sla_list").hide();
|
||||||
@ -2717,6 +2833,8 @@ function chooseType() {
|
|||||||
$("#row_description").show();
|
$("#row_description").show();
|
||||||
$("#row_group").show();
|
$("#row_group").show();
|
||||||
$("#row_module_group").show();
|
$("#row_module_group").show();
|
||||||
|
$("#agents_row").show();
|
||||||
|
$("#modules_row").show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'inventory_changes':
|
case 'inventory_changes':
|
||||||
|
@ -944,6 +944,12 @@ switch ($action) {
|
|||||||
$values['text'] = get_parameter('text');
|
$values['text'] = get_parameter('text');
|
||||||
$values['show_graph'] = get_parameter('combo_graph_options');
|
$values['show_graph'] = get_parameter('combo_graph_options');
|
||||||
|
|
||||||
|
$good_format = true;
|
||||||
|
break;
|
||||||
|
case 'agent_module':
|
||||||
|
$es['id_agents'] = get_parameter('id_agents');
|
||||||
|
$es['module'] = get_parameter('module', "");
|
||||||
|
$values['external_source'] = json_encode($es);
|
||||||
$good_format = true;
|
$good_format = true;
|
||||||
break;
|
break;
|
||||||
case 'inventory':
|
case 'inventory':
|
||||||
@ -1259,6 +1265,12 @@ switch ($action) {
|
|||||||
$values['external_source'] = json_encode($es);
|
$values['external_source'] = json_encode($es);
|
||||||
$good_format = true;
|
$good_format = true;
|
||||||
break;
|
break;
|
||||||
|
case 'agent_module':
|
||||||
|
$es['id_agents'] = get_parameter('id_agents');
|
||||||
|
$es['module'] = get_parameter('module', "");
|
||||||
|
$values['external_source'] = json_encode($es);
|
||||||
|
$good_format = true;
|
||||||
|
break;
|
||||||
case 'inventory_changes':
|
case 'inventory_changes':
|
||||||
$values['period'] = get_parameter('period');
|
$values['period'] = get_parameter('period');
|
||||||
$es['id_agents'] = get_parameter('id_agents');
|
$es['id_agents'] = get_parameter('id_agents');
|
||||||
|
@ -1505,13 +1505,15 @@ function reporting_inventory($report, $content, $type) {
|
|||||||
|
|
||||||
function reporting_agent_module($report, $content) {
|
function reporting_agent_module($report, $content) {
|
||||||
global $config;
|
global $config;
|
||||||
|
$agents_and_modules = json_decode($content['external_source'], true);
|
||||||
|
$agents = array();
|
||||||
|
$agents = $agents_and_modules['id_agents'];
|
||||||
|
$modules = $agents_and_modules['module'];
|
||||||
$id_group = $content['id_group'];
|
$id_group = $content['id_group'];
|
||||||
$id_module_group = $content['id_module_group'];
|
$id_module_group = $content['id_module_group'];
|
||||||
|
|
||||||
$return['type'] = 'agent_module';
|
$return['type'] = 'agent_module';
|
||||||
|
|
||||||
|
|
||||||
if (empty($content['name'])) {
|
if (empty($content['name'])) {
|
||||||
$content['name'] = __('Agent/Modules');
|
$content['name'] = __('Agent/Modules');
|
||||||
}
|
}
|
||||||
@ -1532,54 +1534,25 @@ function reporting_agent_module($report, $content) {
|
|||||||
|
|
||||||
$return["data"] = array();
|
$return["data"] = array();
|
||||||
|
|
||||||
$agents = array();
|
|
||||||
if ($id_group > 0) {
|
|
||||||
$agents = agents_get_group_agents($id_group);
|
|
||||||
$agents = array_keys($agents);
|
|
||||||
}
|
|
||||||
|
|
||||||
$filter_module_groups = false;
|
|
||||||
if ($id_module_group > 0) {
|
|
||||||
$filter_module_groups['id_module_group'] = $id_module_group;
|
|
||||||
}
|
|
||||||
|
|
||||||
$all_modules = agents_get_modules($agents, false,
|
|
||||||
$filter_module_groups, true, false);
|
|
||||||
|
|
||||||
$modules_by_name = array();
|
$modules_by_name = array();
|
||||||
$name = '';
|
|
||||||
$cont = 0;
|
$cont = 0;
|
||||||
|
|
||||||
foreach ($all_modules as $key => $module) {
|
foreach ($modules as $modul_id) {
|
||||||
if ($module == $name) {
|
$modules_by_name[$cont]['name'] = io_safe_output(modules_get_agentmodule_name($modul_id));
|
||||||
$modules_by_name[$cont - 1]['id'][] = $key;
|
$modules_by_name[$cont]['id'][] = $modul_id;
|
||||||
}
|
$cont ++;
|
||||||
else {
|
|
||||||
$name = $module;
|
|
||||||
$modules_by_name[$cont]['name'] = $name;
|
|
||||||
$modules_by_name[$cont]['id'][] = $key;
|
|
||||||
$cont ++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ($modules_by_name == false || $agents == false) {
|
||||||
$filter_groups = array();
|
|
||||||
if ($id_group > 0) {
|
|
||||||
$filter_groups['id_grupo'] = $id_group;
|
|
||||||
}
|
|
||||||
$agents = agents_get_agents ($filter_groups);
|
|
||||||
$nagents = count($agents);
|
|
||||||
|
|
||||||
if ($all_modules == false || $agents == false) {
|
|
||||||
$return['failed'] = __('There are no agents with modules');
|
$return['failed'] = __('There are no agents with modules');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach ($agents as $agent) {
|
foreach ($agents as $agent) {
|
||||||
$row = array();
|
$row = array();
|
||||||
$row['agent_status'][$agent['id_agente']] =
|
$row['agent_status'][$agent] =
|
||||||
agents_get_status($agent['id_agente']);
|
agents_get_status($agent);
|
||||||
$row['agent_name'] = $agent['nombre'];
|
$row['agent_name'] = agents_get_name($agent);
|
||||||
|
|
||||||
$agent_modules = agents_get_modules($agent['id_agente']);
|
$agent_modules = agents_get_modules($agent);
|
||||||
|
|
||||||
$row['modules'] = array();
|
$row['modules'] = array();
|
||||||
foreach ($modules_by_name as $module) {
|
foreach ($modules_by_name as $module) {
|
||||||
|
@ -35,6 +35,7 @@ if (is_ajax ()) {
|
|||||||
$get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json');
|
$get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json');
|
||||||
$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_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");
|
||||||
$get_agents_json_for_multiple_modules = (bool) get_parameter("get_agents_json_for_multiple_modules");
|
$get_agents_json_for_multiple_modules = (bool) get_parameter("get_agents_json_for_multiple_modules");
|
||||||
@ -104,10 +105,14 @@ if (is_ajax ()) {
|
|||||||
$agents = db_get_all_rows_filter('tagente', $filter, $fields);
|
$agents = db_get_all_rows_filter('tagente', $filter, $fields);
|
||||||
if (empty($agents)) $agents = array();
|
if (empty($agents)) $agents = array();
|
||||||
|
|
||||||
|
foreach ($agents as $k => $v) {
|
||||||
|
$agents[$k] = io_safe_output($v);
|
||||||
|
}
|
||||||
|
|
||||||
// Add keys prefix
|
// Add keys prefix
|
||||||
if ($keys_prefix !== '') {
|
if ($keys_prefix !== '') {
|
||||||
foreach ($agents as $k => $v) {
|
foreach ($agents as $k => $v) {
|
||||||
$agents[$keys_prefix . $k] = $v;
|
$agents[$keys_prefix . $k] = io_safe_output($v);
|
||||||
unset($agents[$k]);
|
unset($agents[$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,6 +120,34 @@ if (is_ajax ()) {
|
|||||||
echo json_encode($agents);
|
echo json_encode($agents);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($get_modules_group_json) {
|
||||||
|
$id_group = (int) get_parameter('id_module_group');
|
||||||
|
$id_agents = get_parameter('id_agents');
|
||||||
|
|
||||||
|
$agents = implode(",", $id_agents);
|
||||||
|
|
||||||
|
$filter_group = "";
|
||||||
|
$filter_agent = "";
|
||||||
|
|
||||||
|
if ($id_group != 0) {
|
||||||
|
$filter_group = " AND id_module_group = ". $id_group;
|
||||||
|
}
|
||||||
|
if ($agents != null) {
|
||||||
|
$filter_agent = " AND id_agente IN (" . $agents . ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
$modules = db_get_all_rows_sql("SELECT nombre, id_agente_modulo FROM tagente_modulo WHERE 1 = 1" . $filter_agent . $filter_group);
|
||||||
|
|
||||||
|
if (empty($modules)) $modules = array();
|
||||||
|
|
||||||
|
foreach ($modules as $k => $v) {
|
||||||
|
$modules[$k] = io_safe_output($v);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($modules);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($get_agent_json) {
|
if ($get_agent_json) {
|
||||||
$id_agent = (int) get_parameter ('id_agent');
|
$id_agent = (int) get_parameter ('id_agent');
|
||||||
@ -135,7 +168,7 @@ if (is_ajax ()) {
|
|||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$return[$module['id_agente_modulo']] = $module['nombre'];
|
$return[$module['id_agente_modulo']] = io_safe_output($module['nombre']);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($return);
|
echo json_encode($return);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user