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:
parent
21b0374ab1
commit
09f4f3c307
|
@ -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,
|
||||
|
|
|
@ -147,3 +147,10 @@ INSERT INTO `trecon_script` VALUES (4,'SNMP L2 Recon','Pandora 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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 '';
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 = "";
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
@ -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
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 Report Alerts', 'select t1.nombre as agent_name, t2.nombre as module_name, (select talert_templates.name from talert_templates where talert_templates.id = t3.id_alert_template) as template, (select group_concat(t02.name) from talert_template_module_actions as t01 inner join talert_actions as t02 on t01.id_alert_action = t02.id where t01.id_alert_template_module = t3.id group by t01.id_alert_template_module) as actions from tagente as t1 inner join tagente_modulo as t2 on t1.id_agente = t2.id_agente inner join talert_template_modules as t3 on t2.id_agente_modulo = t3.id_agent_module order by agent_name, module_name;');
|
||||
INSERT INTO `treport_custom_sql` (`id`, `name`, `sql`) VALUES (4, 'Group view', 'select t1.nombre, (select count(t3.id_agente) from tagente as t3 where t1.id_grupo = t3.id_grupo) as agents, (SELECT COUNT(t4.id_agente) FROM tagente as t4 WHERE t4.id_grupo = t1.id_grupo AND t4.disabled = 0 AND t4.ultimo_contacto < NOW() - (intervalo / (1/2))) as agent_unknown, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND utimestamp > 0 AND tagente_modulo.id_tipo_modulo NOT IN(21,22,23,24,100) AND (UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) >= (tagente_estado.current_interval / (1/2))) as monitor_unknow, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,24) AND utimestamp = 0) as monitor_no_init, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 0 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24)))) as monitor_ok, (SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.id_grupo = t1.id_grupo AND tagente.disabled = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 1 AND ((UNIX_TIMESTAMP(NOW()) - tagente_estado.utimestamp) < (tagente_estado.current_interval / (1/2)) OR (tagente_modulo.id_tipo_modulo IN(21,22,23,24,100))) AND utimestamp > 0) as monitor_critical, (SELECT COUNT(talert_template_modules.id) FROM talert_template_modules, tagente_modulo, tagente_estado, tagente WHERE tagente.id_grupo = t1.id_grupo AND tagente_modulo.id_agente = tagente.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo AND times_fired > 0) as monitor_alert_fired from tgrupo as t1 where 0 < (select count(t2.id_agente) from tagente as t2 where t1.id_grupo = t2.id_grupo)');
|
||||
|
||||
INSERT INTO `trecon_script` VALUES (1,'SNMP Recon Script','This script is used to automatically detect SNMP Interfaces on devices, used as Recon Custom Script in the recon task. Parameters used are:

* custom_field1 = network. i.e.: 192.168.100.0/24
* custom_field2 = several communities separated by comma. For example: snmp_community,public,private 
* custom_field3 = optative parameter to force process downed interfaces (use: '-a'). Only up interfaces are processed by default 

See documentation for more information.','/usr/share/pandora_server/util/recon_scripts/snmpdevices.pl');
|
||||
INSERT INTO `trecon_script` VALUES (1,'SNMP Recon Script','This script is used to automatically detect SNMP Interfaces on devices, used as Recon Custom Script in the recon task. Parameters used are:

* Network = network. i.e.: 192.168.100.0/24
* Community = several communities separated by comma. For example: snmp_community,public,private 
* Optative parameter = optative parameter to force process downed interfaces (use: '-a'). Only up interfaces are processed by default 

See documentation for more information.','/usr/share/pandora_server/util/recon_scripts/snmpdevices.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"Network i.e.: 192.168.100.0/24
Networks must be separated by comma. For example: 192.168.100.0/24,192.168.50.0/24\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"Communities must be separated by comma. For example: snmp_community,public,private \",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Optative parameter\",\"help\":\"Optative parameter to force process downed interfaces (use: '-a'). Only up interfaces are processed by default \",\"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 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','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"i.e.: 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 L2 Recon','Pandora FMS SNMP Recon Plugin for level 2 network topology discovery.
(c) Artica ST 2014 <info@artica.es>

Usage:

   ./snmp-recon.pl <task_id> <group_id> <create_incident> <custom_field1> <custom_field2> [custom_field3] [custom_field4]

 * custom_field1 = comma separated list of networks (i.e.: 192.168.1.0/24,192.168.2.0/24)
 * custom_field2 = comma separated list of snmp communities to try.
 * custom_field3 = a router in the network. Optional but recommended.

 * custom_field4 = set to -a to add all network interfaces (by default only interfaces that are up are added).

 Additional information:
When the script is called from a recon task the task_id, group_id and create_incident parameters are automatically filled by the Pandora FMS Server.','/usr/share/pandora_server/util/recon_scripts/snmp-recon.pl');
|
||||
INSERT INTO `trecon_script` VALUES (4,'SNMP L2 Recon','Pandora FMS SNMP Recon Plugin for level 2 network topology discovery.
(c) Artica ST 2014 <info@artica.es>

Usage:

   ./snmp-recon.pl <task_id> <group_id> <create_incident> <custom_field1> <custom_field2> [custom_field3] [custom_field4]

 * custom_field1 = comma separated list of networks (i.e.: 192.168.1.0/24,192.168.2.0/24)
 * custom_field2 = comma separated list of snmp communities to try.
 * custom_field3 = a router in the network. Optional but recommended.
 * custom_field4 = set to -a to add all network interfaces (by default only interfaces that are up are added).

 Additional information:
When the script is called from a recon task the task_id, group_id and create_incident parameters are automatically filled by the Pandora FMS Server.','/usr/share/pandora_server/util/recon_scripts/snmp-recon.pl','{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Network\",\"help\":\"Comma separated list of networks (i.e.: 192.168.1.0/24,192.168.2.0/24)\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"Comma separated list of snmp communities to try.\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Router\",\"help\":\"A router in the network. Optional but recommended.\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Optional parameter\",\"help\":\"Set to -a to add all network interfaces (by default only interfaces that are up are added).\",\"value\":\"\",\"hide\":\"\"}}');
|
||||
|
||||
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `plugin_type`, `macros`, `parameters`) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Username","help":"","value":""},"3":{"macro":"_field3_","desc":"Password","help":"","value":""}}','-h _field1_-u _field2_-p _field3_');
|
||||
|
||||
|
|
Loading…
Reference in New Issue