2013-08-06 Miguel de Dios <miguel.dedios@artica.es>

* godmode/menu.php, godmode/massive/massive_edit_modules.php:
	improved the source code style.
	
	* godmode/snmpconsole/snmp_alert.php,
	godmode/massive/massive_operations.php: added snmp alert operations.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8632 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-08-06 12:53:39 +00:00
parent 267b28ed0a
commit aa3e7d0f76
5 changed files with 74 additions and 31 deletions

View File

@ -1,3 +1,11 @@
2013-08-06 Miguel de Dios <miguel.dedios@artica.es>
* godmode/menu.php, godmode/massive/massive_edit_modules.php:
improved the source code style.
* godmode/snmpconsole/snmp_alert.php,
godmode/massive/massive_operations.php: added snmp alert operations.
2013-08-05 Miguel de Dios <miguel.dedios@artica.es> 2013-08-05 Miguel de Dios <miguel.dedios@artica.es>
* include/constants.php, godmode/snmpconsole/snmp_alert.php: added * include/constants.php, godmode/snmpconsole/snmp_alert.php: added

View File

@ -420,9 +420,9 @@ $table->data['edit8'][1] = html_print_select_from_sql ('SELECT id_tag, name FROM
$table->data['edit8'][2] = __('Category'); $table->data['edit8'][2] = __('Category');
$table->data['edit8'][3] = html_print_select (categories_get_all_categories('forselect'), 'id_category', '','', __('No change'), '', true, false, false); $table->data['edit8'][3] = html_print_select (categories_get_all_categories('forselect'), 'id_category', '','', __('No change'), '', true, false, false);
if(enterprise_installed()) { if (enterprise_installed()) {
$table->rowspan['edit8'][0] = $table->rowspan['edit8'][1] = 2; $table->rowspan['edit8'][0] = $table->rowspan['edit8'][1] = 2;
$table->data['edit81'][2] = __('Policy linking status') . ui_print_help_tip(__("This field only has sense in modules adopted by a policy."), true); $table->data['edit81'][2] = __('Policy linking status') . ui_print_help_tip(__("This field only has sense in modules adopted by a policy."), true);
$table->data['edit81'][3] = html_print_select (array(MODULE_PENDING_LINK => __('Linked'), MODULE_PENDING_UNLINK => __('Unlinked')), 'policy_linked', '','', __('No change'), '', true, false, false); $table->data['edit81'][3] = html_print_select (array(MODULE_PENDING_LINK => __('Linked'), MODULE_PENDING_UNLINK => __('Unlinked')), 'policy_linked', '','', __('No change'), '', true, false, false);
} }

View File

@ -32,14 +32,16 @@ enterprise_include ('godmode/massive/massive_operations.php');
$tab = (string) get_parameter ('tab', 'massive_agents'); $tab = (string) get_parameter ('tab', 'massive_agents');
$option = (string) get_parameter ('option', ''); $option = (string) get_parameter ('option', '');
$options_alerts = array('add_alerts' => __('Massive alerts addition'), $options_alerts = array(
'add_alerts' => __('Massive alerts addition'),
'delete_alerts' => __('Massive alerts deletion'), 'delete_alerts' => __('Massive alerts deletion'),
'add_action_alerts' => __('Massive alert actions addition'), 'add_action_alerts' => __('Massive alert actions addition'),
'delete_action_alerts' => __('Massive alert actions deletion'), 'delete_action_alerts' => __('Massive alert actions deletion'),
'enable_disable_alerts' => __('Massive alert enable/disable'), 'enable_disable_alerts' => __('Massive alert enable/disable'),
'standby_alerts' => __('Massive alert setting standby')); 'standby_alerts' => __('Massive alert setting standby'));
$options_agents = array('edit_agents' => __('Massive agents edition'), $options_agents = array(
'edit_agents' => __('Massive agents edition'),
'delete_agents' => __('Massive agents deletion')); 'delete_agents' => __('Massive agents deletion'));
if (check_acl ($config['id_user'], 0, "PM")) { if (check_acl ($config['id_user'], 0, "PM")) {
@ -61,14 +63,21 @@ if (! check_acl ($config['id_user'], 0, "PM")) {
} }
$options_policies = array(); $options_policies = array();
$policies_options = enterprise_hook('massive_policies_options'); $policies_options = enterprise_hook('massive_policies_options');
if($policies_options != -1) { if ($policies_options != ENTERPRISE_NOT_HOOK) {
$options_policies = $options_policies =
array_merge($options_policies, $policies_options); array_merge($options_policies, $policies_options);
} }
$options_snmp = array();
$snmp_options = enterprise_hook('massive_snmp_options');
if ($snmp_options != ENTERPRISE_NOT_HOOK) {
$options_snmp =
array_merge($options_snmp, $snmp_options);
}
if (in_array($option, array_keys($options_alerts))) { if (in_array($option, array_keys($options_alerts))) {
$tab = 'massive_alerts'; $tab = 'massive_alerts';
} }
@ -84,11 +93,14 @@ elseif (in_array($option, array_keys($options_modules))) {
elseif (in_array($option, array_keys($options_policies))) { elseif (in_array($option, array_keys($options_policies))) {
$tab = 'massive_policies'; $tab = 'massive_policies';
} }
elseif (in_array($option, array_keys($options_snmp))) {
$tab = 'massive_snmp';
}
else { else {
$option = ''; $option = '';
} }
switch($tab) { switch ($tab) {
case 'massive_alerts': case 'massive_alerts':
$options = $options_alerts; $options = $options_alerts;
break; break;
@ -104,6 +116,9 @@ switch($tab) {
case 'massive_policies': case 'massive_policies':
$options = $options_policies; $options = $options_policies;
break; break;
case 'massive_snmp':
$options = $options_snmp;
break;
} }
// Set the default option of the category // Set the default option of the category
@ -127,12 +142,19 @@ $modulestab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/mass
. html_print_image ('images/brick.png', true, array ('title' => __('Modules operations'))) . html_print_image ('images/brick.png', true, array ('title' => __('Modules operations')))
. '</a>', 'active' => $tab == 'massive_modules'); . '</a>', 'active' => $tab == 'massive_modules');
/* Collection */
$policiestab = enterprise_hook('massive_policies_tab'); $policiestab = enterprise_hook('massive_policies_tab');
if ($policiestab == -1) if ($policiestab == ENTERPRISE_NOT_HOOK)
$policiestab = ""; $policiestab = "";
$snmptab = enterprise_hook('massive_snmp_tab');
if ($snmptab == ENTERPRISE_NOT_HOOK)
$snmptab = "";
$onheader = array(); $onheader = array();
$onheader['massive_agents'] = $agentstab; $onheader['massive_agents'] = $agentstab;
$onheader['massive_modules'] = $modulestab; $onheader['massive_modules'] = $modulestab;
@ -141,11 +163,16 @@ if (check_acl ($config['id_user'], 0, "PM")) {
} }
$onheader['massive_alerts'] = $alertstab; $onheader['massive_alerts'] = $alertstab;
$onheader['policies'] = $policiestab; $onheader['policies'] = $policiestab;
$onheader['snmp'] = $snmptab;
ui_print_page_header (__('Massive operations'). ' &raquo; '. $options[$option], "images/gm_massive_operations.png", false, "", true, $onheader); ui_print_page_header(
__('Massive operations') . ' &raquo; '. $options[$option],
"images/gm_massive_operations.png", false, "", true, $onheader);
// Checks if the PHP configuration is correctly // Checks if the PHP configuration is correctly
if ((get_cfg_var("max_execution_time") != 0) or (get_cfg_var("max_input_time") != -1)) { if ((get_cfg_var("max_execution_time") != 0)
or (get_cfg_var("max_input_time") != -1)) {
echo '<div id="notify_conf" class="notify">'; echo '<div id="notify_conf" class="notify">';
echo __("In order to perform massive operations, PHP needs a correct configuration in timeout parameters. Please, open your PHP configuration file (php.ini) for example: <i>sudo vi /etc/php5/apache2/php.ini;</i><br> And set your timeout parameters to a correct value: <br><i> max_execution_time = 0</i> and <i>max_input_time = -1</i>"); echo __("In order to perform massive operations, PHP needs a correct configuration in timeout parameters. Please, open your PHP configuration file (php.ini) for example: <i>sudo vi /etc/php5/apache2/php.ini;</i><br> And set your timeout parameters to a correct value: <br><i> max_execution_time = 0</i> and <i>max_input_time = -1</i>");
echo '</div>'; echo '</div>';
@ -192,7 +219,6 @@ echo '</div>';
</script> </script>
<?php <?php
echo "<br />"; echo "<br />";
echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">'; echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">';
echo '<table border="0"><tr><td>'; echo '<table border="0"><tr><td>';
@ -200,7 +226,7 @@ echo __("Action");
echo '</td><td>'; echo '</td><td>';
html_print_select($options, 'option', $option, 'this.form.submit()', '', html_print_select($options, 'option', $option, 'this.form.submit()', '',
0, false, false, false); 0, false, false, false);
if($option == 'edit_agents' || $option == 'edit_modules') if ($option == 'edit_agents' || $option == 'edit_modules')
ui_print_help_tip(__("The blank fields will not be updated")); ui_print_help_tip(__("The blank fields will not be updated"));
echo '</td></tr></table>'; echo '</td></tr></table>';
echo '</form>'; echo '</form>';

View File

@ -29,7 +29,7 @@ if (check_acl ($config['id_user'], 0, "AW") || check_acl ($config['id_user'], 0,
$menu_godmode["gagente"]["sec2"] = "godmode/agentes/modificar_agente"; $menu_godmode["gagente"]["sec2"] = "godmode/agentes/modificar_agente";
$menu_godmode["gagente"]["id"] = "god-agents"; $menu_godmode["gagente"]["id"] = "god-agents";
if(check_acl ($config['id_user'], 0, "AW")) { if (check_acl ($config['id_user'], 0, "AW")) {
$sub = array (); $sub = array ();
$sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents'); $sub['godmode/agentes/modificar_agente']['text'] = __('Manage agents');
$sub["godmode/agentes/modificar_agente"]["subsecs"] = array( $sub["godmode/agentes/modificar_agente"]["subsecs"] = array(
@ -64,6 +64,7 @@ if (check_acl ($config['id_user'], 0, "AW")) {
} }
$sub["godmode/massive/massive_operations&amp;tab=massive_alerts"]["text"] = __('Alerts operations'); $sub["godmode/massive/massive_operations&amp;tab=massive_alerts"]["text"] = __('Alerts operations');
enterprise_hook('massivepolicies_submenu'); enterprise_hook('massivepolicies_submenu');
enterprise_hook('massivesnmp_submenu');
$menu_godmode["gmassive"]["sub"] = $sub; $menu_godmode["gmassive"]["sub"] = $sub;
} }
@ -104,7 +105,7 @@ if (check_acl ($config['id_user'], 0, "LM") || check_acl ($config['id_user'], 0,
$menu_godmode["galertas"]["sec2"] = "godmode/alerts/alert_list"; $menu_godmode["galertas"]["sec2"] = "godmode/alerts/alert_list";
$menu_godmode["galertas"]["id"] = "god-alerts"; $menu_godmode["galertas"]["id"] = "god-alerts";
if(check_acl ($config['id_user'], 0, "LM")) { if (check_acl ($config['id_user'], 0, "LM")) {
$sub = array (); $sub = array ();
$sub["godmode/alerts/alert_templates"]["text"] = __('Templates'); $sub["godmode/alerts/alert_templates"]["text"] = __('Templates');
$sub["godmode/alerts/alert_actions"]["text"] = __('Actions'); $sub["godmode/alerts/alert_actions"]["text"] = __('Actions');

View File

@ -446,10 +446,17 @@ if ($create_alert || $update_alert) {
// Alert fields // Alert fields
$al = array('al_field1' => $al_field1, 'al_field2' => $al_field2, 'al_field3' => $al_field3, $al = array(
'al_field4' => $al_field4, 'al_field5' => $al_field5, 'al_field6' => $al_field6, 'al_field1' => $al_field1,
'al_field7' => $al_field7, 'al_field8' => $al_field8, 'al_field9' => $al_field9, 'al_field2' => $al_field2,
'al_field10' => $al_field10); 'al_field3' => $al_field3,
'al_field4' => $al_field4,
'al_field5' => $al_field5,
'al_field6' => $al_field6,
'al_field7' => $al_field7,
'al_field8' => $al_field8,
'al_field9' => $al_field9,
'al_field10' => $al_field10);
// Hidden div with help hint to fill with javascript // Hidden div with help hint to fill with javascript
html_print_div(array('id' => 'help_snmp_alert_hint', 'content' => ui_print_help_icon ("snmp_alert_field1", true), 'hidden' => true)); html_print_div(array('id' => 'help_snmp_alert_hint', 'content' => ui_print_help_icon ("snmp_alert_field1", true), 'hidden' => true));
@ -462,7 +469,7 @@ if ($create_alert || $update_alert) {
} }
// Max / Min alerts // Max / Min alerts
echo '<tr><td class="datos2">'.__('Min. number of alerts').'</td><td class="datos2">'; echo '<tr><td class="datos2">' . __('Min. number of alerts').'</td><td class="datos2">';
html_print_input_text ("min_alerts", $min_alerts, '', 3); html_print_input_text ("min_alerts", $min_alerts, '', 3);
echo '</td></tr><tr><td class="datos">'.__('Max. number of alerts').'</td><td class="datos">'; echo '</td></tr><tr><td class="datos">'.__('Max. number of alerts').'</td><td class="datos">';
@ -509,19 +516,25 @@ if ($create_alert || $update_alert) {
$fields[$row["id"]] = $row["name"]; $fields[$row["id"]] = $row["name"];
} }
switch ($config['dbtype']){ switch ($config['dbtype']) {
case "mysql": case "mysql":
case "postgresql": case "postgresql":
html_print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name', html_print_select_from_sql(
"alert_type", $alert_type, '', '', 0, false, false, false); 'SELECT id, name
FROM talert_actions
ORDER BY name',
"alert_type", $alert_type, '', '', 0, false, false, false);
break; break;
case "oracle": case "oracle":
html_print_select_from_sql ('SELECT id, dbms_lob.substr(name,4000,1) as name FROM talert_actions ORDER BY dbms_lob.substr(name,4000,1)', html_print_select_from_sql(
"alert_type", $alert_type, '', '', 0, false, false, false); 'SELECT id, dbms_lob.substr(name,4000,1) as name
FROM talert_actions
ORDER BY dbms_lob.substr(name,4000,1)',
"alert_type", $alert_type, '', '', 0, false, false, false);
break; break;
} }
echo '</td></tr>'; echo '</td></tr>';
echo '<tr><td class="datos">'.__('Position').'</td><td class="datos">'; echo '<tr><td class="datos">' . __('Position') . '</td><td class="datos">';
html_print_input_text ("position", $position, '', 3); html_print_input_text ("position", $position, '', 3);
echo '</td></tr>'; echo '</td></tr>';
echo '</table>'; echo '</table>';
@ -697,14 +710,9 @@ else {
$data[1] = '<a href="' . $url . '">' . $data[1] = '<a href="' . $url . '">' .
alerts_get_alert_action_name ($row["id_alert"]) . '</a>'; alerts_get_alert_action_name ($row["id_alert"]) . '</a>';
$data[2] = __('SNMP Agent');
$data[2] = $row["agent"]; $data[2] = $row["agent"];
$data[3] = __('OID');
$data[3] = $row["oid"]; $data[3] = $row["oid"];
$data[4] = __('Custom Value/OID');
$data[4] = $row["custom_oid"]; $data[4] = $row["custom_oid"];
$data[5] = $row["description"]; $data[5] = $row["description"];
$data[6] = $row["times_fired"]; $data[6] = $row["times_fired"];