2014-04-22 Sergio Martin <sergio.martin@artica.es>

* pandoradb.postgreSQL.sql
	pandoradb.oracle.sql
	pandoradb.data.postgreSQL.sql
	pandoradb.data.oracle.sql
	extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
	extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql
	extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
	godmode/agentes/module_manager_editor_plugin.php
	godmode/servers/plugin.php
	godmode/servers/manage_recontask.php
	godmode/servers/manage_recontask_form.php
	godmode/servers/recon_script.php
	pandoradb_data.sql
	include/javascript/pandora_modules.js
	pandoradb.sql: Changed the recon scripts parameters to
	dynamic fields like plugin macros. 
	Fixed some plugin macros bugs in the new hide parameter



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9796 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2014-04-22 09:26:55 +00:00
parent 21b0374ab1
commit 09f4f3c307
16 changed files with 369 additions and 57 deletions

View File

@ -1,3 +1,23 @@
2014-04-22 Sergio Martin <sergio.martin@artica.es>
* pandoradb.postgreSQL.sql
pandoradb.oracle.sql
pandoradb.data.postgreSQL.sql
pandoradb.data.oracle.sql
extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql
extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
godmode/agentes/module_manager_editor_plugin.php
godmode/servers/plugin.php
godmode/servers/manage_recontask.php
godmode/servers/manage_recontask_form.php
godmode/servers/recon_script.php
pandoradb_data.sql
include/javascript/pandora_modules.js
pandoradb.sql: Changed the recon scripts parameters to
dynamic fields like plugin macros.
Fixed some plugin macros bugs in the new hide parameter
2014-04-21 Hirofumi Kosaka <kosaka@rworks.jp>
* godmode/massive/massive_enable_disable_alerts.php,

View File

@ -147,3 +147,10 @@ INSERT INTO `trecon_script` VALUES (4,'SNMP&#x20;L2&#x20;Recon','Pandora&#x20;FM
/* 2014/04/10 */
ALTER TABLE `treport_content` ADD COLUMN `name` varchar(150) NULL;
/* 2014/04/11 */
-- ---------------------------------------------------------------------
-- Table `trecon_script` and `trecon_task`
-- ---------------------------------------------------------------------
ALTER TABLE `trecon_script` ADD COLUMN `macros` TEXT;
ALTER TABLE `trecon_task` ADD COLUMN `macros` TEXT;

View File

@ -131,3 +131,10 @@ ALTER TABLE treport ADD (non_interactive NUMBER(5, 0) default 0 NOT NULL);
/* 2014/04/10 */
ALTER TABLE treport_content ADD (name VARCHAR2(150) default NULL);
/* 2014/04/11 */
-- ---------------------------------------------------------------------
-- Table `trecon_script` and `trecon_task`
-- ---------------------------------------------------------------------
ALTER TABLE trecon_script ADD (macros CLOB default '' NOT NULL);
ALTER TABLE trecon_task ADD (macros CLOB default '' NOT NULL);

View File

@ -104,3 +104,10 @@ ALTER TABLE "treport" ADD COLUMN "non_interactive" SMALLINT DEFAULT 0;
/* 2014/04/10 */
ALTER TABLE "treport_content" ADD COLUMN "name" varchar(150) NULL;
/* 2014/04/11 */
-- ---------------------------------------------------------------------
-- Table `trecon_script` and `trecon_task`
-- ---------------------------------------------------------------------
ALTER TABLE "trecon_script" ADD COLUMN "macros" TEXT default '';
ALTER TABLE "trecon_task" ADD COLUMN "macros" TEXT default '';

View File

@ -84,7 +84,12 @@ if (!empty($macros)) {
if (!empty($m['help'])) {
$data[0] .= ui_print_help_tip ($m['help'], true);
}
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true);
if($m['hide']) {
$data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true);
}
else {
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true);
}
$table_simple->colspan['macro'.$m['macro']][1] = 3;
$table_simple->rowclass['macro'.$m['macro']] = 'macro_field';
@ -107,4 +112,4 @@ if (!empty($macros)) {
//In the file pandora_modules.js
load_module_component = true;
}
</script>
</script>

View File

@ -94,6 +94,19 @@ if ((isset ($_GET["update"])) OR ((isset ($_GET["create"])))) {
$resolve_names = (int) get_parameter ("resolve_names", 0);
$parent_detection = (int) get_parameter ("parent_detection", 0);
$parent_recursion = (int) get_parameter ("parent_recursion", 1);
// Get macros
$macros = (string) get_parameter ('macros');
if (!empty($macros)) {
$macros = json_decode(base64_decode($macros), true);
foreach($macros as $k => $m) {
$macros[$k]['value'] = get_parameter($m['macro'], '');
}
}
$macros = json_encode($macros);
}
// --------------------------------
@ -122,7 +135,8 @@ if (isset($_GET["update"])) {
'os_detect' => $os_detect,
'resolve_names' => $resolve_names,
'parent_detection' => $parent_detection,
'parent_recursion' => $parent_recursion
'parent_recursion' => $parent_recursion,
'macros' => $macros
);
$where = array('id_rt' => $id);
@ -175,7 +189,8 @@ if (isset($_GET["create"])) {
'os_detect' => $os_detect,
'resolve_names' => $resolve_names,
'parent_detection' => $parent_detection,
'parent_recursion' => $parent_recursion
'parent_recursion' => $parent_recursion,
'macros' => $macros
);
$reason = "";

View File

