add new column evaluate_sla into table tservice

This commit is contained in:
daniel 2018-06-28 13:34:55 +02:00
parent e1d41c25b1
commit 1b1bc4aa2e
4 changed files with 34 additions and 18 deletions

View File

@ -10,4 +10,6 @@ ALTER TABLE `tmetaconsole_agent` ADD COLUMN `cps` int NOT NULL DEFAULT '0';
ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL DEFAULT '0';
ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL DEFAULT '0';
COMMIT; COMMIT;

View File

@ -1269,6 +1269,7 @@ UPDATE tagente SET tagente.alias = tagente.nombre;
ALTER TABLE `tservice` ADD COLUMN `quiet` tinyint(1) NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `quiet` tinyint(1) NOT NULL default 0;
ALTER TABLE `tservice` ADD COLUMN `cps` int NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `cps` int NOT NULL default 0;
ALTER TABLE `tservice` ADD COLUMN `cascade_protection` tinyint(1) NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `cascade_protection` tinyint(1) NOT NULL default 0;
ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL default 0;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tlayout` -- Table `tlayout`

View File

@ -10339,10 +10339,11 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) {
* *
* @param $thrash1 Don't use. * @param $thrash1 Don't use.
* @param $thrash2 Don't use. * @param $thrash2 Don't use.
* @param array $other it's array, $other as param is <description>;<id_group>;<critical>; * @param array $other it's array, $other as param is <description>;<id_group>;<critical>;
* <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>; * <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>;
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>; * <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;<quiet>;
* in this order and separator char (after text ; ) and separator * <cascade_protection>;<evaluate_sla>;
* in this order and separator char (after text ; ) and separator
* (pass in param othermode as othermode=url_encode_separator_<separator>) * (pass in param othermode as othermode=url_encode_separator_<separator>)
* @param $thrash3 Don't use * @param $thrash3 Don't use
* *
@ -10370,6 +10371,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
$id_critical_module_sla = $other['data'][10]; $id_critical_module_sla = $other['data'][10];
$quiet = $other['data'][11]; $quiet = $other['data'][11];
$cascade_protection = $other['data'][12]; $cascade_protection = $other['data'][12];
$evaluate_sla = $other['data'][13];
if(empty($name)){ if(empty($name)){
returnError('error_create_service', __('Error in creation service. No name')); returnError('error_create_service', __('Error in creation service. No name'));
@ -10419,6 +10421,9 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
if(empty($cascade_protection)){ if(empty($cascade_protection)){
$cascade_protection = 0; $cascade_protection = 0;
} }
if(empty($evaluate_sla)){
$evaluate_sla = 0;
}
$result = services_create_service ( $result = services_create_service (
$name, $description, $id_group, $name, $description, $id_group,
@ -10426,7 +10431,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
$mode, $id_agent, $sla_interval, $sla_limit, $mode, $id_agent, $sla_interval, $sla_limit,
$id_warning_module_template, $id_critical_module_template, $id_warning_module_template, $id_critical_module_template,
$id_unknown_module_template, $id_critical_module_sla, $id_unknown_module_template, $id_critical_module_sla,
$quiet, $cascade_protection $quiet, $cascade_protection, $evaluate_sla
); );
if($result){ if($result){
@ -10441,10 +10446,11 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
* *
* @param $thrash1 service id. * @param $thrash1 service id.
* @param $thrash2 Don't use. * @param $thrash2 Don't use.
* @param array $other it's array, $other as param is <name>;<description>;<id_group>;<critical>; * @param array $other it's array, $other as param is <name>;<description>;<id_group>;<critical>;
* <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>; * <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>;
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>; * <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;<quiet>;
* in this order and separator char (after text ; ) and separator * <cascade_protection>;<evaluate_sla>;
* in this order and separator char (after text ; ) and separator
* (pass in param othermode as othermode=url_encode_separator_<separator>) * (pass in param othermode as othermode=url_encode_separator_<separator>)
* @param $thrash3 Don't use * @param $thrash3 Don't use
* *
@ -10542,6 +10548,11 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
$cascade_protection = $service['cascade_protection']; $cascade_protection = $service['cascade_protection'];
} }
$evaluate_sla = $other['data'][13];
if(empty($evaluate_sla)){
$evaluate_sla = $service['evaluate_sla'];
}
$result = services_update_service ( $result = services_update_service (
$id_service, $name,$description, $id_group, $id_service, $name,$description, $id_group,
$critical, $warning, SECONDS_5MINUTES, $mode, $critical, $warning, SECONDS_5MINUTES, $mode,
@ -10550,7 +10561,8 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
$id_critical_module_template, $id_critical_module_template,
$id_unknown_module_template, $id_unknown_module_template,
$id_critical_module_sla, $id_critical_module_sla,
$quiet, $cascade_protection $quiet, $cascade_protection,
$evaluate_sla
); );
if($result){ if($result){
@ -10565,10 +10577,10 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) {
* *
* @param $thrash1 service id. * @param $thrash1 service id.
* @param $thrash2 Don't use. * @param $thrash2 Don't use.
* @param array $other it's a json, $other as param is <description>;<id_group>;<critical>; * @param array $other it's a json, $other as param is <description>;<id_group>;<critical>;
* <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>; * <warning>;<id_agent>;<sla_interval>;<sla_limit>;<id_warning_module_template_alert>;
* <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>; * <id_critical_module_template_alert>;<id_critical_module_sla_template_alert>;
* in this order and separator char (after text ; ) and separator * in this order and separator char (after text ; ) and separator
* (pass in param othermode as othermode=url_encode_separator_<separator>) * (pass in param othermode as othermode=url_encode_separator_<separator>)
* @param $thrash3 Don't use * @param $thrash3 Don't use
* *
@ -10584,7 +10596,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
if (is_metaconsole()) return; if (is_metaconsole()) return;
$id = $thrash1; $id = $thrash1;
if(empty($id)){ if(empty($id)){
returnError('error_add_service_element', __('Error adding elements to service. No service id')); returnError('error_add_service_element', __('Error adding elements to service. No service id'));
return; return;
@ -10613,7 +10625,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
continue; continue;
} }
break; break;
case 'module': case 'module':
$agent_id = 0; $agent_id = 0;
$id_service_child = 0; $id_service_child = 0;
@ -10622,7 +10634,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
continue; continue;
} }
break; break;
case 'service': case 'service':
$agent_id = 0; $agent_id = 0;
$id_agente_modulo = 0; $id_agente_modulo = 0;
@ -10635,7 +10647,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
} }
break; break;
} }
$values = array( $values = array(
'id_agente_modulo' => $id_agente_modulo, 'id_agente_modulo' => $id_agente_modulo,
'description' => $element['description'], 'description' => $element['description'],
@ -10647,20 +10659,20 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) {
'id_agent' => $agent_id, 'id_agent' => $agent_id,
'id_service_child' => $id_service_child, 'id_service_child' => $id_service_child,
'id_server_meta' => 0); 'id_server_meta' => 0);
$result = db_process_sql_insert('tservice_element',$values); $result = db_process_sql_insert('tservice_element',$values);
if($result && !$results){ if($result && !$results){
$results = $result; $results = $result;
} }
} }
} }
if($results){ if($results){
returnData('string', array('type' => 'string', 'data' => 1)); returnData('string', array('type' => 'string', 'data' => 1));
} else { } else {
returnError('error_add_service_element', __('Error adding elements to service')); returnError('error_add_service_element', __('Error adding elements to service'));
} }
} }
/** /**
* Update a special day. And return a message with the result of the operation. * Update a special day. And return a message with the result of the operation.

View File

@ -2429,6 +2429,7 @@ CREATE TABLE IF NOT EXISTS `tservice` (
`quiet` tinyint(1) NOT NULL default 0, `quiet` tinyint(1) NOT NULL default 0,
`cps` int NOT NULL default 0, `cps` int NOT NULL default 0,
`cascade_protection` tinyint(1) NOT NULL default 0, `cascade_protection` tinyint(1) NOT NULL default 0,
`evaluate_sla` int(1) NOT NULL default 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB ) ENGINE=InnoDB
COMMENT = 'Table to define services to monitor' COMMENT = 'Table to define services to monitor'