diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 442d0dd826..0ecf0ec308 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,7 @@ +2012-06-31 Vanessa Gil + + * include/functions_api.php: Added functions to api. + 2012-08-30 Miguel de Dios * godmode/agentes/planned_downtime.editor.php: fixed thw added diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index c4e195b9fb..d72e591568 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -4860,7 +4860,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $sql = "SELECT *, (SELECT t1.nombre FROM tagente AS t1 WHERE t1.id_agente = tevento.id_agente) AS agent_name, (SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name, - (SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon + (SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon, + (SELECT tmodule.name FROM tmodule WHERE id_module IN (SELECT tagente_modulo.id_modulo FROM tagente_modulo + WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name FROM tevento WHERE 1=1 " . $sql_post . " ORDER BY utimestamp DESC LIMIT " . $offset . "," . $pagination; } @@ -4870,7 +4872,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $sql = "SELECT *, (SELECT t1.nombre FROM tagente AS t1 WHERE t1.id_agente = tevento.id_agente) AS agent_name, (SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name, - (SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon + (SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon, + (SELECT tmodule.name FROM tmodule WHERE id_module IN (SELECT tagente_modulo.id_modulo FROM tagente_modulo + WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name FROM tevento WHERE 1=1 " . $sql_post . " ORDER BY utimestamp DESC LIMIT " . $pagination . " OFFSET " . $offset; break; @@ -4882,7 +4886,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $sql = "SELECT *, (SELECT t1.nombre FROM tagente AS t1 WHERE t1.id_agente = tevento.id_agente) AS agent_name, (SELECT t2.nombre FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_name, - (SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon + (SELECT t2.icon FROM tgrupo AS t2 WHERE t2.id_grupo = tevento.id_grupo) AS group_icon, + (SELECT tmodule.name FROM tmodule WHERE id_module IN (SELECT tagente_modulo.id_modulo FROM tagente_modulo + WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name FROM tevento WHERE 1=1 ".$sql_post." ORDER BY utimestamp DESC"; $sql = oracle_recode_query ($sql, $set); @@ -5327,4 +5333,97 @@ function get_tags($thrash1, $thrash2, $other, $returnType, $user_in_db) { returnData($returnType, $data, $separator); } +/** + * Total modules for a given group + * + * @param int $id_group + * +**/ +// http://localhost/pandora_console/include/api.php?op=get&op2=total_modules&id=1 +function api_get_total_modules($id_group, $returnType) { + + $sql = sprintf('SELECT COUNT(*) + FROM tgroup_stat, tgrupo + WHERE tgrupo.id_grupo = tgroup_stat.id_group AND tgroup_stat.id_group = %d', $id_group); + $total = db_get_value_sql($sql); + + $data = array('type' => 'string', 'data' => $total); + + returnData(string, $data); +} + +/** + * Total modules for a given group + * + * @param int $id_group + * +**/ +// http://localhost/pandora_console/include/api.php?op=get&op2=total_modules&id=2 +function api_get_total_agents($id_group, $returnType) { + + $sql = sprintf('SELECT COUNT(*) FROM tagente WHERE id_grupo=%d AND disabled=0', $id_group); + $group = db_get_value_sql($sql); + + $data = array('type' => 'string', 'data' => $group); + returnData(string, $data); +} + +/** + * Agent name for a given id + * + * @param int $id_group + * +**/ +// http://localhost/pandora_console/include/api.php?op=get&op2=agent_name&id=1 +function api_get_agent_name($id_agent, $returnType) { + + $sql = sprintf('SELECT nombre FROM tagente WHERE id_agente = %d', $id_agent); + $value = db_get_value_sql($sql); + if ($value === false) { + returnError('id_not_found', $returnType); + } + + $data = array('type' => 'string', 'data' => $value); + + returnData(string, $data); +} + +/** + * Module name for a given id + * + * @param int $id_group + * +**/ +// http://localhost/pandora_console/include/api.php?op=get&op2=module_name&id_module=20 +function api_get_module_name($id_module, $returnType) { + + $sql = sprintf('SELECT name FROM tmodule WHERE id_module = %d', $id_module); + $value = db_get_value_sql($sql); + if ($value === false) { + returnError('id_not_found', $returnType); + } + + $data = array('type' => 'string', 'data' => $value); + + returnData(string, $data); + //returnData($returnType, $data); +} + +function api_get_alert_action_by_group($id_group, $id_action, $returnType) { + + $sql = sprintf('SELECT SUM(internal_counter) FROM talert_template_modules + WHERE id_alert_template IN + (SELECT id FROM talert_templates + WHERE id_group=%d AND id_alert_action = %d)', $id_group, $id_action); + + $value = db_get_value_sql($sql); + if ($value === false) { + returnError('data_not_found', $returnType); + } + + $data = array('type' => 'string', 'data' => $value); + + returnData(string, $data); +} + ?>