@ -39,6 +39,22 @@ if (is_ajax ()) {
return;
}
$get_recon_script_macros = get_parameter('get_recon_script_macros');
if ($get_recon_script_macros) {
$id_recon_script = get_parameter('id', 0);
$recon_script_macros = db_get_value('macros', 'trecon_script', 'id_recon_script',
$id_recon_script);
$macros = array();
$macros['base64'] = base64_encode($recon_script_macros);
$macros['array'] = json_decode($recon_script_macros,true);
echo json_encode($macros);
return;
}
return;
}
@ -86,6 +102,7 @@ if (isset ($_GET["update"]) or (isset($_GET["crt"]))) {
$resolve_names = $row["resolve_names"];
$parent_detection = $row["parent_detection"];
$parent_recursion = $row["parent_recursion"];
$macros = $row["macros"];
}
}
elseif (isset ($_GET["create"]) or isset($_GET["crt"])) {
@ -119,6 +136,7 @@ elseif (isset ($_GET["create"]) or isset($_GET["crt"])) {
$resolve_names = 0;
$parent_detection = 1;
$parent_recursion = 5;
$macros = '';
}
}
@ -126,6 +144,7 @@ elseif (isset ($_GET["create"]) or isset($_GET["crt"])) {
ui_print_page_header (__('Manage recontask'), "", false, "recontask", true);
$table->id='table_recon';
$table->width='98%';
$table->cellspacing=4;
$table->cellpadding=4;
@ -190,6 +209,7 @@ $table->data[5][1] = html_print_select_from_sql ('SELECT id_np, name FROM tnetwo
$table->data[6][0] = "<b>".__('Recon script');
$table->data[6][1] = html_print_select_from_sql ('SELECT id_recon_script, name FROM trecon_script',
"id_recon_script", $id_recon_script, 'get_explanation_recon_script($(\'#id_recon_script\').val())', '', '', true);
$table->data[6][1] .= $data[1] .= html_print_input_hidden('macros',base64_encode($macros),true);
// OS
@ -223,27 +243,43 @@ $table->data[11][0] = "<b>".__('SNMP Default community');
$table->data[11][1] = html_print_input_text ('snmp_community', $snmp_community, '', 35, 0, true);
$explanation = db_get_value('description', 'trecon_script', 'id_recon_script', $id_recon_script);
$table->data[12][0] = "<b>" . __('Explanation') . "</b>";
$table->data[12][1] = "<span id='spinner_layour' style='display: none;'>" . html_print_image ("images/spinner.gif", true) .
"</span>" . html_print_textarea('explanation', 4, 60, '', 'style="width: 388px;"', true);
"</span>" . html_print_textarea('explanation', 4, 60, $explanation, 'style="width: 388px;"', true);
// A hidden "model row" to clone it from javascript to add fields dynamicly
$data = array ();
$data[0] = 'macro_desc';
$data[0] .= ui_print_help_tip ('macro_help', true);
$data[1] = html_print_input_text ('macro_name', 'macro_value', '', 100, 255, true);
$table->colspan['macro_field'][1] = 3;
$table->rowstyle['macro_field'] = 'display:none';
$table->data['macro_field'] = $data;
// Field1
$table->data[13][0] = "<b>".__('Script field #1').ui_print_help_tip(__("several networks separated by comma. For example: 192.168.100.0/24,192.168.50.0/24"), true);
$table->data[13][1] = html_print_input_text ('field1', $field1, '', 40, 0, true);
// Field2
$table->data[14][0] = "<b>".__('Script field #2').ui_print_help_tip(__("several communities separated by comma. For example: snmp_community,public,private "), true);
$table->data[14][1] = html_print_input_text ('field2', $field2, '', 40, 0, true);
// Field3
$table->data[15][0] = "<b>".__('Script field #3');
$table->data[15][1] = html_print_input_text ('field3', $field3, '', 40, 0, true);
// Field4
$table->data[16][0] = "<b>".__('Script field #4');
$table->data[16][1] = html_print_input_text ('field4', $field4, '', 40, 0, true);
// If there are $macros, we create the form fields
if (!empty($macros)) {
$macros = json_decode($macros, true);
foreach ($macros as $k => $m) {
$data = array ();
$data[0] = "<b>" . $m['desc'] . "</b>";
if (!empty($m['help'])) {
$data[0] .= ui_print_help_tip ($m['help'], true);
}
if($m['hide']) {
$data[1] = html_print_input_password($m['macro'], $m['value'], '', 100, 255, true);
}
else {
$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true);
}
$table->colspan['macro'.$m['macro']][1] = 3;
$table->rowclass['macro'.$m['macro']] = 'macro_field';
$table->data['macro'.$m['macro']] = $data;
}
}
// Comments
$table->data[17][0] = "<b>".__('Comments');
@ -277,6 +313,8 @@ echo "</div>";
echo "</form>";
ui_require_javascript_file ('pandora_modules');
?>
<script type="text/javascript">
/* <![CDATA[ */
@ -317,6 +355,35 @@ function get_explanation_recon_script(id) {
$("#textarea_explanation").val(data);
}
);
var params = [];
params.push("page=godmode/servers/manage_recontask_form");
params.push("get_recon_script_macros=1");
params.push("id=" + id);
jQuery.ajax ({
data: params.join ("&"),
type: 'POST',
url: action = get_php_value('absolute_homeurl') + "ajax.php",
async: false,
timeout: 10000,
dataType: 'json',
success: function (data) {
// Delete all the macro fields
$('.macro_field').remove();
if (data['array'] != null) {
$('#hidden-macros').val(data['base64']);
jQuery.each (data['array'], function (i, macro) {
if (macro['desc'] != '') {
add_macro_field(macro, 'table_recon-macro');
}
});
}
forced_title_callback();
}
});
}
/* ]]> */
</script>

View File

