2012-06-31 Vanessa Gil <vanessa.gil@artica.es>

* include/functions_api.php: Added functions to api.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6926 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
vgilc 2012-08-31 08:44:10 +00:00
parent 3ffb3d5a31
commit 7e75f26694
2 changed files with 106 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2012-06-31 Vanessa Gil <vanessa.gil@artica.es>
* include/functions_api.php: Added functions to api.
2012-08-30 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/planned_downtime.editor.php: fixed thw added

View File

@ -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);
}
?>