diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql
index 7ff09cdc29..f1cc0056c0 100644
--- a/pandora_console/extras/mr/51.sql
+++ b/pandora_console/extras/mr/51.sql
@@ -11,6 +11,33 @@ ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGN
ALTER TABLE `tsync_queue` ADD COLUMN `result` TEXT;
ALTER TABLE tagente_modulo MODIFY debug_content TEXT;
+CREATE TABLE IF NOT EXISTS `tncm_queue` (
+ `id` SERIAL,
+ `id_agent` INT(10) UNSIGNED NOT NULL,
+ `id_script` BIGINT(20) UNSIGNED NOT NULL,
+ `utimestamp` INT UNSIGNED NOT NULL,
+ `scheduled` INT UNSIGNED DEFAULT NULL,
+ FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
+ FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `tncm_snippet` (
+ `id` SERIAL,
+ `name` TEXT,
+ `content` TEXT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS `tncm_firmware` (
+ `id` SERIAL,
+ `name` varchar(255),
+ `shortname` varchar(255) unique,
+ `vendor` bigint(20) unsigned,
+ `models` text,
+ `path` text,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
CREATE TABLE IF NOT EXISTS `talert_calendar` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL default '',
@@ -50,6 +77,10 @@ ALTER TABLE `tipam_supernet` ADD COLUMN `id_site` bigint unsigned;
ALTER TABLE `tipam_supernet` ADD CONSTRAINT FOREIGN KEY (`id_site`) REFERENCES `tipam_sites`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE `tipam_network` ADD COLUMN `vrf` int(10) unsigned;
ALTER TABLE `tipam_network` ADD CONSTRAINT FOREIGN KEY (`vrf`) REFERENCES `tagente`(`id_agente`) ON DELETE SET NULL ON UPDATE CASCADE;
+ALTER TABLE `tncm_agent` ADD COLUMN `cron_interval` varchar(100) default '' AFTER `execute`;
+ALTER TABLE `tncm_agent` ADD COLUMN `event_on_change` int unsigned default null AFTER `cron_interval`;
+ALTER TABLE `tncm_vendor` ADD COLUMN `icon` VARCHAR(255) DEFAULT '';
+ALTER TABLE `tevento` MODIFY COLUMN `event_type` ENUM('going_unknown','unknown','alert_fired','alert_recovered','alert_ceased','alert_manual_validation','recon_host_detected','system','error','new_agent','going_up_warning','going_up_critical','going_down_warning','going_down_normal','going_down_critical','going_up_normal', 'configuration_change', 'ncm') DEFAULT 'unknown';
INSERT IGNORE INTO `talert_calendar` VALUES (1, 'Default', 0, 'Default calendar');
UPDATE `talert_special_days` set `day_code` = 1 WHERE `same_day` = 'monday';
diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
index e43e977ec1..20d5ba6324 100644
--- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
@@ -4135,6 +4135,7 @@ UPDATE `tlanguage` SET `name` = 'Deutsch' WHERE `id_language` = 'de';
CREATE TABLE IF NOT EXISTS `tncm_vendor` (
`id` serial,
`name` varchar(255) UNIQUE,
+ `icon` VARCHAR(255) DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -4199,6 +4200,8 @@ CREATE TABLE IF NOT EXISTS `tncm_agent` (
`id_template` bigint(20) unsigned,
`execute_type` int(2) UNSIGNED NOT NULL default 0,
`execute` int(2) UNSIGNED NOT NULL default 0,
+ `cron_interval` varchar(100) default '',
+ `event_on_change` int unsigned default null,
`last_error` text,
PRIMARY KEY (`id_agent`),
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
@@ -4221,6 +4224,41 @@ CREATE TABLE IF NOT EXISTS `tncm_agent_data` (
FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+-- ----------------------------------------------------------------------
+-- Table `tncm_queue`
+-- ----------------------------------------------------------------------
+CREATE TABLE IF NOT EXISTS `tncm_queue` (
+ `id` SERIAL,
+ `id_agent` INT(10) UNSIGNED NOT NULL,
+ `id_script` BIGINT(20) UNSIGNED NOT NULL,
+ `utimestamp` INT UNSIGNED NOT NULL,
+ `scheduled` INT UNSIGNED DEFAULT NULL,
+ FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE,
+ FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------------------------------------------------
+-- Table `tncm_snippet`
+-- ----------------------------------------------------------------------
+CREATE TABLE IF NOT EXISTS `tncm_snippet` (
+ `id` SERIAL,
+ `name` TEXT,
+ `content` TEXT,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+-- ----------------------------------------------------------------------
+-- Table `tncm_firmware`
+-- ----------------------------------------------------------------------
+CREATE TABLE IF NOT EXISTS `tncm_firmware` (
+ `id` SERIAL,
+ `name` varchar(255),
+ `shortname` varchar(255) unique,
+ `vendor` bigint(20) unsigned,
+ `models` text,
+ `path` text,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `tncm_vendor` VALUES
(1,'Cisco'),
@@ -4247,9 +4285,9 @@ INSERT INTO `tncm_script` VALUES
(2,1,'enable
expect:Password:\s*
_enablepass_
term length 0
capture:show running-config
exit
'),
(3,2,'enable
expect:Password:\s*
_enablepass_
term length 0
config terminal
_applyconfigbackup_
exit
'),
(4,3,'enable
expect:Password:\s*
_enablepass_
term length 0
capture:show version | i IOS Software
exit
'),
- (5,5,'enable
expect:Password:\s*
_enablepass_
term length 0
config term
end
end
exit
');
-
-INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5);
+ (5,5,'enable
expect:Password:\s*
_enablepass_
term length 0
config term
end
end
exit
'),
+ (6,4,'copy tftp flash
expect:\]\?
_TFTP_SERVER_IP_
expect:\]\?
_SOURCE_FILE_NAME_
expect:\]\?
_DESTINATION_FILE_NAME_
show flash
reload
expect:confirm
y
config terminal
boot system _DESTINATION_FILE_NAME_');
+INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6);
-- ----------------------------------------------------------------------
-- Table `talert_calendar`
diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php
index 23a0e401d5..2d77e7de29 100644
--- a/pandora_console/godmode/agentes/agent_manager.php
+++ b/pandora_console/godmode/agentes/agent_manager.php
@@ -103,10 +103,10 @@ if (is_ajax()) {
} else {
$commons = array_intersect($out, $oid_snmp);
if ($get_common_modules) {
- // Common modules is selected (default)
+ // Common modules is selected (default).
$out = $commons;
} else {
- // All modules is selected
+ // All modules is selected.
$array1 = array_diff($out, $oid_snmp);
$array2 = array_diff($oid_snmp, $out);
$out = array_merge($commons, $array1, $array2);
@@ -135,12 +135,12 @@ if (is_ajax()) {
'agents_update_secondary_groups',
[
$id_agent,
- ($add_secondary_groups) ? $groups_to_add : [],
- ($remove_secondary_groups) ? $groups_to_add : [],
+ (($add_secondary_groups) ? $groups_to_add : []),
+ (($remove_secondary_groups) ? $groups_to_add : []),
]
);
// Echo 0 in case of error. 0 Otherwise.
- echo ($ret) ? 1 : 0;
+ echo ((bool) $ret === true) ? 1 : 0;
}
}
diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
index 81b6877cc2..9d5925b7e6 100755
--- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php
+++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php
@@ -893,6 +893,10 @@ switch ($action) {
$select_by_group = $es['select_by_group'];
break;
+ case 'ncm':
+ $idAgent = $item['id_agent'];
+ break;
+
default:
// It's not possible.
break;
@@ -4000,23 +4004,23 @@ function print_SLA_list($width, $action, $idItem=null)
],
]
);
- if (!empty($services_tmp)
- && $services_tmp != ENTERPRISE_NOT_HOOK
- ) {
- foreach ($services_tmp as $service) {
- $check_module_sla = modules_check_agentmodule_exists(
- $service['sla_id_module']
- );
- $check_module_sla_value = modules_check_agentmodule_exists(
- $service['sla_value_id_module']
- );
- if ($check_module_sla
- && $check_module_sla_value
+ if (!empty($services_tmp)
+ && $services_tmp != ENTERPRISE_NOT_HOOK
) {
- $services[$service['id']] = $service['name'];
+ foreach ($services_tmp as $service) {
+ $check_module_sla = modules_check_agentmodule_exists(
+ $service['sla_id_module']
+ );
+ $check_module_sla_value = modules_check_agentmodule_exists(
+ $service['sla_value_id_module']
+ );
+ if ($check_module_sla
+ && $check_module_sla_value
+ ) {
+ $services[$service['id']] = $service['name'];
+ }
+ }
}
- }
- }
echo '
';
echo html_print_select(
@@ -6593,6 +6597,11 @@ function chooseType() {
} else {
$("#row_profiles_group").hide();
}
+ break;
+
+ case 'ncm':
+ $("#row_agent").show();
+ break;
}
diff --git a/pandora_console/images/ncm/cisco.png b/pandora_console/images/ncm/cisco.png
new file mode 100755
index 0000000000..fa2f8c2812
Binary files /dev/null and b/pandora_console/images/ncm/cisco.png differ
diff --git a/pandora_console/images/ncm/default.png b/pandora_console/images/ncm/default.png
new file mode 100644
index 0000000000..83f5e691ca
Binary files /dev/null and b/pandora_console/images/ncm/default.png differ
diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php
index 872f4a0496..8ded979b77 100644
--- a/pandora_console/include/db/mysql.php
+++ b/pandora_console/include/db/mysql.php
@@ -778,8 +778,59 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
$not = (($negative === true) ? ' !' : '');
$query .= sprintf('%s %s= %f', $field, $not, $value);
} else if (is_array($value)) {
- $not = (($negative === true) ? 'NOT' : '');
- $query .= sprintf('%s %s IN ("%s")', $field, $not, implode('", "', $value));
+ $values_check = array_keys($value);
+ $ranges = false;
+ $initialized = false;
+ foreach ($values_check as $operation) {
+ if ($ranges === true && $initialized === true) {
+ $query .= ' '.$join.' ';
+ } else {
+ $initialized = true;
+ }
+
+ if ($operation === '>') {
+ $query .= sprintf("%s > '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($operation === '>=') {
+ $query .= sprintf("%s >= '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($operation === '<') {
+ $query .= sprintf("%s < '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($operation === '<=') {
+ $query .= sprintf("%s <= '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($operation === '!=') {
+ $query .= sprintf("%s != '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($operation === '=') {
+ $query .= sprintf("%s = '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($negative === true && $operation === '>') {
+ $query .= sprintf("%s <= '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($negative === true && $operation === '>=') {
+ $query .= sprintf("%s < '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($negative === true && $operation === '<') {
+ $query .= sprintf("%s >= '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($negative === true && $operation === '<=') {
+ $query .= sprintf("%s > '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($negative === true && $operation === '!=') {
+ $query .= sprintf("%s = '%s'", $field, $value[$operation]);
+ $ranges = true;
+ } else if ($negative === true && $operation === '=') {
+ $query .= sprintf("%s != '%s'", $field, $value[$operation]);
+ $ranges = true;
+ }
+ }
+
+ if ($ranges !== true) {
+ $not = (($negative === true) ? 'NOT' : '');
+ $query .= sprintf('%s %s IN ("%s")', $field, $not, implode('", "', $value));
+ }
} else {
if ($value === '') {
// Search empty string.
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 90d2dfd984..9b617af6aa 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -1234,6 +1234,7 @@ function get_event_types($id_type=false)
$types['system'] = __('System');
$types['error'] = __('Error');
$types['configuration_change'] = __('Configuration change');
+ $types['ncm'] = __('Network configuration manager');
// This types are impersonated by the monitor 'x' types
// $types['going_up_normal'] = __('Going Normal');
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index d10a36c47c..3d7de884d6 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -3248,6 +3248,10 @@ function events_get_event_types($type_id)
$type_desc = __('Not normal');
break;
+ case 'ncm':
+ $type_desc = __('Network configuration manager');
+ break;
+
default:
if (isset($config['text_char_long'])) {
foreach ($diferent_types as $key => $type) {
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index ad17a5ad99..374e724efd 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -4096,6 +4096,10 @@ function html_print_input_file($name, $return=false, $options=false)
if (isset($options['required'])) {
$output .= ' required';
}
+
+ if (isset($options['onchange'])) {
+ $output .= ' onchange="'.$options['onchange'].'"';
+ }
}
$output .= ' />';
@@ -4488,7 +4492,7 @@ function html_print_switch($attributes=[])
$disabled_class = (bool) ($attributes['disabled']) ? ' p-slider-disabled' : '';
- return " |