Changed agent name

This commit is contained in:
Daniel Maya 2016-10-03 12:24:15 +02:00
parent b196d5e3d5
commit 370f7ff373
9 changed files with 49 additions and 25 deletions

View File

@ -95,12 +95,12 @@ function output_xml_report($id) {
echo "<description>" . io_safe_output($item['description']) . "</description>\n";
echo "<period>" . io_safe_output($item['period']) . "</period>\n";
if ($item['id_agent'] != 0) {
$agent = agents_get_name($item['id_agent']);
$agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
}
if ($item['id_agent_module'] != 0) {
$module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']);
$id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']);
$agent = agents_get_name($item['id_agent']);
$agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n";
}
@ -138,7 +138,7 @@ function output_xml_report($id) {
foreach ($slas as $sla) {
$module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']);
$id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']);
$agent = agents_get_name($item['id_agent']);
$agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
echo "<sla>";
echo "<agent><![CDATA[" . $agent . "]]></agent>\n";
echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n";
@ -243,8 +243,14 @@ function output_xml_visual_console($id) {
foreach ($items as $item) {
echo "<item>\n";
echo "<other_id>" . $item['id'] . "</other_id>\n"; //OLD ID USE FOR parent item
$agent = '';
if ($item['id_agent'] != 0) {
$agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
}
if (!empty($item['label'])) {
echo "<label><![CDATA[" . io_safe_output($item['label']) . "]]></label>\n";
$aux = explode("-",$item['label']);
$label = $agent .' -'. $aux[1];
echo "<label><![CDATA[" . io_safe_output($label) . "]]></label>\n";
}
echo "<x>" . $item['pos_x'] . "</x>\n";
echo "<y>" . $item['pos_y'] . "</y>\n";
@ -261,15 +267,11 @@ function output_xml_visual_console($id) {
if ($item['period'] != 0) {
echo "<period>" . $item['period'] . "</period>\n";
}
$agent = '';
if ($item['id_agent'] != 0) {
$agent = agents_get_name($item['id_agent']);
}
if (isset($item['id_agente_modulo'])) {
if ($item['id_agente_modulo'] != 0) {
$module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']);
$id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']);
$agent = agents_get_name($id_agent);
$agent = db_get_value ("alias","tagente","id_agente",$id_agent);
echo "<module><![CDATA[" . io_safe_output($module) . "]]></module>\n";
}

View File

@ -645,7 +645,7 @@ if ($id_downtime > 0) {
$filter_cond = '';
if ($filter_group > 0)
$filter_cond = " AND id_grupo = $filter_group ";
$sql = sprintf("SELECT tagente.id_agente, tagente.nombre
$sql = sprintf("SELECT tagente.id_agente, tagente.alias
FROM tagente
WHERE tagente.id_agente NOT IN (
SELECT tagente.id_agente
@ -660,7 +660,7 @@ if ($id_downtime > 0) {
$agents = array();
$agent_ids = extract_column($agents, 'id_agente');
$agent_names = extract_column($agents, 'nombre');
$agent_names = extract_column($agents, 'alias');
// item[<id>] = <name>;
$agents = array_combine($agent_ids, $agent_names);
if ($agents === false)
@ -736,7 +736,8 @@ if ($id_downtime > 0) {
foreach ($downtimes_agents as $downtime_agent) {
$data = array ();
$data[0] = $downtime_agent['nombre'];
$alias = db_get_value("alias","tagente","id_agente",$downtime_agent['id_agente']);
$data[0] = $alias;
$data[1] = db_get_sql ("SELECT nombre
FROM tgrupo

View File

@ -159,7 +159,8 @@ if (!empty($downtimes)) {
if (!empty($downtime_agents)) {
foreach ($downtime_agents as $downtime_agent) {
$downtime_items = array();
$downtime_items[] = $downtime_agent['agent_name'];
$alias = db_get_value("alias","tagente","id_agente",$downtime_agent['agent_id']);
$downtime_items[] = $alias;
if (!$downtime_agent['all_modules']) {
$agent_id = $downtime_agent['agent_id'];

View File

@ -87,7 +87,8 @@ else {
$agents = array();
foreach ($rows as $row) {
$agents[$row['id_agente']] = $row['nombre'];
$alias = db_get_value ("alias","tagente","id_agente",$row['id_agente']);
$agents[$row['id_agente']] = $alias;
}
switch ($config['dbtype']) {
@ -372,15 +373,17 @@ foreach ($items as $item) {
$agent_name_db = array();
foreach ($agents as $a) {
$agent_name_db[] = agents_get_name($a);
$alias = db_get_value ("alias","tagente","id_agente",$a);
$agent_name_db[] = $alias;
}
$agent_name_db = implode('<br>',$agent_name_db);
$module_name_db = implode('<br>',$modules);
}
else {
$agent_name_db = agents_get_name(agents_get_agent_id_by_module_id($item['id_agent_module']));
$agent_name_db = ui_print_truncate_text($agent_name_db, 'agent_small');
$alias = db_get_value ("alias","tagente","id_agente",agents_get_agent_id_by_module_id($item['id_agent_module']));
$agent_name_db = '<span title='. agents_get_name(agents_get_agent_id_by_module_id($item['id_agent_module'])) . '>' .$alias . '</span>';
$module_name_db = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
$module_name_db = ui_print_truncate_text(io_safe_output($module_name_db), 'module_small');
}
@ -390,7 +393,8 @@ foreach ($items as $item) {
}
}
else {
$row[2] = ui_print_truncate_text(agents_get_name($item['id_agent']), 'agent_small');
$alias = db_get_value ("alias","tagente","id_agente",$item['id_agent']);
$row[2] = '<span title='. agents_get_name($item['id_agent']) . '>' .$alias . '</span>';
if ($item['id_agent_module'] == '') {
$row [3] = '';

View File

@ -121,6 +121,10 @@ function reporting_html_print_report($report, $mini = false) {
}
else
$label = '';
$aux = explode("-",$item['subtitle']);
$item['subtitle'] = db_get_value ("alias","tagente","nombre",$item['agent_name']) .' -'. $aux[1];
reporting_html_header($table,
$mini, $item['title'],
$item['subtitle'],
@ -738,8 +742,9 @@ function reporting_html_inventory_changes($table, $item) {
$table1->data[2][0] = __('Added');
$table1->colspan[2][0] = 2;
$table1->data = array_merge($table1->data, $module_item['added']);
if (count ($module_item['added'])) {
$table1->data = array_merge($table1->data, $module_item['added']);
}
$table1->cellstyle[3 + count($module_item['added'])][0] =
@ -747,8 +752,9 @@ function reporting_html_inventory_changes($table, $item) {
$table1->data[3 + count($module_item['added'])][0] = __('Deleted');
$table1->colspan[3 + count($module_item['added'])][0] = 2;
$table1->data = array_merge($table1->data, $module_item['deleted']);
if (count ($module_item['deleted'])) {
$table1->data = array_merge($table1->data, $module_item['deleted']);
}
$table->colspan[

View File

@ -138,7 +138,8 @@ if (!empty ($module)) {
foreach ($data as $key => $module) {
$output .= $rowstart;
$output .= io_safe_output($module['agent_name']);
$alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']);
$output .= io_safe_output($alias);
$output .= $divider;
$output .= io_safe_output($module['module_name']);
$output .= $divider;

View File

@ -137,7 +137,8 @@ if (!empty ($module)) {
foreach ($data as $key => $module) {
$output .= $rowstart;
$output .= io_safe_output($module['agent_name']);
$alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']);
$output .= io_safe_output($alias);
$output .= $divider;
$output .= io_safe_output($module['module_name']);
$output .= $divider;

View File

@ -160,7 +160,8 @@ if (!empty ($export_btn) && !empty ($module)) {
foreach ($data as $key => $module) {
$output .= $rowstart;
$output .= io_safe_output($module['agent_name']);
$alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']);
$output .= io_safe_output($alias);
$output .= $divider;
$output .= io_safe_output($module['module_name']);
$output .= $divider;

View File

@ -139,6 +139,13 @@ unset($report['private']);
unset($report['custom_logo']);
//----------------------------------------------------------------------
//change agent name
if(count($report['contents']) > 0){
for($i = 0;$i < count($report['contents']); $i++){
$aux = explode("-",$report['contents'][$i]['subtitle']);
$report['contents'][$i]['subtitle'] = db_get_value ("alias","tagente","nombre",$report['contents'][$i]['agent_name']) .' -'. $aux[1];
}
}
$xml = null;
$xml = array2XML($report, "report", $xml);