2013-09-05 Ramon Novoa <rnovoa@artica.es>
* extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql, godmode/agentes/configurar_agente.php, godmode/agentes/agent_template.php, godmode/agentes/module_manager_editor_common.php, godmode/agentes/module_manager_editor.php, include/functions_modules.php, pandoradb.sql: Added support for module macros. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8747 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c824039a28
commit
ca1a5f2160
|
@ -1,3 +1,17 @@
|
|||
2013-09-05 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
|
||||
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
|
||||
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
|
||||
pandoradb.postgreSQL.sql,
|
||||
pandoradb.oracle.sql,
|
||||
godmode/agentes/configurar_agente.php,
|
||||
godmode/agentes/agent_template.php,
|
||||
godmode/agentes/module_manager_editor_common.php,
|
||||
godmode/agentes/module_manager_editor.php,
|
||||
include/functions_modules.php,
|
||||
pandoradb.sql: Added support for module macros.
|
||||
|
||||
2013-09-05 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* godmode/agentes/module_manager.php
|
||||
|
|
|
@ -185,6 +185,7 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `cron_interval` varchar(100) default '';
|
|||
ALTER TABLE `tagente_modulo` ADD COLUMN `max_retries` int(4) UNSIGNED NOT NULL default 0;
|
||||
ALTER TABLE `tagente_modulo` ADD COLUMN `id_category` int(10) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `tagente_modulo` ADD COLUMN `disabled_types_event` TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE `tagente_modulo` ADD COLUMN `module_macros` TEXT NOT NULL DEFAULT '';
|
||||
|
||||
-- Move the number of retries for web modules from plugin_pass to max_retries
|
||||
UPDATE `tagente_modulo` SET max_retries=plugin_pass WHERE id_modulo=7;
|
||||
|
@ -205,6 +206,7 @@ ALTER TABLE `tnetwork_component` ADD COLUMN `max_retries` int(4) UNSIGNED NOT NU
|
|||
ALTER TABLE `tnetwork_component` ADD COLUMN `id_category` int(10) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `tnetwork_component` ADD COLUMN `tags` TEXT NOT NULL default '';
|
||||
ALTER TABLE `tnetwork_component` ADD COLUMN `disabled_types_event` TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE `tnetwork_component` ADD COLUMN `module_macros` TEXT NOT NULL DEFAULT '';
|
||||
|
||||
-- ----------------------------------------------------------------------
|
||||
-- Table `tgraph_source` Alter table to allow negative values in weight
|
||||
|
|
|
@ -320,6 +320,7 @@ ALTER TABLE tnetwork_component ADD (wizard_level VARCHAR2(100) default 'nowizard
|
|||
ALTER TABLE tnetwork_component ADD CONSTRAINT t_network_component_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','nowizard'));
|
||||
ALTER TABLE tnetwork_component ADD (macros CLOB default '');
|
||||
ALTER TABLE tnetwork_component ADD (disabled_types_event CLOB default '');
|
||||
ALTER TABLE tnetwork_component ADD (module_macros CLOB default '');
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
|
@ -332,6 +333,7 @@ ALTER TABLE tagente_modulo ADD (quiet NUMBER(5, 0) default 0 NOT NULL);
|
|||
ALTER TABLE tagente_modulo ADD (cron_interval VARCHAR2(100) DEFAULT '');
|
||||
ALTER TABLE tagente_modulo ADD (max_retries NUMBER(10, 0) default 0);
|
||||
ALTER TABLE tagente_modulo ADD (disabled_types_event CLOB default '');
|
||||
ALTER TABLE tagente_modulo ADD (module_macros CLOB default '');
|
||||
|
||||
|
||||
-- Move the number of retries for web modules from plugin_pass to max_retries
|
||||
|
|
|
@ -208,6 +208,7 @@ ALTER TABLE "tagente_modulo" ADD COLUMN "cron_interval" varchar(100) default '';
|
|||
ALTER TABLE "tagente_modulo" ADD COLUMN "max_retries" INTEGER default 0;
|
||||
ALTER TABLE "tagente_modulo" ADD COLUMN "id_category" INTEGER default 0;
|
||||
ALTER TABLE "tagente_modulo" ADD COLUMN "disabled_types_event" TEXT default '';
|
||||
ALTER TABLE "tagente_modulo" ADD COLUMN "module_macros" TEXT default '';
|
||||
|
||||
-- Move the number of retries for web modules from plugin_pass to max_retries
|
||||
UPDATE "tagente_modulo" SET max_retries=CAST(plugin_pass AS INT) WHERE id_modulo=7;
|
||||
|
@ -289,6 +290,7 @@ ALTER TABLE "tnetwork_component" ADD COLUMN "critical_inverse" SMALLINT NOT NULL
|
|||
ALTER TABLE "tnetwork_component" ADD COLUMN "warning_inverse" SMALLINT NOT NULL default 0;
|
||||
ALTER TABLE "tnetwork_component" ADD COLUMN "tags" text default '';
|
||||
ALTER TABLE "tnetwork_component" ADD COLUMN "disabled_types_event" TEXT default '';
|
||||
ALTER TABLE "tnetwork_component" ADD COLUMN "module_macros" TEXT default '';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table "talert_commands"
|
||||
|
|
|
@ -95,7 +95,8 @@ if (isset ($_POST["template_id"])) {
|
|||
'critical_instructions' => $row2['critical_instructions'],
|
||||
'warning_instructions' => $row2['warning_instructions'],
|
||||
'unknown_instructions' => $row2['unknown_instructions'],
|
||||
'id_category' => $row2['id_category']
|
||||
'id_category' => $row2['id_category'],
|
||||
'module_macros' => $row2['module_macros']
|
||||
);
|
||||
|
||||
$name = $row2["name"];
|
||||
|
|
|
@ -142,6 +142,7 @@ $quiet = 0;
|
|||
$macros = '';
|
||||
|
||||
$create_agent = (bool)get_parameter('create_agent');
|
||||
$module_macros = array ();
|
||||
|
||||
// Create agent
|
||||
if ($create_agent) {
|
||||
|
@ -894,6 +895,10 @@ if ($update_module || $create_module) {
|
|||
//Set the event type that can show.
|
||||
$disabled_types_event = array(EVENTS_GOING_UNKNOWN => (int)!$throw_unknown_events);
|
||||
$disabled_types_event = json_encode($disabled_types_event);
|
||||
|
||||
$module_macro_names = (array) get_parameter('module_macro_names', array());
|
||||
$module_macro_values = (array) get_parameter('module_macro_values', array());
|
||||
$module_macros = modules_get_module_macros_json ($module_macro_names, $module_macro_values);
|
||||
|
||||
// Make changes in the conf file if necessary
|
||||
enterprise_include_once('include/functions_config_agents.php');
|
||||
|
@ -953,7 +958,8 @@ if ($update_module) {
|
|||
'warning_inverse' => $warning_inverse,
|
||||
'cron_interval' => $cron_interval,
|
||||
'id_category' => $id_category,
|
||||
'disabled_types_event' => $disabled_types_event);
|
||||
'disabled_types_event' => $disabled_types_event,
|
||||
'module_macros' => $module_macros);
|
||||
|
||||
if ($prediction_module == 3 && $serialize_ops == '') {
|
||||
$result = false;
|
||||
|
@ -1076,7 +1082,8 @@ if ($create_module) {
|
|||
'warning_inverse' => $warning_inverse,
|
||||
'cron_interval' => $cron_interval,
|
||||
'id_category' => $id_category,
|
||||
'disabled_types_event' => $disabled_types_event);
|
||||
'disabled_types_event' => $disabled_types_event,
|
||||
'module_macros' => $module_macros);
|
||||
|
||||
if ($prediction_module == 3 && $serialize_ops == '') {
|
||||
$id_agent_module = false;
|
||||
|
|
|
@ -230,6 +230,8 @@ if ($id_agent_module) {
|
|||
$month = '*';
|
||||
$wday = '*';
|
||||
}
|
||||
|
||||
$module_macros = json_decode(base64_decode($module['module_macros']));
|
||||
}
|
||||
else {
|
||||
if (!isset ($moduletype)) {
|
||||
|
@ -302,6 +304,8 @@ else {
|
|||
$wday = '*';
|
||||
|
||||
$ff_interval = 0;
|
||||
|
||||
$module_macros = array ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,6 +426,7 @@ echo '<form method="post" id="module_form">';
|
|||
html_print_table ($table_simple);
|
||||
|
||||
ui_toggle(html_print_table ($table_advanced, true), __('Advanced options'));
|
||||
ui_toggle(html_print_table ($table_macros, true), __('Module macros'));
|
||||
|
||||
|
||||
// Submit
|
||||
|
|
|
@ -471,6 +471,32 @@ else {
|
|||
$table_advanced->data[12][4] .= html_print_input_hidden ('id_category', $id_category, true);
|
||||
}
|
||||
|
||||
/* Advanced form part */
|
||||
$table_macros->id = 'module_macros';
|
||||
$table_macros->width = '98%';
|
||||
$table_macros->class = 'databox_color';
|
||||
$table_macros->data = array ();
|
||||
$table_macros->style = array ();
|
||||
$table_macros->style[0] = 'font-weight: bold; vertical-align: top';
|
||||
$table_macros->style[2] = 'font-weight: bold; vertical-align: top';
|
||||
$table_macros->style[5] = 'width: 10px';
|
||||
$table_macros->colspan = array ();
|
||||
|
||||
$macro_count = 0;
|
||||
foreach ($module_macros as $macro_name => $macro_value) {
|
||||
$table_macros->data[$macro_count][0] = __('Name');
|
||||
$table_macros->data[$macro_count][1] = html_print_input_text ('module_macro_names[]', $macro_name, '', 50, 60, true);
|
||||
$table_macros->data[$macro_count][2] = __('Value');
|
||||
$table_macros->data[$macro_count][3] = html_print_input_text ('module_macro_values[]', $macro_value, '', 50, 60, true);
|
||||
$table_macros->data[$macro_count][4] = '<a href="javascript: delete_macro(' . $macro_count . ');">' . html_print_image('images/cross.png', true) . '</a>';
|
||||
$macro_count++;
|
||||
}
|
||||
$table_macros->data[$macro_count][0] = '<span>'.__('Add module macro').'</span> <a href="javascript:add_macro();">'.html_print_image('images/add.png',true).'</a>';
|
||||
$table_macros->colspan[$macro_count][0] = 5;
|
||||
$macro_count++;
|
||||
|
||||
html_print_input_hidden ('module_macro_count', $macro_count);
|
||||
|
||||
ui_require_jquery_file('json');
|
||||
|
||||
?>
|
||||
|
@ -542,5 +568,31 @@ $(document).ready (function () {
|
|||
|
||||
$("#id_module_type").trigger('change');
|
||||
});
|
||||
|
||||
// Add a new module macro
|
||||
function add_macro () {
|
||||
var macro_count = parseInt($("#hidden-module_macro_count").val());
|
||||
var delete_icon = '<?php html_print_image ("images/cross.png", false) ?>';
|
||||
|
||||
// Add inputs for the new macro
|
||||
$("#module_macros").append('<tr id="module_macros-' + macro_count + '" class="datos2"><td style=" font-weight: bold; vertical-align: top;" class="datos2">Name</td> \
|
||||
<td style="" class="datos2"><input type="text" name="module_macro_names[]" value="" id="text-module_macro_names[]" size="50" maxlength="60"></td> \
|
||||
<td style="font-weight: bold; vertical-align: top;" class="datos2">Value</td> \
|
||||
<td style="" class="datos2"><input type="text" name="module_macro_values[]" value="" id="text-module_macro_values[]" size="50" maxlength="60"></td> \
|
||||
<td style="" class="datos2"><a href="javascript: delete_macro(' + macro_count + ');">' + delete_icon + '</a></td></tr>');
|
||||
|
||||
// Update the macro count
|
||||
$("#hidden-module_macro_count").val(macro_count + 1);
|
||||
}
|
||||
|
||||
// Delete an existing module macro
|
||||
function delete_macro (num) {
|
||||
if ($("#module_macros-" + num).length) {
|
||||
$("#module_macros-" + num).remove();
|
||||
}
|
||||
|
||||
// Do not decrease the macro counter or new macros may overlap existing ones!
|
||||
}
|
||||
|
||||
/* ]]> */
|
||||
</script>
|
||||
|
|
|
@ -1661,4 +1661,17 @@ function modules_group_agent_warning ($module_group) {
|
|||
AND critical_count = 0 AND warning_count > 0
|
||||
AND id_module_group = $module_group");
|
||||
}
|
||||
|
||||
// Return a base64 encoded JSON document to store module macros inside the database
|
||||
function modules_get_module_macros_json ($macro_names, $macro_values) {
|
||||
$module_macros = array ();
|
||||
for ($i = 0; $i < count($macro_names); $i++) {
|
||||
if (isset ($macro_values[$i])) {
|
||||
$module_macros[$macro_names[$i]] = $macro_values[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return base64_encode(json_encode ($module_macros));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -248,6 +248,7 @@ CREATE TABLE tagente_modulo (
|
|||
warning_inverse NUMBER(1, 0) default 0 NOT NULL,
|
||||
id_category NUMBER(10, 0) default 0 NOT NULL,
|
||||
disabled_types_event CLOB default '',
|
||||
module_macros CLOB default '',
|
||||
|
||||
CONSTRAINT t_agente_modulo_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','nowizard'))
|
||||
);
|
||||
|
@ -702,6 +703,7 @@ CREATE TABLE tnetwork_component (
|
|||
id_category NUMBER(10, 0) default 0 NOT NULL,
|
||||
tags CLOB,
|
||||
disabled_types_event CLOB default '',
|
||||
module_macros CLOB default '',
|
||||
|
||||
CONSTRAINT t_network_component_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','nowizard'))
|
||||
);
|
||||
|
|
|
@ -236,7 +236,8 @@ CREATE TABLE "tagente_modulo" (
|
|||
"critical_inverse" SMALLINT NOT NULL default 0,
|
||||
"warning_inverse" SMALLINT NOT NULL default 0,
|
||||
"id_category" INTEGER NOT NULL default 0,
|
||||
"disabled_types_event" TEXT default ''
|
||||
"disabled_types_event" TEXT default '',
|
||||
"module_macros" TEXT default ''
|
||||
);
|
||||
CREATE INDEX "tagente_modulo_id_agente_idx" ON "tagente_modulo"("id_agente");
|
||||
CREATE INDEX "tagente_modulo_id_tipo_modulo_idx" ON "tagente_modulo"("id_tipo_modulo");
|
||||
|
@ -599,7 +600,8 @@ CREATE TABLE "tnetwork_component" (
|
|||
"warning_inverse" SMALLINT NOT NULL default 0,
|
||||
"id_category" INTEGER NOT NULL default 0,
|
||||
"tags" text NOT NULL,
|
||||
"disabled_types_event" TEXT default ''
|
||||
"disabled_types_event" TEXT default '',
|
||||
"module_macros" TEXT default ''
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
|
|
|
@ -233,6 +233,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
|
|||
`warning_inverse` tinyint(1) unsigned default '0',
|
||||
`id_category` int(10) default 0,
|
||||
`disabled_types_event` TEXT NOT NULL default '',
|
||||
`module_macros` TEXT NOT NULL default '',
|
||||
PRIMARY KEY (`id_agente_modulo`),
|
||||
KEY `main_idx` (`id_agente_modulo`,`id_agente`),
|
||||
KEY `tam_agente` (`id_agente`),
|
||||
|
@ -653,6 +654,7 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` (
|
|||
`id_category` int(10) default 0,
|
||||
`tags` text NOT NULL,
|
||||
`disabled_types_event` TEXT NOT NULL default '',
|
||||
`module_macros` TEXT NOT NULL default '',
|
||||
PRIMARY KEY (`id_nc`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
Loading…
Reference in New Issue