mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
2011-08-01 Tomas Palacios <tomas.palacios@artica.es>
* godmode/alerts: fixed a bug regarding creation and updates of alert templates, actions and commands with blank or already used name fields. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4658 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e23d71e5b0
commit
d983c38f45
@ -113,23 +113,29 @@ if ($create_action) {
|
|||||||
$field3 = (string) get_parameter ('field3');
|
$field3 = (string) get_parameter ('field3');
|
||||||
$group = (string) get_parameter ('group');
|
$group = (string) get_parameter ('group');
|
||||||
$action_threshold = (int) get_parameter ('action_threshold');
|
$action_threshold = (int) get_parameter ('action_threshold');
|
||||||
|
$name_check = db_get_value ('name', 'talert_actions', 'name', $name);
|
||||||
|
|
||||||
$result = alerts_create_alert_action ($name, $id_alert_command,
|
if ($name_check) {
|
||||||
array ('field1' => $field1,
|
$result = '';
|
||||||
'field2' => $field2,
|
}
|
||||||
'field3' => $field3,
|
else {
|
||||||
'id_group' => $group,
|
$result = alerts_create_alert_action ($name, $id_alert_command,
|
||||||
'action_threshold' => $action_threshold));
|
array ('field1' => $field1,
|
||||||
|
'field2' => $field2,
|
||||||
|
'field3' => $field3,
|
||||||
|
'id_group' => $group,
|
||||||
|
'action_threshold' => $action_threshold));
|
||||||
|
|
||||||
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command .
|
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command .
|
||||||
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group .
|
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group .
|
||||||
' Action threshold: ' . $action_threshold;
|
' Action threshold: ' . $action_threshold;
|
||||||
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
db_pandora_audit("Command management", "Create alert action " . $result, false, false, $info);
|
db_pandora_audit("Command management", "Create alert action " . $result, false, false, $info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
db_pandora_audit("Command management", "Fail try to create alert action", false, false, $info);
|
db_pandora_audit("Command management", "Fail try to create alert action", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_print_result_message ($result,
|
ui_print_result_message ($result,
|
||||||
@ -174,13 +180,20 @@ if ($update_action) {
|
|||||||
$values['field3'] = $field3;
|
$values['field3'] = $field3;
|
||||||
$values['id_group'] = $group;
|
$values['id_group'] = $group;
|
||||||
$values['action_threshold'] = $action_threshold;
|
$values['action_threshold'] = $action_threshold;
|
||||||
|
$name_check = db_get_value ('name', 'talert_actions', 'name', $name);
|
||||||
|
|
||||||
$result = alerts_update_alert_action ($id, $values);
|
|
||||||
|
if (!$name || $name_check) {
|
||||||
|
$result = '';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = alerts_update_alert_action ($id, $values);
|
||||||
|
|
||||||
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command .
|
$info = 'Name: ' . $name . ' ID alert Command: ' . $id_alert_command .
|
||||||
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group .
|
' Field1: ' . $field1 . ' Field2: ' . $field2 . ' Field3: ' . $field3 . ' Group: ' . $group .
|
||||||
' Action threshold: ' . $action_threshold;
|
' Action threshold: ' . $action_threshold;
|
||||||
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
db_pandora_audit("Command management", "Update alert action " . $id, false, false, json_encode($values));
|
db_pandora_audit("Command management", "Update alert action " . $id, false, false, json_encode($values));
|
||||||
}
|
}
|
||||||
|
@ -49,17 +49,23 @@ if ($create_command) {
|
|||||||
$name = (string) get_parameter ('name');
|
$name = (string) get_parameter ('name');
|
||||||
$command = (string) get_parameter ('command');
|
$command = (string) get_parameter ('command');
|
||||||
$description = (string) get_parameter ('description');
|
$description = (string) get_parameter ('description');
|
||||||
|
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
|
||||||
$result = alerts_create_alert_command ($name, $command,
|
|
||||||
array ('description' => $description));
|
if (!$name_check) {
|
||||||
|
$result = alerts_create_alert_command ($name, $command,
|
||||||
$info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description;
|
array ('description' => $description));
|
||||||
|
|
||||||
|
$info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = '';
|
||||||
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
db_pandora_audit("Command management", "Create alert command " . $result, false, false, $info);
|
db_pandora_audit("Command management", "Create alert command " . $result, false, false, $info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
db_pandora_audit("Command management", "Fail try to create alert command", false, false, $info);
|
db_pandora_audit("Command management", "Fail try to create alert command", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_print_result_message ($result,
|
ui_print_result_message ($result,
|
||||||
@ -83,14 +89,21 @@ if ($update_command) {
|
|||||||
$values['name'] = $name;
|
$values['name'] = $name;
|
||||||
$values['command'] = $command;
|
$values['command'] = $command;
|
||||||
$values['description'] = $description;
|
$values['description'] = $description;
|
||||||
$result = alerts_update_alert_command ($id, $values);
|
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
|
||||||
|
|
||||||
$info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description;
|
if (!$name || $name_check) {
|
||||||
|
$result = '';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = alerts_update_alert_command ($id, $values);
|
||||||
|
$info = 'Name: ' . $name . ' Command: ' . $command . ' Description: ' . $description;
|
||||||
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
db_pandora_audit("Command management", "Create alert command " . $id, false, false, $info);
|
db_pandora_audit("Command management", "Create alert command " . $id, false, false, $info);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
db_pandora_audit("Command management", "Fail to create alert command " . $id, false, false, $info);
|
db_pandora_audit("Command management", "Fail to create alert command " . $id, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_print_result_message ($result,
|
ui_print_result_message ($result,
|
||||||
|
@ -178,6 +178,7 @@ function update_template ($step) {
|
|||||||
$matches = (bool) get_parameter ('matches_value');
|
$matches = (bool) get_parameter ('matches_value');
|
||||||
$priority = (int) get_parameter ('priority');
|
$priority = (int) get_parameter ('priority');
|
||||||
$id_group = get_parameter ("id_group");
|
$id_group = get_parameter ("id_group");
|
||||||
|
$name_check = db_get_value ('name', 'talert_templates', 'name', $name);
|
||||||
|
|
||||||
$values = array ('name' => $name,
|
$values = array ('name' => $name,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
@ -188,8 +189,13 @@ function update_template ($step) {
|
|||||||
'id_group' => $id_group,
|
'id_group' => $id_group,
|
||||||
'matches_value' => $matches,
|
'matches_value' => $matches,
|
||||||
'priority' => $priority);
|
'priority' => $priority);
|
||||||
|
|
||||||
$result = alerts_update_alert_template ($id,$values);
|
if (!$name || $name_check) {
|
||||||
|
$result = '';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = alerts_update_alert_template ($id,$values);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($step == 2) {
|
elseif ($step == 2) {
|
||||||
$monday = (bool) get_parameter ('monday');
|
$monday = (bool) get_parameter ('monday');
|
||||||
@ -330,6 +336,7 @@ if ($create_template) {
|
|||||||
$matches = (bool) get_parameter ('matches_value');
|
$matches = (bool) get_parameter ('matches_value');
|
||||||
$priority = (int) get_parameter ('priority');
|
$priority = (int) get_parameter ('priority');
|
||||||
$id_group = get_parameter ("id_group");
|
$id_group = get_parameter ("id_group");
|
||||||
|
$name_check = db_get_value ('name', 'talert_templates', 'name', $name);
|
||||||
|
|
||||||
switch ($config['dbtype']){
|
switch ($config['dbtype']){
|
||||||
case "mysql":
|
case "mysql":
|
||||||
@ -354,8 +361,12 @@ if ($create_template) {
|
|||||||
'field3_recovery' => ' ');
|
'field3_recovery' => ' ');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$result = alerts_create_alert_template ($name, $type, $values);
|
if (!$name_check) {
|
||||||
|
$result = alerts_create_alert_template ($name, $type, $values);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = '';
|
||||||
|
}
|
||||||
if ($result) {
|
if ($result) {
|
||||||
db_pandora_audit("Command management", "Create alert command " . $result, false, false, json_encode($values));
|
db_pandora_audit("Command management", "Create alert command " . $result, false, false, json_encode($values));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user