2013-02-27 Dario Rodriguez <dario@artica.es>
* include/functions_events.php: Added new fields to events_create_event function: critical warning and unknown instructions, source and tags. * include/functions_api.php: Reimplemented api_create_event API function, the behaviour was completly wrong from documented and events_create_event function. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7733 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b261b2dbf9
commit
f6f7bbcaeb
|
@ -1,3 +1,11 @@
|
|||
2013-02-27 Dario Rodriguez <dario@artica.es>
|
||||
|
||||
* include/functions_events.php: Added new fields to events_create_event
|
||||
function: critical warning and unknown instructions, source and tags.
|
||||
* include/functions_api.php: Reimplemented api_create_event API function,
|
||||
the behaviour was completly wrong from documented and events_create_event
|
||||
function.
|
||||
|
||||
2013-02-27 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/setup/setup_general.php, godmode/setup/setup_netflow.php,
|
||||
|
|
|
@ -5589,97 +5589,102 @@ function api_set_create_event($id, $trash1, $other, $returnType) {
|
|||
|
||||
$values = array();
|
||||
|
||||
if ($other['data'][0] != '')
|
||||
$values['id_grupo'] = $other['data'][0];
|
||||
else {
|
||||
returnError('error_parameter', 'Id group required.');
|
||||
if ($other['data'][0] != '') {
|
||||
$values['event'] = $other['data'][0];
|
||||
} else {
|
||||
returnError('error_parameter', 'Event text required.');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][1] != '') {
|
||||
$values['id_grupo'] = $other['data'][1];
|
||||
} else {
|
||||
returnError('error_parameter', 'Group ID required.');
|
||||
return;
|
||||
}
|
||||
if ($other['data'][1] != '')
|
||||
$values['event_type'] = $other['data'][1];
|
||||
else {
|
||||
returnError('error_parameter', 'Event type required.');
|
||||
return;
|
||||
}
|
||||
if ($other['data'][2] != '')
|
||||
|
||||
if ($other['data'][2] != '') {
|
||||
$values['id_agente'] = $other['data'][2];
|
||||
else {
|
||||
if ($other['data'][3] != '') {
|
||||
$agent_name = $other['data'][3];
|
||||
$id_agent = agents_get_agent_id ($agent_name);
|
||||
if ($id_agent !== false) {
|
||||
$values['id_agente'] = $id_agent;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
returnError('error_parameter', 'Agent ID required.');
|
||||
return;
|
||||
}
|
||||
if ($other['data'][4] != '')
|
||||
$values['id_usuario'] = $other['data'][4];
|
||||
|
||||
if ($other['data'][5] != '')
|
||||
$values['estado'] = $other['data'][5];
|
||||
$values['timestamp'] = date("Y-m-d H:i:s", get_system_time());
|
||||
|
||||
$values['evento'] = $id;
|
||||
$values['utimestamp'] = get_system_time ();
|
||||
|
||||
if ($other['data'][6] != '')
|
||||
$values['id_agentmodule'] = $other['data'][6];
|
||||
else {
|
||||
if ($other['data'][7] != '') {
|
||||
$module_name = $other['data'][7];
|
||||
$id_agent_module = modules_get_agentmodule_id ($module_name, $values['id_agente']);
|
||||
if ($id_agent_module !== false) {
|
||||
$values['id_agentmodule'] = $id_agent_module;
|
||||
}
|
||||
}
|
||||
if ($other['data'][3] != '') {
|
||||
$values['status'] = $other['data'][3];
|
||||
} else {
|
||||
$values['status'] = 0;
|
||||
}
|
||||
if ($other['data'][8] != '')
|
||||
|
||||
$values['id_usuario'] = $other['data'][4];
|
||||
|
||||
if ($other['data'][5] != '') {
|
||||
$values['event_type'] = $other['data'][5];
|
||||
} else {
|
||||
$values['event_type'] = "unknown";
|
||||
}
|
||||
|
||||
if ($other['data'][6] != '') {
|
||||
$values['priority'] = $other['data'][6];
|
||||
} else {
|
||||
$values['priority'] = 0;
|
||||
}
|
||||
|
||||
if ($other['data'][7] != '') {
|
||||
$values['id_agentmodule'] = $other['data'][7];
|
||||
} else {
|
||||
$value['id_agentemodule'] = 0;
|
||||
}
|
||||
|
||||
if ($other['data'][8] != '') {
|
||||
$values['id_alert_am'] = $other['data'][8];
|
||||
} else {
|
||||
$values['id_alert_am'] = 0;
|
||||
}
|
||||
|
||||
if ($other['data'][9] != '')
|
||||
$values['criticity'] = $other['data'][9];
|
||||
if ($other['data'][9] != '') {
|
||||
$values['critical_instructions'] = $other['data'][9];
|
||||
} else {
|
||||
$values['critical_instructions'] = '';
|
||||
}
|
||||
|
||||
if ($other['data'][10] != '') {
|
||||
$values['warning_instructions'] = $other['data'][10];
|
||||
} else {
|
||||
$values['warning_instructions'] = '';
|
||||
}
|
||||
|
||||
if ($other['data'][11] != '') {
|
||||
$values['unknown_instructions'] = $other['data'][11];
|
||||
} else {
|
||||
$values['unknown_instructions'] = '';
|
||||
}
|
||||
|
||||
if ($other['data'][11] != '')
|
||||
$values['tags'] = $other['data'][11];
|
||||
if ($other['data'][12] != '')
|
||||
$values['source'] = $other['data'][12];
|
||||
else
|
||||
$values['source'] = 'Pandora';
|
||||
if ($other['data'][13] != '')
|
||||
$values['id_extra'] = $other['data'][13];
|
||||
if ($other['data'][14] != '') {
|
||||
$values['critical_instructions'] = $other['data'][14];
|
||||
$values['source'] = $other['data'][14];
|
||||
} else {
|
||||
$values['source'] = "Pandora";
|
||||
}
|
||||
|
||||
if ($other['data'][15] != '') {
|
||||
$values['warning_instructions'] = $other['data'][15];
|
||||
}
|
||||
if ($other['data'][16] != '') {
|
||||
$values['unknown_instructions'] = $other['data'][16];
|
||||
}
|
||||
$values ['ack_utimestamp'] = 0;
|
||||
|
||||
if (preg_match("/\w*alert\w*/", $values['event_type'])) {
|
||||
if (($values['id_alert_am'] == '') || ($values['id_alert_am'] == 0)) {
|
||||
returnError('error_parameter', 'Id alert required for this type of event.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (preg_match("/\w*going\w*/", $values['event_type'])) {
|
||||
if (($values['id_agentmodule'] == '') || ($values['id_agentmodule'] == 0)) {
|
||||
returnError('error_parameter', 'Id agent module required for this type of event.');
|
||||
return;
|
||||
}
|
||||
$values['tags'] = $other['data'][15];
|
||||
} else {
|
||||
$values['tags'] = "";
|
||||
}
|
||||
|
||||
$return = db_process_sql_insert('tevento', $values);
|
||||
$return = events_create_event($values['event'], $values['id_grupo'], $values['id_agente'],
|
||||
$values['status'], $values['id_usuario'], $values['event_type'],
|
||||
$values['priority'], $value['id_agentemodule'], $values['id_alert_am'],
|
||||
$values['critical_instructions'], $values['warning_instructions'],
|
||||
$values['unknown_instructions'], $values['source'], $values['tags']);
|
||||
|
||||
if ($other['data'][10] != '') { //user comments
|
||||
if ($other['data'][12] != '') { //user comments
|
||||
if ($return !== false) { //event successfully created
|
||||
$user_comment = $other['data'][10];
|
||||
$user_comment = $other['data'][12];
|
||||
$res = events_comment ($return, $user_comment);
|
||||
if ($other['data'][17] != '') { //owner user
|
||||
if ($other['data'][13] != '') { //owner user
|
||||
if ($res !== false) { //comment added
|
||||
$owner_user = $other['data'][17];
|
||||
$owner_user = $other['data'][13];
|
||||
events_change_owner ($return, $owner_user, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -660,33 +660,33 @@ function events_get_description ($id_event) {
|
|||
*
|
||||
* @return int event id
|
||||
*/
|
||||
function events_create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", $event_type = "unknown", $priority = 0, $id_agent_module = 0, $id_aam = 0, $critical_instructions = '', $warning_instructions = '', $unknown_instructions = '') {
|
||||
function events_create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", $event_type = "unknown", $priority = 0, $id_agent_module = 0, $id_aam = 0, $critical_instructions = '', $warning_instructions = '', $unknown_instructions = '', $source="Pandora", $tags="") {
|
||||
global $config;
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp,
|
||||
estado, utimestamp, id_usuario, event_type, criticity,
|
||||
id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions)
|
||||
VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()), "%s", "%s", %d, %d, %d)',
|
||||
id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags)
|
||||
VALUES (%d, %d, "%s", NOW(), %d, UNIX_TIMESTAMP(NOW()), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s")',
|
||||
$id_agent, $id_group, $event, $status, $id_user, $event_type,
|
||||
$priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions);
|
||||
$priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags);
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp,
|
||||
estado, utimestamp, id_usuario, event_type, criticity,
|
||||
id_agentmodule, id_alert_am)
|
||||
VALUES (%d, %d, "%s", NOW(), %d, ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s", "%s", %d, %d, %d)',
|
||||
id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags)
|
||||
VALUES (%d, %d, "%s", NOW(), %d, ceil(date_part(\'epoch\', CURRENT_TIMESTAMP)), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s")',
|
||||
$id_agent, $id_group, $event, $status, $id_user, $event_type,
|
||||
$priority, $id_agent_module, $id_aam);
|
||||
$priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags);
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp,
|
||||
estado, utimestamp, id_usuario, event_type, criticity,
|
||||
id_agentmodule, id_alert_am)
|
||||
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)), "%s", "%s", %d, %d, %d)',
|
||||
id_agentmodule, id_alert_am, critical_instructions, warning_instructions, unknown_instructions, source, tags)
|
||||
VALUES (%d, %d, "%s", CURRENT_TIMESTAMP, %d, ceil((sysdate - to_date(\'19700101000000\',\'YYYYMMDDHH24MISS\')) * (86400)), "%s", "%s", %d, %d, %d, "%s", "%s", "%s", "%s", "%s")',
|
||||
$id_agent, $id_group, $event, $status, $id_user, $event_type,
|
||||
$priority, $id_agent_module, $id_aam);
|
||||
$priority, $id_agent_module, $id_aam, $critical_instructions, $warning_instructions, $unknown_instructions, $source, $tags);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue