2012-01-23 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/functions_agents.php
	 operation/incidents/incident.php
	 operation/incidents/incident_detail.php
     operation/agentes/ver_agente.php
	 godmode/agentes/agent_incidents.php
	 godmode/agentes/configurar_agente.php: Added the possibility to add
	 agent to an incident and added new tab in agent view if the agent
	 has incidents associated.
  
	 * pandoradb.postgreSQL.sql
	 pandoradb.oracle.sql
	 pandoradb.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql
	 extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql	
	 extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: modified 
	 table tincidencia.
	 
	 Pending task: # 3472447
	 



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5405 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2012-01-23 17:01:00 +00:00
parent 7d6ab5a944
commit e1ea2d84ce
13 changed files with 288 additions and 13 deletions

View File

@ -1,3 +1,24 @@
2012-01-23 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_agents.php
operation/incidents/incident.php
operation/incidents/incident_detail.php
operation/agentes/ver_agente.php
godmode/agentes/agent_incidents.php
godmode/agentes/configurar_agente.php: Added the possibility to add
agent to an incident and added new tab in agent view if the agent
has incidents associated.
* pandoradb.postgreSQL.sql
pandoradb.oracle.sql
pandoradb.sql
extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql
extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql
extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql: modified
table tincidencia.
Pending task: # 3472447
2012-01-23 Vanessa Gil <vanessa.gil@artica.es>
* operation/agentes/estado_agente.php

View File

@ -53,3 +53,8 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
ALTER TABLE `tusuario` ADD COLUMN `disabled` int(4) NOT NULL DEFAULT 0;
-- -----------------------------------------------------
-- Table `tincidencia`
-- -----------------------------------------------------
ALTER TABLE `tincidencia` ADD COLUMN `id_agent` int(10) unsigned NULL default 0;

View File

@ -54,3 +54,9 @@ show_graph VARCHAR2(60),
CREATE SEQUENCE tnetflow_report_content_s INCREMENT BY 1 START WITH 1;
CREATE OR REPLACE TRIGGER tnetflow_report_content_inc BEFORE INSERT ON tnetflow_report_content REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnetflow_report_content_s.nextval INTO :NEW.ID_RC FROM dual; END tnetflow_report_content_inc;;
-- -----------------------------------------------------
-- Table `tincidencia`
-- -----------------------------------------------------
alter table tincidencia add (id_agent NUMBER(10,0) default 0 NULL);

View File

@ -43,3 +43,8 @@ CREATE TABLE "tnetflow_report_content" (
"order" INTEGER NOT NULL default 0
);
-- -----------------------------------------------------
-- Table `tincidencia`
-- -----------------------------------------------------
ALTER TABLE "tincidencia" ADD COLUMN "id_agent" INTEGER(10) NULL DEFAULT 0;

View File

@ -0,0 +1,130 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
require_once ('include/functions_incidents.php');
/*enterprise_include ('include/functions_policies.php');
enterprise_include ('include/functions_modules.php');
include_once($config['homedir'] . "/include/functions_agents.php");*/
check_login ();
$group = $id_grupo;
if (! check_acl ($config["id_user"], $group, "AW", $id_agente)) {
db_pandora_audit("ACL Violation",
"Trying to access agent manager");
require ("general/noaccess.php");
return;
}
$offset = (int) get_parameter("offset", 0);
//See if id_agente is set (either POST or GET, otherwise -1
$id_agent = (int) get_parameter ("id_agente");
$groups = users_get_groups ($config["id_user"], "IR");
$filter = ' AND id_agent = ' . $id_agent;
$url = "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=incident&id_agente=" . $id_agent;
//Select incidencts where the user has access to ($groups from
//get_user_groups), array_keys for the id, implode to pass to SQL
$sql = "SELECT * FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($groups)).")".$filter."
ORDER BY actualizacion DESC LIMIT ".$offset.",".$config["block_size"];
$result = db_get_all_rows_sql ($sql);
$count_sql = "SELECT count(*) FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($groups)).")".$filter."
ORDER BY actualizacion DESC";
$count = db_get_value_sql ($count_sql);
if (empty ($result)) {
$result = array ();
$count = 0;
echo '<div class="nf">'.__('No incidents associated to this agent').'</div><br />';
return;
}
// Show pagination
ui_pagination ($count, $url, $offset, 0, false, 'offset'); //($count + $offset) it's real count of incidents because it's use LIMIT $offset in query.
echo '<br />';
// Show headers
$table->width = "100%";
$table->class = "databox";
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->head = array ();
$table->data = array ();
$table->size = array ();
$table->align = array ();
$table->head[0] = __('ID');
$table->head[1] = __('Status');
$table->head[2] = __('Incident');
$table->head[3] = __('Priority');
$table->head[4] = __('Group');
$table->head[5] = __('Updated');
$table->head[6] = __('Source');
$table->head[7] = __('Owner');
$table->size[0] = 43;
$table->size[7] = 50;
$table->align[1] = "center";
$table->align[3] = "center";
$table->align[4] = "center";
$rowPair = true;
$iterator = 0;
foreach ($result as $row) {
if ($rowPair)
$table->rowclass[$iterator] = 'rowPair';
else
$table->rowclass[$iterator] = 'rowOdd';
$rowPair = !$rowPair;
$iterator++;
$data = array();
$data[0] = '<a href="index.php?sec=incidencias&amp;sec2=operation/incidents/incident_detail&amp;id='.$row["id_incidencia"].'">'.$row["id_incidencia"].'</a>';
$attach = incidents_get_attach ($row["id_incidencia"]);
if (!empty ($attach))
$data[0] .= '&nbsp;&nbsp;'.html_print_image ("images/attachment.png", true, array ("style" => "align:middle;"));
$data[1] = incidents_print_status_img ($row["estado"], true);
$data[2] = '<a href="index.php?sec=incidencias&amp;sec2=operation/incidents/incident_detail&amp;id='.$row["id_incidencia"].'">'.substr(io_safe_output($row["titulo"]),0,45).'</a>';
$data[3] = incidents_print_priority_img ($row["prioridad"], true);
$data[4] = ui_print_group_icon ($row["id_grupo"], true);
$data[5] = ui_print_timestamp ($row["actualizacion"], true);
$data[6] = $row["origen"];
$data[7] = ui_print_username ($row["id_usuario"], true);
array_push ($table->data, $data);
}
html_print_table ($table);
echo '</div>';
unset ($table);
echo '<br><br>';
echo '<div style="clear:both">&nbsp;</div>';
?>