@ -283,7 +283,7 @@ if (($create != "") OR ($view != "")) {
$macro_name_name = 'field'.$i.'_macro';
$macro_name = '_field'.$i.'_';
$macro_hide_value_name = 'field'.$i.'_hide';
$macro_hide_value_value = 1;
$macro_hide_value_value = 0;
if(isset($macros[$i]['desc'])) {
$macro_desc_value = $macros[$i]['desc'];
@ -297,6 +297,10 @@ if (($create != "") OR ($view != "")) {
$macro_value_value = $macros[$i]['value'];
}
if(isset($macros[$i]['hide'])) {
$macro_hide_value_value = $macros[$i]['hide'];
}
$datam = array ();
$datam[0] = __('Description')."<span style='font-weight: normal'> ($macro_name)</span>";
$datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
@ -318,11 +322,13 @@ if (($create != "") OR ($view != "")) {
$table->colspan['plugin_'.$next_name_number][1] = 3;
$datam = array ();
$datam[0] = __('Hide value');
$datam[1] = html_print_checkbox_extended ($macro_hide_value_name, $macro_hide_value_value, 0, 0, '', array('class' => 'command_advanced_conf'), true, 'checkbox-'.$macro_hide_value_name);
$datam[0] = __('Hide value') . ui_print_help_tip(__('This field will show up as dots like a password'), true);
$datam[1] = html_print_checkbox_extended ($macro_hide_value_name, 1, $macro_hide_value_value, 0, '', array('class' => 'command_advanced_conf'), true, 'checkbox-'.$macro_hide_value_name);
$table->data['plugin_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['plugin_'.$next_name_number][1] = 3;
$datam = array ();
$datam[0] = __('Help')."<span style='font-weight: normal'> ($macro_name)</span><br><br><br>";
@ -411,11 +417,14 @@ else {
$desc = (string)get_parameter ('field'.$i.'_desc');
$help = (string)get_parameter ('field'.$i.'_help');
$value = (string)get_parameter ('field'.$i.'_value');
$hide = get_parameter ('field'.$i.'_hide');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$macros[$i]['hide'] = $hide;
$i++;
}

View File

@ -55,11 +55,13 @@ if ($view != "") {
$form_name = $reconscript["name"];
$form_description = $reconscript["description"];
$form_script = $reconscript ["script"];
$macros = $reconscript ["macros"];
}
if ($create != "") {
$form_name = "";
$form_description = "";
$form_script = "";
$macros = "";
}
// SHOW THE FORM
@ -80,22 +82,136 @@ if (($create != "") OR ($view != "")){
else
echo "<form name=reconscript method='post' action='index.php?sec=gservers&sec2=godmode/servers/recon_script&create_reconscript=1'>";
echo '<table width="98%" cellspacing="4" cellpadding="4" class="databox_color">';
$table->width = '98%';
$table->id = 'table-form';
$table->class = 'databox_color';
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
$table->data = array ();
echo '<tr><td class="datos">' . __('Name') . '</td>';
echo '<td class="datos">';
echo '<input type="text" name="form_name" size=30 value="'.$form_name.'"></td>';
$data = array();
$data[0] = __('Name');
$data[1] = '<input type="text" name="form_name" size=30 value="'.$form_name.'">';
$table->data['recon_name'] = $data;
$table->colspan['recon_name'][1] = 3;
echo '<tr><td class="datos2">' . __('Script fullpath') . '</td>';
echo '<td class="datos2">';
echo '<input type="text" name="form_script" size=70 value="'.$form_script.'"></td>';
$data = array();
$data[0] = __('Script fullpath');
$data[1] = '<input type="text" name="form_script" size=70 value="'.$form_script.'">';
$table->data['recon_fullpath'] = $data;
$table->colspan['recon_fullpath'][1] = 3;
$data = array();
$data[0] = __('Description');
$data[1] = '<textarea name="form_description" cols="50" rows="4">';
$data[1] .= $form_description;
$data[1] .= '</textarea>';
$table->data['recon_description'] = $data;
$table->colspan['recon_description'][1] = 3;
$macros = json_decode($macros,true);
echo '<tr><td class="datos2">' . __('Description') . '</td>';
echo '<td class="datos2"><textarea name="form_description" cols="50" rows="4">';
echo $form_description;
echo '</textarea></td></tr>';
// This code is ready to add locked feature as plugins
$locked = false;
// The next row number is recon_3
$next_name_number = 3;
$i = 1;
while (1) {
// Always print at least one macro
if((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
break;
}
$macro_desc_name = 'field'.$i.'_desc';
$macro_desc_value = '';
$macro_help_name = 'field'.$i.'_help';
$macro_help_value = '';
$macro_value_name = 'field'.$i.'_value';
$macro_value_value = '';
$macro_name_name = 'field'.$i.'_macro';
$macro_name = '_field'.$i.'_';
$macro_hide_value_name = 'field'.$i.'_hide';
$macro_hide_value_value = 0;
if(isset($macros[$i]['desc'])) {
$macro_desc_value = $macros[$i]['desc'];
}
if(isset($macros[$i]['help'])) {
$macro_help_value = $macros[$i]['help'];
}
if(isset($macros[$i]['value'])) {
$macro_value_value = $macros[$i]['value'];
}
if(isset($macros[$i]['hide'])) {
$macro_hide_value_value = $macros[$i]['hide'];
}
$datam = array ();
$datam[0] = __('Description')."<span style='font-weight: normal'> ($macro_name)</span>";
$datam[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
$datam[1] = html_print_input_text_extended ($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_advanced_conf'", true);
if($locked) {
$datam[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf'));
}
$datam[2] = __('Default value')."<span style='font-weight: normal'> ($macro_name)</span>";
$datam[3] = html_print_input_text_extended ($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_advanced_conf'", true);
if($locked) {
$datam[3] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf'));
}
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['recon_'.$next_name_number][1] = 3;
$datam = array ();
$datam[0] = __('Hide value') . ui_print_help_tip(__('This field will show up as dots like a password'), true);
$datam[1] = html_print_checkbox_extended ($macro_hide_value_name, 1, $macro_hide_value_value, 0, '', array('class' => 'command_advanced_conf'), true, 'checkbox-'.$macro_hide_value_name);
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$table->colspan['recon_'.$next_name_number][1] = 3;
$datam = array ();
$datam[0] = __('Help')."<span style='font-weight: normal'> ($macro_name)</span><br><br><br>";
$tadisabled = $locked === true ? ' disabled' : '';
$datam[1] = html_print_textarea ($macro_help_name, 6, 100, $macro_help_value, 'class="command_advanced_conf" style="width: 97%;"' . $tadisabled, true);
if($locked) {
$datam[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf'));
}
$datam[1] .= "<br><br><br>";
$table->data['recon_'.$next_name_number] = $datam;
$next_name_number++;
$i++;
}
if (!$locked) {
$datam = array ();
$datam[0] = '<span style="font-weight: bold">'.__('Add macro').'</span> <a href="javascript:new_macro(\'table-form-recon_\');update_preview();">'.html_print_image('images/add.png',true).'</a>';
$datam[0] .= '<div id="next_macro" style="display:none">'.$i.'</div>';
$datam[0] .= '<div id="next_row" style="display:none">'.$next_name_number.'</div>';
$delete_macro_style = '';
if($i <= 2) {
$delete_macro_style = 'display:none;';
}
$datam[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">'.__('Delete macro').' <a href="javascript:delete_macro(\'table-form-recon_\');update_preview();">'.html_print_image('images/delete.png',true).'</a></div>';
$table->colspan['recon_action'][0] = 2;
$table->rowstyle['recon_action'] = 'text-align:center';
$table->colspan['recon_action'][2] = 2;
$table->data['recon_action'] = $datam;
}
html_print_table($table);
echo '</table>';
echo '<table width=98%>';
echo '<tr><td align="right">';
@ -117,10 +233,35 @@ else {
$reconscript_description = get_parameter ("form_description", "");
$reconscript_script = get_parameter ("form_script", "");
// Get macros
$i = 1;
$macros = array();
while (1) {
$macro = (string)get_parameter ('field'.$i.'_macro');
if($macro == '') {
break;
}
$desc = (string)get_parameter ('field'.$i.'_desc');
$help = (string)get_parameter ('field'.$i.'_help');
$value = (string)get_parameter ('field'.$i.'_value');
$hide = get_parameter ('field'.$i.'_hide');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$macros[$i]['hide'] = $hide;
$i++;
}
$macros = io_json_mb_encode($macros);
$sql_update ="UPDATE trecon_script SET
name = '$reconscript_name',
description = '$reconscript_description',
script = '$reconscript_script'
script = '$reconscript_script',
macros = '$macros'
WHERE id_recon_script = $id_recon_script";
$result = false;
if ($reconscript_name != '' && $reconscript_script != '')
@ -139,10 +280,35 @@ else {
$reconscript_description = get_parameter ("form_description", "");
$reconscript_script = get_parameter ("form_script", "");
// Get macros
$i = 1;
$macros = array();
while (1) {
$macro = (string)get_parameter ('field'.$i.'_macro');
if($macro == '') {
break;
}
$desc = (string)get_parameter ('field'.$i.'_desc');
$help = (string)get_parameter ('field'.$i.'_help');
$value = (string)get_parameter ('field'.$i.'_value');
$hide = get_parameter ('field'.$i.'_hide');
$macros[$i]['macro'] = $macro;
$macros[$i]['desc'] = $desc;
$macros[$i]['help'] = $help;
$macros[$i]['value'] = $value;
$macros[$i]['hide'] = $hide;
$i++;
}
$macros = io_json_mb_encode($macros);
$values = array(
'name' => $reconscript_name,
'description' => $reconscript_description,
'script' => $reconscript_script);
'script' => $reconscript_script,
'macros' => $macros);
$result = false;
if ($values['name'] != '' && $values['script'] != '')
$result = db_process_sql_insert('trecon_script', $values);
@ -218,4 +384,8 @@ else {
echo "<input name='crtbutton' type='submit' class='sub next' value='".__('Add')."'>";
echo "</td></tr></table>";
}
ui_require_javascript_file('pandora_modules');
?>

View File

@ -461,13 +461,15 @@ function delete_macro(prefix) {
}
var next_row = parseInt($('#next_row').html());
$('#next_macro').html(next_number-1);
$('#next_row').html(next_row-2);
$('#next_row').html(next_row-3);
var nrow1 = next_row - 2;
var nrow2 = next_row - 1;
var nrow1 = next_row - 3;
var nrow2 = next_row - 2;
var nrow3 = next_row - 1;
var $row1 = $('#'+prefix+nrow1).remove();
var $row2 = $('#'+prefix+nrow2).remove();
var $row3 = $('#'+prefix+nrow3).remove();
}
function new_macro(prefix) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -840,7 +840,8 @@ CREATE TABLE trecon_script (
id_recon_script NUMBER(10, 0) NOT NULL PRIMARY KEY,
name VARCHAR2(100) default '',
description CLOB default NULL,
script VARCHAR2(250) default ''
script VARCHAR2(250) default '',
macros CLOB default ''
);
CREATE SEQUENCE trecon_script_s INCREMENT BY 1 START WITH 1;
@ -871,7 +872,8 @@ CREATE TABLE trecon_task (
resolve_names NUMBER(5, 0) default 1 NOT NULL,
parent_detection NUMBER(5, 0) default 1 NOT NULL,
parent_recursion NUMBER(5, 0) default 1 NOT NULL,
disabled NUMBER(5, 0) default 1 NOT NULL
disabled NUMBER(5, 0) default 1 NOT NULL,
macros CLOB default ''
);
CREATE INDEX trecon_task_id_rec_serv_idx ON trecon_task(id_recon_server);

View File

@ -737,7 +737,8 @@ CREATE TABLE "trecon_script" (
"id_recon_script" SERIAL NOT NULL PRIMARY KEY,
"name" varchar(100) default '',
"description" TEXT default NULL,
"script" varchar(250) default ''
"script" varchar(250) default '',
"macros" TEXT NOT NULL default ''
);
-- ---------------------------------------------------------------------
@ -767,7 +768,8 @@ CREATE TABLE "trecon_task" (
"resolve_names" SMALLINT NOT NULL default 1,
"parent_detection" SMALLINT NOT NULL default 1,
"parent_recursion" SMALLINT NOT NULL default 1,
"disabled" SMALLINT NOT NULL default 1
"disabled" SMALLINT NOT NULL default 1,
"macros" TEXT NOT NULL default ''
);
CREATE INDEX "trecon_task_id_recon_server_idx" ON "trecon_task"("id_recon_server");

View File

@ -800,6 +800,7 @@ CREATE TABLE IF NOT EXISTS `trecon_script` (
`name` varchar(100) default '',
`description` TEXT,
`script` varchar(250) default '',
`macros` TEXT,
PRIMARY KEY (`id_recon_script`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -831,6 +832,7 @@ CREATE TABLE IF NOT EXISTS `trecon_task` (
`parent_detection` tinyint(1) unsigned default '0',
`parent_recursion` tinyint(1) unsigned default '0',
`disabled` tinyint(1) unsigned NOT NULL DEFAULT '0',
`macros` TEXT,
PRIMARY KEY (`id_rt`),
KEY `recon_task_daemon` (`id_recon_server`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -996,12 +996,11 @@ INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (2, 'Monitoring&#x
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (3, 'Monitoring&#x20;Report&#x20;Alerts', 'select&#x20;t1.nombre&#x20;as&#x20;agent_name,&#x20;t2.nombre&#x20;as&#x20;module_name,&#x20;&#40;select&#x20;talert_templates.name&#x20;from&#x20;talert_templates&#x20;where&#x20;talert_templates.id&#x20;=&#x20;t3.id_alert_template&#41;&#x20;as&#x20;template,&#x20;&#40;select&#x20;group_concat&#40;t02.name&#41;&#x20;from&#x20;talert_template_module_actions&#x20;as&#x20;t01&#x20;inner&#x20;join&#x20;talert_actions&#x20;as&#x20;t02&#x20;on&#x20;t01.id_alert_action&#x20;=&#x20;t02.id&#x20;where&#x20;t01.id_alert_template_module&#x20;=&#x20;t3.id&#x20;group&#x20;by&#x20;t01.id_alert_template_module&#41;&#x20;as&#x20;actions&#x20;from&#x20;tagente&#x20;as&#x20;t1&#x20;inner&#x20;join&#x20;tagente_modulo&#x20;as&#x20;t2&#x20;on&#x20;t1.id_agente&#x20;=&#x20;t2.id_agente&#x20;inner&#x20;join&#x20;talert_template_modules&#x20;as&#x20;t3&#x20;on&#x20;t2.id_agente_modulo&#x20;=&#x20;t3.id_agent_module&#x20;order&#x20;by&#x20;agent_name,&#x20;module_name;');
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group&#x20;view', 'select&#x20;t1.nombre,&#x20;&#40;select&#x20;count&#40;t3.id_agente&#41;&#x20;from&#x20;tagente&#x20;as&#x20;t3&#x20;where&#x20;t1.id_grupo&#x20;=&#x20;t3.id_grupo&#41;&#x20;as&#x20;agents,&#x20;&#40;SELECT&#x20;COUNT&#40;t4.id_agente&#41;&#x20;FROM&#x20;tagente&#x20;as&#x20;t4&#x20;WHERE&#x20;t4.id_grupo&#x20;=&#x20;t1.id_grupo&#x20;AND&#x20;t4.disabled&#x20;=&#x20;0&#x20;AND&#x20;t4.ultimo_contacto&#x20;&lt;&#x20;NOW&#40;&#41;&#x20;-&#x20;&#40;intervalo&#x20;/&#x20;&#40;1/2&#41;&#41;&#41;&#x20;as&#x20;agent_unknown,&#x20;&#40;SELECT&#x20;COUNT&#40;tagente_estado.id_agente_estado&#41;&#x20;FROM&#x20;tagente_estado,&#x20;tagente,&#x20;tagente_modulo&#x20;WHERE&#x20;tagente.id_grupo&#x20;=&#x20;t1.id_grupo&#x20;AND&#x20;tagente.disabled&#x20;=&#x20;0&#x20;AND&#x20;tagente.id_agente&#x20;=&#x20;tagente_estado.id_agente&#x20;AND&#x20;tagente_estado.id_agente_modulo&#x20;=&#x20;tagente_modulo.id_agente_modulo&#x20;AND&#x20;tagente_modulo.disabled&#x20;=&#x20;0&#x20;AND&#x20;utimestamp&#x20;&gt;&#x20;0&#x20;AND&#x20;tagente_modulo.id_tipo_modulo&#x20;NOT&#x20;IN&#40;21,22,23,24,100&#41;&#x20;AND&#x20;&#40;UNIX_TIMESTAMP&#40;NOW&#40;&#41;&#41;&#x20;-&#x20;tagente_estado.utimestamp&#41;&#x20;&gt;=&#x20;&#40;tagente_estado.current_interval&#x20;/&#x20;&#40;1/2&#41;&#41;&#41;&#x20;as&#x20;monitor_unknow,&#x20;&#40;SELECT&#x20;COUNT&#40;tagente_estado.id_agente_estado&#41;&#x20;FROM&#x20;tagente_estado,&#x20;tagente,&#x20;tagente_modulo&#x20;WHERE&#x20;tagente.id_grupo&#x20;=&#x20;t1.id_grupo&#x20;AND&#x20;tagente.disabled&#x20;=&#x20;0&#x20;AND&#x20;tagente.id_agente&#x20;=&#x20;tagente_estado.id_agente&#x20;AND&#x20;tagente_estado.id_agente_modulo&#x20;=&#x20;tagente_modulo.id_agente_modulo&#x20;AND&#x20;tagente_modulo.disabled&#x20;=&#x20;0&#x20;AND&#x20;tagente_modulo.id_tipo_modulo&#x20;NOT&#x20;IN&#x20;&#40;21,22,23,24&#41;&#x20;AND&#x20;utimestamp&#x20;=&#x20;0&#41;&#x20;as&#x20;monitor_no_init,&#x20;&#40;SELECT&#x20;COUNT&#40;tagente_estado.id_agente_estado&#41;&#x20;FROM&#x20;tagente_estado,&#x20;tagente,&#x20;tagente_modulo&#x20;WHERE&#x20;tagente.id_grupo&#x20;=&#x20;t1.id_grupo&#x20;AND&#x20;tagente.disabled&#x20;=&#x20;0&#x20;AND&#x20;tagente_estado.id_agente&#x20;=&#x20;tagente.id_agente&#x20;AND&#x20;tagente_estado.id_agente_modulo&#x20;=&#x20;tagente_modulo.id_agente_modulo&#x20;AND&#x20;tagente_modulo.disabled&#x20;=&#x20;0&#x20;AND&#x20;estado&#x20;=&#x20;0&#x20;AND&#x20;&#40;&#40;UNIX_TIMESTAMP&#40;NOW&#40;&#41;&#41;&#x20;-&#x20;tagente_estado.utimestamp&#41;&#x20;&lt;&#x20;&#40;tagente_estado.current_interval&#x20;/&#x20;&#40;1/2&#41;&#41;&#x20;OR&#x20;&#40;tagente_modulo.id_tipo_modulo&#x20;IN&#40;21,22,23,24,100&#41;&#41;&#41;&#x20;AND&#x20;&#40;utimestamp&#x20;&gt;&#x20;0&#x20;OR&#x20;&#40;tagente_modulo.id_tipo_modulo&#x20;IN&#40;21,22,23,24&#41;&#41;&#41;&#41;&#x20;as&#x20;monitor_ok,&#x20;&#40;SELECT&#x20;COUNT&#40;tagente_estado.id_agente_estado&#41;&#x20;FROM&#x20;tagente_estado,&#x20;tagente,&#x20;tagente_modulo&#x20;WHERE&#x20;tagente.id_grupo&#x20;=&#x20;t1.id_grupo&#x20;AND&#x20;tagente.disabled&#x20;=&#x20;0&#x20;AND&#x20;tagente_estado.id_agente&#x20;=&#x20;tagente.id_agente&#x20;AND&#x20;tagente_estado.id_agente_modulo&#x20;=&#x20;tagente_modulo.id_agente_modulo&#x20;AND&#x20;tagente_modulo.disabled&#x20;=&#x20;0&#x20;AND&#x20;estado&#x20;=&#x20;1&#x20;AND&#x20;&#40;&#40;UNIX_TIMESTAMP&#40;NOW&#40;&#41;&#41;&#x20;-&#x20;tagente_estado.utimestamp&#41;&#x20;&lt;&#x20;&#40;tagente_estado.current_interval&#x20;/&#x20;&#40;1/2&#41;&#41;&#x20;OR&#x20;&#40;tagente_modulo.id_tipo_modulo&#x20;IN&#40;21,22,23,24,100&#41;&#41;&#41;&#x20;AND&#x20;utimestamp&#x20;&gt;&#x20;0&#41;&#x20;as&#x20;monitor_critical,&#x20;&#40;SELECT&#x20;COUNT&#40;talert_template_modules.id&#41;&#x20;FROM&#x20;talert_template_modules,&#x20;tagente_modulo,&#x20;tagente_estado,&#x20;tagente&#x20;WHERE&#x20;tagente.id_grupo&#x20;=&#x20;t1.id_grupo&#x20;AND&#x20;tagente_modulo.id_agente&#x20;=&#x20;tagente.id_agente&#x20;AND&#x20;tagente_estado.id_agente_modulo&#x20;=&#x20;tagente_modulo.id_agente_modulo&#x20;AND&#x20;tagente_modulo.disabled&#x20;=&#x20;0&#x20;AND&#x20;tagente.disabled&#x20;=&#x20;0&#x20;AND&#x20;talert_template_modules.id_agent_module&#x20;=&#x20;tagente_modulo.id_agente_modulo&#x20;AND&#x20;times_fired&#x20;&gt;&#x20;0&#41;&#x20;as&#x20;monitor_alert_fired&#x20;from&#x20;tgrupo&#x20;as&#x20;t1&#x20;where&#x20;0&#x20;&lt;&#x20;&#40;select&#x20;count&#40;t2.id_agente&#41;&#x20;from&#x20;tagente&#x20;as&#x20;t2&#x20;where&#x20;t1.id_grupo&#x20;=&#x20;t2.id_grupo&#41;');
INSERT INTO `trecon_script` VALUES (1,'SNMP&#x20;Recon&#x20;Script','This&#x20;script&#x20;is&#x20;used&#x20;to&#x20;automatically&#x20;detect&#x20;SNMP&#x20;Interfaces&#x20;on&#x20;devices,&#x20;used&#x20;as&#x20;Recon&#x20;Custom&#x20;Script&#x20;in&#x20;the&#x20;recon&#x20;task.&#x20;Parameters&#x20;used&#x20;are:&#x0d;&#x0a;&#x0d;&#x0a;*&#x20;custom_field1&#x20;=&#x20;network.&#x20;i.e.:&#x20;192.168.100.0/24&#x0d;&#x0a;*&#x20;custom_field2&#x20;=&#x20;several&#x20;communities&#x20;separated&#x20;by&#x20;comma.&#x20;For&#x20;example:&#x20;snmp_community,public,private&#x20;&#x0d;&#x0a;*&#x20;custom_field3&#x20;=&#x20;optative&#x20;parameter&#x20;to&#x20;force&#x20;process&#x20;downed&#x20;interfaces&#x20;&#40;use:&#x20;&#039;-a&#039;&#41;.&#x20;Only&#x20;up&#x20;interfaces&#x20;are&#x20;processed&#x20;by&#x20;default&#x20;&#x0d;&#x0a;&#x0d;&#x0a;See&#x20;documentation&#x20;for&#x20;more&#x20;information.','/usr/share/pandora_server/util/recon_scripts/snmpdevices.pl');
INSERT INTO `trecon_script` VALUES (1,'SNMP&#x20;Recon&#x20;Script','This&#x20;script&#x20;is&#x20;used&#x20;to&#x20;automatically&#x20;detect&#x20;SNMP&#x20;Interfaces&#x20;on&#x20;devices,&#x20;used&#x20;as&#x20;Recon&#x20;Custom&#x20;Script&#x20;in&#x20;the&#x20;recon&#x20;task.&#x20;Parameters&#x20;used&#x20;are:&#x0d;&#x0a;&#x0d;&#x0a;*&#x20;Network&#x20;=&#x20;network.&#x20;i.e.:&#x20;192.168.100.0/24&#x0d;&#x0a;*&#x20;Community&#x20;=&#x20;several&#x20;communities&#x20;separated&#x20;by&#x20;comma.&#x20;For&#x20;example:&#x20;snmp_community,public,private&#x20;&#x0d;&#x0a;*&#x20;Optative&#x20;parameter&#x20;=&#x20;optative&#x20;parameter&#x20;to&#x20;force&#x20;process&#x20;downed&#x20;interfaces&#x20;&#40;use:&#x20;&#039;-a&#039;&#41;.&#x20;Only&#x20;up&#x20;interfaces&#x20;are&#x20;processed&#x20;by&#x20;default&#x20;&#x0d;&#x0a;&#x0d;&#x0a;See&#x20;documentation&#x20;for&#x20;more&#x20;information.','/usr/share/pandora_server/util/recon_scripts/snmpdevices.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"Network&#x20;i.e.:&#x20;192.168.100.0/24&#x0d;&#x0a;Networks&#x20;must&#x20;be&#x20;separated&#x20;by&#x20;comma.&#x20;For&#x20;example:&#x20;192.168.100.0/24,192.168.50.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"Communities&#x20;must&#x20;be&#x20;separated&#x20;by&#x20;comma.&#x20;For&#x20;example:&#x20;snmp_community,public,private&#x20;\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Optative&#x20;parameter\",\"help\":\"Optative&#x20;parameter&#x20;to&#x20;force&#x20;process&#x20;downed&#x20;interfaces&#x20;&#40;use:&#x20;&#039;-a&#039;&#41;.&#x20;Only&#x20;up&#x20;interfaces&#x20;are&#x20;processed&#x20;by&#x20;default&#x20;\",\"value\":\"\",\"hide\":\"\"}}');
INSERT INTO `trecon_script` VALUES
(2,'IPMI Recon', 'Specific Pandora FMS Intel DCM Discovery (c) Artica ST 2011 <info@artica.es> Usage: ./ipmi-recon.pl <task_id> <group_id> <create_incident_flag> <custom_field1> <custom_field2> <custom_field3> * custom_field1 = network. i.e.: 192.168.100.0/24 * custom_field2 = username * custom_fiedl3 = password ', '/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl');
INSERT INTO `trecon_script` VALUES (2,'IPMI&#x20;Recon','Specific&#x20;Pandora&#x20;FMS&#x20;Intel&#x20;DCM&#x20;Discovery&#x20;&#40;c&#41;&#x20;Artica&#x20;ST&#x20;2011&#x20;&lt;info@artica.es&gt;&#x0d;&#x0a;&#x0d;&#x0a;Usage:&#x20;./ipmi-recon.pl&#x20;&lt;task_id&gt;&#x20;&lt;group_id&gt;&#x20;&lt;create_incident_flag&gt;&#x20;&lt;custom_field1&gt;&#x20;&lt;custom_field2&gt;&#x20;&lt;custom_field3&gt;&#x0d;&#x0a;&#x0d;&#x0a;*&#x20;custom_field1&#x20;=&#x20;Network&#x20;i.e.:&#x20;192.168.100.0/24&#x0d;&#x0a;*&#x20;custom_field2&#x20;=&#x20;Username&#x0d;&#x0a;*&#x20;custom_fiedl3&#x20;=&#x20;Password','/usr/share/pandora_server/util/recon_scripts/ipmi-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.:&#x20;192.168.100.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Username\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"}}');
INSERT INTO `trecon_script` VALUES (4,'SNMP&#x20;L2&#x20;Recon','Pandora&#x20;FMS&#x20;SNMP&#x20;Recon&#x20;Plugin&#x20;for&#x20;level&#x20;2&#x20;network&#x20;topology&#x20;discovery.&#x0d;&#x0a;&#40;c&#41;&#x20;Artica&#x20;ST&#x20;2014&#x20;&lt;info@artica.es&gt;&#x0d;&#x0a;&#x0d;&#x0a;Usage:&#x0d;&#x0a;&#x0d;&#x0a;&#x20;&#x20;&#x20;./snmp-recon.pl&#x20;&lt;task_id&gt;&#x20;&lt;group_id&gt;&#x20;&lt;create_incident&gt;&#x20;&lt;custom_field1&gt;&#x20;&lt;custom_field2&gt;&#x20;[custom_field3]&#x20;[custom_field4]&#x0d;&#x0a;&#x0d;&#x0a;&#x20;*&#x20;custom_field1&#x20;=&#x20;comma&#x20;separated&#x20;list&#x20;of&#x20;networks&#x20;&#40;i.e.:&#x20;192.168.1.0/24,192.168.2.0/24&#41;&#x0d;&#x0a;&#x20;*&#x20;custom_field2&#x20;=&#x20;comma&#x20;separated&#x20;list&#x20;of&#x20;snmp&#x20;communities&#x20;to&#x20;try.&#x0d;&#x0a;&#x20;*&#x20;custom_field3&#x20;=&#x20;a&#x20;router&#x20;in&#x20;the&#x20;network.&#x20;Optional&#x20;but&#x20;recommended.&#x0d;&#x0a;&#x0d;&#x0a;&#x20;*&#x20;custom_field4&#x20;=&#x20;set&#x20;to&#x20;-a&#x20;to&#x20;add&#x20;all&#x20;network&#x20;interfaces&#x20;&#40;by&#x20;default&#x20;only&#x20;interfaces&#x20;that&#x20;are&#x20;up&#x20;are&#x20;added&#41;.&#x0d;&#x0a;&#x0d;&#x0a;&#x20;Additional&#x20;information:&#x0d;&#x0a;When&#x20;the&#x20;script&#x20;is&#x20;called&#x20;from&#x20;a&#x20;recon&#x20;task&#x20;the&#x20;task_id,&#x20;group_id&#x20;and&#x20;create_incident&#x20;parameters&#x20;are&#x20;automatically&#x20;filled&#x20;by&#x20;the&#x20;Pandora&#x20;FMS&#x20;Server.','/usr/share/pandora_server/util/recon_scripts/snmp-recon.pl');
INSERT INTO `trecon_script` VALUES (4,'SNMP&#x20;L2&#x20;Recon','Pandora&#x20;FMS&#x20;SNMP&#x20;Recon&#x20;Plugin&#x20;for&#x20;level&#x20;2&#x20;network&#x20;topology&#x20;discovery.&#x0d;&#x0a;&#40;c&#41;&#x20;Artica&#x20;ST&#x20;2014&#x20;&lt;info@artica.es&gt;&#x0d;&#x0a;&#x0d;&#x0a;Usage:&#x0d;&#x0a;&#x0d;&#x0a;&#x20;&#x20;&#x20;./snmp-recon.pl&#x20;&lt;task_id&gt;&#x20;&lt;group_id&gt;&#x20;&lt;create_incident&gt;&#x20;&lt;custom_field1&gt;&#x20;&lt;custom_field2&gt;&#x20;[custom_field3]&#x20;[custom_field4]&#x0d;&#x0a;&#x0d;&#x0a;&#x20;*&#x20;custom_field1&#x20;=&#x20;comma&#x20;separated&#x20;list&#x20;of&#x20;networks&#x20;&#40;i.e.:&#x20;192.168.1.0/24,192.168.2.0/24&#41;&#x0d;&#x0a;&#x20;*&#x20;custom_field2&#x20;=&#x20;comma&#x20;separated&#x20;list&#x20;of&#x20;snmp&#x20;communities&#x20;to&#x20;try.&#x0d;&#x0a;&#x20;*&#x20;custom_field3&#x20;=&#x20;a&#x20;router&#x20;in&#x20;the&#x20;network.&#x20;Optional&#x20;but&#x20;recommended.&#x0d;&#x0a;&#x20;*&#x20;custom_field4&#x20;=&#x20;set&#x20;to&#x20;-a&#x20;to&#x20;add&#x20;all&#x20;network&#x20;interfaces&#x20;&#40;by&#x20;default&#x20;only&#x20;interfaces&#x20;that&#x20;are&#x20;up&#x20;are&#x20;added&#41;.&#x0d;&#x0a;&#x0d;&#x0a;&#x20;Additional&#x20;information:&#x0d;&#x0a;When&#x20;the&#x20;script&#x20;is&#x20;called&#x20;from&#x20;a&#x20;recon&#x20;task&#x20;the&#x20;task_id,&#x20;group_id&#x20;and&#x20;create_incident&#x20;parameters&#x20;are&#x20;automatically&#x20;filled&#x20;by&#x20;the&#x20;Pandora&#x20;FMS&#x20;Server.','/usr/share/pandora_server/util/recon_scripts/snmp-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"Comma&#x20;separated&#x20;list&#x20;of&#x20;networks&#x20;&#40;i.e.:&#x20;192.168.1.0/24,192.168.2.0/24&#41;\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"Comma&#x20;separated&#x20;list&#x20;of&#x20;snmp&#x20;communities&#x20;to&#x20;try.\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Router\",\"help\":\"A&#x20;router&#x20;in&#x20;the&#x20;network.&#x20;Optional&#x20;but&#x20;recommended.\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Optional&#x20;parameter\",\"help\":\"Set&#x20;to&#x20;-a&#x20;to&#x20;add&#x20;all&#x20;network&#x20;interfaces&#x20;&#40;by&#x20;default&#x20;only&#x20;interfaces&#x20;that&#x20;are&#x20;up&#x20;are&#x20;added&#41;.\",\"value\":\"\",\"hide\":\"\"}}');
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI&#x20;Plugin','Plugin&#x20;to&#x20;get&#x20;IPMI&#x20;monitors&#x20;from&#x20;a&#x20;IPMI&#x20;Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{"1":{"macro":"_field1_","desc":"Target&#x20;IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Username","help":"","value":""},"3":{"macro":"_field3_","desc":"Password","help":"","value":""}}','-h&#x20;_field1_-u&#x20;_field2_-p&#x20;_field3_');