View File

@ -247,7 +247,7 @@ if ($id_agente) {
if($tab == 'alert')
$alerttab['active'] = true;
else
$alerttab['active'] = false;
$alerttab['active'] = false;
/* Template tab */
$templatetab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=template&amp;id_agente='.$id_agente.'">'
@ -295,10 +295,29 @@ if ($id_agente) {
$gistab['active'] = false;
}
$total_incidents = agents_get_count_incidents($id_agente);
/* Incident tab */
if ($config['integria_enabled'] == 0 and $total_incidents > 0){
$incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=godmode/agentes/configurar_agente&amp;tab=incident&amp;id_agente='.$id_agente.'">'
. html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents')))
. '</a>';
if($tab == 'incident')
$incidenttab['active'] = true;
else
$incidenttab['active'] = false;
}
$onheader = array('view' => $viewtab, 'separator' => "", 'main' => $maintab,
'module' => $moduletab, 'alert' => $alerttab, 'template' => $templatetab,
'inventory' => $inventorytab, 'collection'=> $collectiontab, 'group' => $grouptab, 'gis' => $gistab);
// Only if the agent has incidents associated show incidents tab
if ($total_incidents){
$onheader['incident'] = $incidenttab;
}
foreach($config['extensions'] as $extension) {
if (isset($extension['extension_god_tab'])) {
$image = $extension['extension_god_tab']['icon'];
@ -345,6 +364,9 @@ if ($id_agente) {
case "gis":
$tab_description = '- ' . __('Gis') . ui_print_help_icon('gis_tab', true);
break;
case "incident":
$tab_description = '- ' . __('Incidents');
break;
case "extension":
$id_extension = get_parameter('id_extension', '');
switch ($id_extension){
@ -1065,6 +1087,9 @@ switch ($tab) {
case "gis":
require("agent_conf_gis.php");
break;
case "incident":
require("agent_incidents.php");
break;
case "extension":
$found = false;
foreach($config['extensions'] as $extension) {

View File

@ -1808,4 +1808,19 @@ function agents_get_agent_group ($id_agent) {
return (int) db_get_value ('id_grupo', 'tagente', 'id_agente', (int) $id_agent);
}
/**
* This function gets the count of incidents attached to the agent
*
* @param int The agent id
*
* @return mixed The incidents attached or false
*/
function agents_get_count_incidents ($id_agent) {
if (empty($id_agent)){
return false;
}
return db_get_value('count(*)', 'tincidencia', 'id_agent', $id_agent);
}
?>

View File

@ -580,6 +580,20 @@ if ($config['activate_gis']) {
$gistab['active'] = false;
}
$total_incidents = agents_get_count_incidents($id_agente);
/* Incident tab */
if ($config['integria_enabled'] == 0 and $total_incidents > 0){
$incidenttab['text'] = '<a href="index.php?sec=gagente&amp;sec2=operation/agentes/ver_agente&tab=incident&id_agente='.$id_agente.'">'
. html_print_image ("images/book_edit.png", true, array ("title" =>__('Incidents')))
. '</a>';
if($tab == 'incident')
$incidenttab['active'] = true;
else
$incidenttab['active'] = false;
}
$custom_fields['text']= '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=custom_fields&id_agente='.$id_agente.'">'
. html_print_image("images/note.png", true, array("title" => __('Custom fields')))
. '</a>';
@ -607,6 +621,11 @@ $onheader = array('manage' => $managetab, 'separator' => "", 'main' => $maintab,
'inventory' => $inventorytab, 'collection' => $collectiontab,
'group' => $grouptab, 'gis' => $gistab, 'custom' => $custom_fields, 'graphs' => $graphs, 'policy' => $policyTab);
// If the agent has incidents associated
if ($total_incidents){
$onheader['incident'] = $incidenttab;
}
foreach($config['extensions'] as $extension) {
if (isset($extension['extension_ope_tab'])) {
@ -677,7 +696,10 @@ switch($tab) {
break;
case "policy":
$header_description = ' - ' . __('Policy');
break;
break;
case "incident":
$header_description = ' - ' . __('Incident');
break;
}
ui_print_page_header (__('Agent').'&nbsp;-&nbsp;'.mb_substr(agents_get_name($id_agente),0,25) . $header_description, $icon, false, "", false, $onheader);
@ -723,6 +745,9 @@ switch ($tab) {
case "graphs";
require("operation/agentes/graphs.php");
break;
case "incident":
require("godmode/agentes/agent_incidents.php");
break;
case "extension":
$found = false;
foreach($config['extensions'] as $extension) {

View File

@ -88,9 +88,10 @@ elseif ($action == "update") {
$estado = get_parameter ("estado_form", 0);
$grupo = get_parameter ("grupo_form", 1);
$usuario = get_parameter ("usuario_form", $config["id_user"]);
$id_agent = get_parameter ("incident_agents");
$sql = sprintf ("UPDATE tincidencia SET titulo = '%s', origen = '%s', estado = %d, id_grupo = %d, id_usuario = '%s', prioridad = %d, descripcion = '%s', id_lastupdate = '%s' WHERE id_incidencia = %d",
$titulo, $origen, $estado, $grupo, $usuario, $prioridad, $descripcion, $config["id_user"], $id_inc);
$sql = sprintf ("UPDATE tincidencia SET titulo = '%s', origen = '%s', estado = %d, id_grupo = %d, id_usuario = '%s', prioridad = %d, descripcion = '%s', id_lastupdate = '%s', id_agent = %d WHERE id_incidencia = %d",
$titulo, $origen, $estado, $grupo, $usuario, $prioridad, $descripcion, $config["id_user"], $id_agent, $id_inc);
$result = db_process_sql ($sql);
if ($result !== false) {
@ -120,8 +121,9 @@ elseif ($action == "insert") {
$prioridad = get_parameter ("prioridad_form");
$id_creator = $config['id_user'];
$estado = get_parameter ("estado_form");
$sql = sprintf ("INSERT INTO tincidencia (inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator) VALUES
(NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s')", $titulo, $descripcion, $config["id_user"], $origen, $estado, $prioridad, $grupo, $config["id_user"]);
$id_agent = get_parameter ("incident_agents");
$sql = sprintf ("INSERT INTO tincidencia (inicio, actualizacion, titulo, descripcion, id_usuario, origen, estado, prioridad, id_grupo, id_creator, id_agent) VALUES
(NOW(), NOW(), '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d)", $titulo, $descripcion, $config["id_user"], $origen, $estado, $prioridad, $grupo, $config["id_user"], $id_agent);
$id_inc = db_process_sql ($sql, "insert_id");
if ($id_inc === false) {
@ -161,6 +163,11 @@ $prioridad = (int) get_parameter ("prioridad", -1);
if ($prioridad != -1) //-1 = All
$filter .= sprintf (" AND prioridad = %d", $prioridad);
$agent_search = (int) get_parameter("agent_search");
if ($agent_search != 0){
$filter .= sprintf(" AND id_agent = %d", $agent_search);
}
$offset = (int) get_parameter ("offset", 0);
$groups = users_get_groups ($config["id_user"], "IR");
@ -171,14 +178,17 @@ $sql = "SELECT * FROM tincidencia WHERE
ORDER BY actualizacion DESC LIMIT ".$offset.",".$config["block_size"];
$result = db_get_all_rows_sql ($sql);
$count_sql = "SELECT count(*) FROM tincidencia WHERE
id_grupo IN (".implode (",",array_keys ($groups)).")".$filter."
ORDER BY actualizacion DESC";
$count = db_get_value_sql ($count_sql);
if (empty ($result)) {
$result = array ();
$count = 0;
}
else {
$count = count ($result);
}
echo '<form name="visualizacion" method="post" action="index.php?sec=incidencias&amp;sec2=operation/incidents/incident">';
@ -214,6 +224,20 @@ echo '</td></tr><tr><td>';
html_print_select (users_get_info (), "usuario", $usuario, 'javascript:this.form.submit();', __('All users'), "", false, false, false, "w155");
echo '</td></tr><tr><td>';
$agents_incidents = agents_get_agents(false, array('id_agente', 'nombre'));
if ($agents_incidents === false){
$agents_incidents = array();
}
foreach ($agents_incidents as $agent_incident){
$result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre'];
}
html_print_select ($result_agent_incidents, "agent_search", $agent_search, 'javascript:this.form.submit();', __('All agents'), "", false, false, false, "w155");
echo '</td></tr><tr><td colspan=3>';
html_print_select_groups($config["id_user"], "IR", true, "grupo", $grupo, 'javascript:this.form.submit();', '', '',false,false,false,'w155');
@ -248,7 +272,7 @@ if ($count < 1) {
$url .= "&amp;texto=".$texto;
// Show pagination
ui_pagination ($count + $offset, $url, $offset, 15, false); //($count + $offset) it's real count of incidents because it's use LIMIT $offset in query.
ui_pagination ($count, $url, $offset, 0, false); //($count + $offset) it's real count of incidents because it's use LIMIT $offset in query.
echo '<br />';
// Show headers

View File

@ -50,6 +50,7 @@ if (isset ($_GET["id"])) {
$id_grupo = $row["id_grupo"];
$id_creator = $row["id_creator"]; //creator
$id_lastupdate = $row["id_lastupdate"]; //last updater
$id_agent = $row["id_agent"]; // Agent
// Note add - everybody that can read incidents, can add notes
if (isset ($_GET["insertar_nota"])) {
@ -179,6 +180,7 @@ elseif (isset ($_GET["insert_form"])) {
$usuario = $config["id_user"];
$id_creator = $config["id_user"];
$id_grupo = 0;
$id_agent = 0;
if (isset ($_GET["from_event"])) {
$event = get_parameter ("from_event");
@ -300,6 +302,20 @@ if (empty ($id_creator)) {
echo $id_creator.' (<i>'.get_user_fullname($id_creator).'</i>)';
}
$agents_incidents = agents_get_agents(false, array('id_agente', 'nombre'));
if ($agents_incidents === false){
$agents_incidents = array();
}
foreach ($agents_incidents as $agent_incident){
$result_agent_incidents[$agent_incident['id_agente']] = $agent_incident['nombre'];
}
echo '</td></tr><tr><td class="datos"><b>'.__('Agent').'</b></td><td class="datos">';
html_print_select ($result_agent_incidents, "incident_agents", $id_agent, '', __('None'), 0, false, false, false, 'w135', false);
echo '</td></tr><tr><td class="datos2" colspan="4">';
if ((check_acl ($config["id_user"], $id_grupo, "IM") == 1) OR ($usuario == $config["id_user"])) {

View File

@ -534,7 +534,8 @@ CREATE TABLE tincidencia (
id_creator VARCHAR2(60) default NULL,
id_lastupdate VARCHAR2(60) default NULL,
id_agente_modulo NUMBER(19, 0) NOT NULL,
notify_email NUMBER(10, 0) default 0 NOT NULL
notify_email NUMBER(10, 0) default 0 NOT NULL,
id_agent NUMBER(19, 0) default 0 NULL
);
CREATE INDEX tincidencia_id_1_idx ON tincidencia(id_usuario,id_incidencia);
CREATE INDEX tincidencia_id_agente_mod_idx ON tincidencia(id_agente_modulo);

View File

@ -420,7 +420,8 @@ CREATE TABLE "tincidencia" (
"id_creator" varchar(60) default NULL,
"id_lastupdate" varchar(60) default NULL,
"id_agente_modulo" BIGINT NOT NULL,
"notify_email" INTEGER NOT NULL default 0
"notify_email" INTEGER NOT NULL default 0,
"id_agent" INTEGER(10) NULL default 0
);
CREATE INDEX "tincidencia_id_1_idx" ON "tincidencia"("id_usuario","id_incidencia");
CREATE INDEX "tincidencia_id_agente_modulo_idx" ON "tincidencia"("id_agente_modulo");

View File

@ -470,6 +470,7 @@ CREATE TABLE IF NOT EXISTS `tincidencia` (
`id_lastupdate` varchar(60) default NULL,
`id_agente_modulo` bigint(100) NOT NULL,
`notify_email` tinyint(3) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NULL default 0,
PRIMARY KEY (`id_incidencia`),
KEY `incident_index_1` (`id_usuario`,`id_incidencia`),
KEY `id_agente_modulo` (`id_agente_modulo`)