Merge branch 'develop' of https://github.com/pandorafms/pandorafms into develop

This commit is contained in:
fermin831 2015-06-30 13:47:08 +02:00
commit 073165d107
57 changed files with 1676 additions and 458 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 6.0dev-150629
Version: 6.0dev-150630
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.0dev-150629"
pandora_version="6.0dev-150630"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '6.0dev';
use constant AGENT_BUILD => '150629';
use constant AGENT_BUILD => '150630';
# Commands to retrieve total memory information in kB
use constant TOTALMEMORY_CMDS => {

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.0dev
%define release 150629
%define release 150630
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 6.0dev
%define release 150629
%define release 150630
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{150629}
{150630}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("6.0dev(Build 150629)")
#define PANDORA_VERSION ("6.0dev(Build 150630)")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(6.0dev(Build 150629))"
VALUE "ProductVersion", "(6.0dev(Build 150630))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 6.0dev-150629
Version: 6.0dev-150630
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.0dev-150629"
pandora_version="6.0dev-150630"
package_pear=0
package_pandora=1

View File

@ -22,14 +22,29 @@ function pluginreg_extension_main () {
require ("general/noaccess.php");
return;
}
ui_require_css_file ('firts_task');
ui_print_page_header (__('Plugin registration'), "images/extensions.png", false, "", true, "" );
echo "<div class=notify>";
printf(__("This extension makes registration of server plugins more easy. Here you can upload a server plugin in Pandora FMS 3.x zipped format (.pspz). Please refer to documentation on how to obtain and use Pandora FMS Server Plugins.<br><br>You can get more plugins in our <a href='%s'>Public Resource Library</a>") , "http://pandorafms.com/Library/Library/");
echo "</div>";
echo "<br><br>";
echo '<div class="new_task">
<div class="image_task">';
echo html_print_image("images/firts_task/icono_grande_import.png", true, array("title" => __("") ));
echo '</div>';
echo '<div class="text_task">';
echo '<h3>' . __("Plugin registration") . '</h3>';
echo '<p id="description_task">' .
__("This extension makes registration of server plugins more easy.
Here you can upload a server plugin in Pandora FMS 3.x zipped format (.pspz).
Please refer to documentation on how to obtain and use Pandora FMS Server Plugins.
<br><br>You can get more plugins in our <a href='http://pandorafms.com/Library/Library/'>Public Resource Library</a> ") . '</p>';
// Upload form
echo "<form name='submit_plugin' method='post' enctype='multipart/form-data'>";
echo '<table class="" id="table1" width="100%" border="0" cellpadding="4" cellspacing="4">';
echo "<tr><td class='datos'><input type='file' name='plugin_upload' />";
echo "<td class='datos'><input type='submit' class='sub next' value='".__('Upload')."' />";
echo "</form></table>";
echo '</div>';
echo '</div>';
$zip = null;
$upload = false;
@ -408,15 +423,6 @@ function pluginreg_extension_main () {
}
}
}
// Upload form
echo "<form name='submit_plugin' method='post' enctype='multipart/form-data'>";
echo '<table class="databox" id="table1" width="100%" border="0" cellpadding="4" cellspacing="4">';
echo "<tr><td class='datos'><input type='file' name='plugin_upload' />";
echo "<td class='datos'><input type='submit' class='sub next' value='".__('Upload')."' />";
echo "</form></table>";
return;
}
extensions_add_godmode_menu_option (__('Register plugin'), 'PM','gservers', null, "v1r1");

View File

@ -0,0 +1,26 @@
<?php
global $config;
check_login ();
ui_require_css_file ('firts_task');
?>
<?php
ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no custom fields defined yet.') ) );
?>
<div class="new_task">
<div class="image_task">
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, array("title" => __('Custom Graphs')));?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Custom Fields'); ?></h3>
<p id="description_task"> <?php echo __('The Recon Task definition of Pandora FMS is used to find new elements in the network.
If it detects any item, it will add that item to the monitoring, and if that item it is already being monitored, then it will
ignore it or will update its information.There are three types of detection: Based on <strong id="fuerte"> ICMP </strong>(pings),
<strong id="fuerte">SNMP</strong> (detecting the topology of networks and their interfaces), and other <strong id="fuerte"> customized </strong>
type. You can define your own customized recon script.'); ?></p>
<form action="index.php?sec=gagente&sec2=godmode/agentes/configure_field" method="post">
<input type="submit" class="button_task" value="<?php echo __('Create Custom Fields'); ?>" />
</form>
</div>
</div>

View File

@ -10,17 +10,19 @@ ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no in
<div class="new_task">
<div class="image_task">
<?php echo html_print_image('images/firts_task/icono_grande_custom_reporting.png', true, array("title" => __('Incidents')));?>
<?php echo html_print_image('images/firts_task/icono_grande_incidencia.png', true, array("title" => __('Incidents')));?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Incidents'); ?></h3>
<p id="description_task"> <?php echo __('The Recon Task definition of Pandora FMS is used to find new elements in the network.
If it detects any item, it will add that item to the monitoring, and if that item it is already being monitored, then it will
ignore it or will update its information.There are three types of detection: Based on <strong id="fuerte"> ICMP </strong>(pings),
<strong id="fuerte">SNMP</strong> (detecting the topology of networks and their interfaces), and other <strong id="fuerte"> customized </strong>
type. You can define your own customized recon script.'); ?></p>
<form action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&create" method="post">
<p id="description_task"> <?php echo __("Besides receiving and processing data to monitor systems or applications,
you're also required to monitor possible incidents which might take place on these systems within the system monitoring process.
For it, the Pandora FMS team has designed an incident manager within which any user is able to open incidents,
explaining what's happened on the network and to update them with comments and files any time in case there is a need to do so.
This system allows the users to work as a team, along with different roles and work-flow systems which allows an incident to be
moved from one group to another, and that members from different groups and different people could work on the same incident, sharing information and files.
"); ?></p>
<form action="index.php?sec=workspace&amp;sec2=operation/incidents/incident_detail&amp;insert_form=1" method="post">
<input type="submit" class="button_task" value="<?php echo __('Create Incidents'); ?>" />
</form>
</div>
</div>
</div>

View File

@ -19,9 +19,13 @@ $networkmap_types = networkmap_get_types($strict_user);
<p id="description_task"> <?php echo __("There is also an open-source version of the network map.
This functionality allows to graphically display the nodes and relationships, agents, modules and groups available to the user.
There are three types of network maps:
<li><ul>Topology Map</ul>
<ul>Group Map</ul>
<ul>Policy Map</ul></li> "); ?></p>
");
echo "<li>" . __("Topology Map") . "</li>
<li>" . __("Group Map") . "</li>
<li>" . __("Radial Map (User without strict user)") . "</li>
<li>" . __("Dinamic Map") . "</li>
<li>" . __("Policy Map (Only Enterprise version)") . "</li>";
?> </p>
<form id="networkmap_action" method="post" action="index.php?sec=network&amp;sec2=operation/agentes/networkmap&action=create">
<?php echo html_print_select($networkmap_types, 'tab', 'topology', '', '', 0);
html_print_input_hidden('add_networkmap', 1);

View File

@ -11,12 +11,11 @@ ui_require_css_file ('firts_task');
</div>
<div class="text_task">
<h3> <?php echo __('Create Planned Downtime'); ?></h3>
<p id="description_task"> <?php echo __('The Recon Task definition of Pandora FMS is used to find new elements in the network.
If it detects any item, it will add that item to the monitoring, and if that item it is already being monitored, then it will
ignore it or will update its information.There are three types of detection: Based on <strong id="fuerte"> ICMP </strong>(pings),
<strong id="fuerte">SNMP</strong> (detecting the topology of networks and their interfaces), and other <strong id="fuerte"> customized </strong>
type. You can define your own customized recon script.'); ?></p>
<form action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&create" method="post">
<p id="description_task"> <?php echo __("Pandora FMS contains a scheduled downtime management system.
This system was designed to deactivate the alerts in the intervals whenever there is down time by deactivating the agent.
If an agent is deactivated, it doesn't collect information. In a down time, the down-time intervals aren't taken into
account for most of the metrics or types of reports, because the agents don't contain any data within those intervals. "); ?></p>
<form action="index.php?sec=estado&amp;sec2=godmode/agentes/planned_downtime.editor" method="post">
<input type="submit" class="button_task" value="<?php echo __('Create Planned Downtime'); ?>" />
</form>
</div>

View File

@ -3,21 +3,19 @@ global $config;
check_login ();
ui_require_css_file ('firts_task');
?>
<?php ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no recon task defined yet.') ) ); ?>
<?php ui_print_info_message ( array('no_close'=>true, 'message'=> __('There are no tags defined yet.') ) ); ?>
<div class="new_task">
<div class="image_task">
<?php echo html_print_image('images/firts_task/icono_grande_reconserver.png', true, array("alt" => __('Recon server')));?>
<?php echo html_print_image('images/firts_task/icono_grande_gestiondetags.png', true, array("alt" => __('Recon server')));?>
</div>
<div class="text_task">
<h3> <?php echo __('Create Recon Task'); ?></h3>
<p id="description_task"> <?php echo __('The Recon Task definition of Pandora FMS is used to find new elements in the network.
If it detects any item, it will add that item to the monitoring, and if that item it is already being monitored, then it will
ignore it or will update its information.There are three types of detection: Based on <strong id="fuerte"> ICMP </strong>(pings),
<strong id="fuerte">SNMP</strong> (detecting the topology of networks and their interfaces), and other <strong id="fuerte"> customized </strong>
type. You can define your own customized recon script.'); ?></p>
<form action="index.php?sec=gservers&sec2=godmode/servers/manage_recontask_form&create" method="post">
<input type="submit" class="button_task" value="<?php echo __('Create Recon Task'); ?>" />
<h3> <?php echo __('Create Tags'); ?></h3>
<p id="description_task"> <?php echo __("From Pandora FMS versions 5 and above, the access to modules can be configured by a tags system.
Tags are configured on the system and be assigned to the chosen modules.
The user's access can be limited to modules with certain tags in this way. "); ?></p>
<form action="index.php?sec=gmodules&sec2=godmode/tag/edit_tag&action=new" method="post">
<input type="submit" class="button_task" value="<?php echo __('Create Tags'); ?>" />
</form>
</div>
</div>

View File

@ -103,7 +103,8 @@ if ($fields) {
$table->data = array ();
}
else {
ui_print_info_message ( array('no_close'=>true, 'message'=> __('No fields defined') ) );
require_once ($config['homedir'] . "/general/firts_task/custom_fields.php");
return;
}
if ($fields === false) $fields = array();

View File

@ -255,9 +255,9 @@ if ($template['time_from'] == $template['time_to']) {
}
else {
$from_array = explode(':', $template['time_from']);
$from = $from_array[0] * 3600 + $from_array[1] * 60 + $from_array[2];
$from = $from_array[0] * SECONDS_1HOUR + $from_array[1] * SECONDS_1MINUTE + $from_array[2];
$to_array = explode(':', $template['time_to']);
$to = $to_array[0] * 3600 + $to_array[1] * 60 + $to_array[2];
$to = $to_array[0] * SECONDS_1HOUR + $to_array[1] * SECONDS_1MINUTE + $to_array[2];
if ($to > $from) {
if ($template['time_from'] != '00:00:00') {
$table_time->head[0] = '00:00:00<br>-<br>' . $template['time_from'];
@ -296,7 +296,11 @@ unset($table_time);
$table_conditions->data[] = $data;
$data[0] = __('Use special days list');
$data[1] = (isset($alert['special_day']) && $alert['special_day'] == 1) ? __('Yes') : __('No');
$data[1] = (isset($alert['special_day']) && $alert['special_day'] == 1)
?
__('Yes')
:
__('No');
$table_conditions->data[] = $data;
$data[0] = __('Time threshold');
@ -372,7 +376,7 @@ else {
else {
$table->head[$k] = '#' . $k;
}
}
}
}
$action_threshold = $action['module_action_threshold'] > 0 ? $action['module_action_threshold'] : $action['action_threshold'];
@ -523,21 +527,21 @@ else {
$table->style[3] = 'width: 25%;';
$table->style[3] = 'font-weight: bold; width: 25%;';
$table->title = __('Recovering fields') . ui_print_help_tip(__('Fields passed to the command executed by this action when the alert is recovered'), true);
$table->head[0] = __('Field') . ui_print_help_tip(__('Fields configured on the command associated to the action'), true);
$table->head[1] = __('Firing fields') . ui_print_help_tip(__('Fields used on execution when the alert is fired'), true);
$table->head[2] = __('Template recovery fields') . ui_print_help_tip(__('Recovery fields configured in alert template'), true);
$table->head[3] = __('Action recovery fields') . ui_print_help_tip(__('Recovery fields configured in alert action'), true);
$table->head[4] = __('Executed on recovery') . ui_print_help_tip(__('Fields used on execution when the alert is recovered'), true);
$table->style[4] = 'font-weight: bold;';
foreach($firing_fields as $kaction => $firing) {
$data = array();
$command_preview = $firing_fields[$kaction]['command'];
$fieldn = 1;
foreach ($firing['description'] as $field => $desc) {
$data[0] = $desc;
if (!empty($data[0])) {
$data[0] = '<b>' . $data[0] . '</b><br>';
}
@ -609,7 +613,7 @@ $('#firing_action_select').change(function() {
$('.action_details').show();
}
$('.firing_action').hide();
if($(this).val() != -1) {
$('.firing_action_' + $(this).val()).show();

View File

@ -0,0 +1,990 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
check_login ();
if (! check_acl ($config['id_user'], 0, "AW")) {
db_pandora_audit("ACL Violation",
"Trying to access massive plugin edition section");
require ("general/noaccess.php");
return;
}
$plugin_id = (int) get_parameter('plugin_id');
$agent_ids = get_parameter('agent_ids', array());
$module_ids = get_parameter('module_ids', array());
$module_names = get_parameter('module_names', array());
if (is_ajax()) {
$get_plugin = (bool) get_parameter('get_plugin');
$get_agents = (bool) get_parameter('get_agents');
$get_modules = (bool) get_parameter('get_modules');
$get_module_plugin_macros = (bool) get_parameter('get_module_plugin_macros');
if ($get_plugin) {
$plugin = db_get_row('tplugin', 'id', $plugin_id);
if (empty($plugin)) {
$plugin = array();
}
if (isset($plugin['description'])) {
$plugin['description'] = io_safe_output($plugin['description']);
$plugin['description'] = str_replace("\n", "<br>", $plugin['description']);
}
if (isset($plugin['macros'])) {
$macros = json_decode($plugin['macros'], true);
if (!empty($macros)) {
$macros = array_values($macros);
if (!empty($macros)) {
$plugin['macros'] = $macros;
}
}
}
echo json_encode($plugin);
return;
}
if ($get_agents) {
$sql = "SELECT ta.id_agente, ta.nombre AS agent_name,
tam.nombre AS module_name
FROM tagente ta
INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente
AND tam.id_plugin = $plugin_id
ORDER BY ta.nombre, tam.nombre";
$result = db_get_all_rows_sql($sql);
if (empty($result)) $result = array();
$agents = array();
$current_element = array();
foreach ($result as $key => $value) {
$id = (int) $value['id_agente'];
$name = $value['agent_name'];
$module_name = $value['module_name'];
if (!empty($current_element) && $current_element['id'] !== $id) {
$agents[] = $current_element;
$current_element = array();
}
$current_element['id'] = $id;
$current_element['name'] = $name;
if (!isset($current_element['module_names']))
$current_element['module_names'] = array();
$current_element['module_names'][] = $module_name;
}
if (!empty($current_element)) {
$agents[] = $current_element;
}
echo json_encode($agents);
return;
}
if ($get_module_plugin_macros) {
$fields = array('macros');
$filter = array(
'id_plugin' => $plugin_id,
'id_agente' => $agent_ids,
'nombre' => $module_names
);
$module_plugin_macros = db_get_all_rows_filter('tagente_modulo', $filter, $fields);
if (empty($module_plugin_macros)) $module_plugin_macros = array();
$module_plugin_macros = array_reduce($module_plugin_macros, function($carry, $item) {
$macros = json_decode($item['macros'], true);
if (!empty($macros)) {
$macros = array_values($macros);
if (!empty($macros)) {
$carry[] = $macros;
}
}
return $carry;
}, array());
echo json_encode($module_plugin_macros);
return;
}
return;
}
$update = (bool) get_parameter('update');
if ($update) {
try {
$plugin = db_get_row('tplugin', 'id', $plugin_id);
// Macros retrieved from the plugin definition
$plugin_macros = array();
if (isset($plugin['macros'])) {
$plugin_macros = json_decode($plugin['macros'], true);
if (!empty($plugin_macros)) {
$plugin_macros = array_values($plugin_macros);
}
}
// Error
if (empty($plugin_macros))
throw new Exception(__('Error retrieving the plugin macros'));
// Macros returned by the form
$macros = get_parameter('macros', array());
// Error
if (empty($macros))
throw new Exception(__('Error retrieving the modified macros'));
$fields = array('id_agente_modulo', 'macros');
$filter = array(
'id_plugin' => $plugin_id,
'id_agente' => $agent_ids,
'nombre' => $module_names
);
$module_plugin_macros = db_get_all_rows_filter('tagente_modulo', $filter, $fields);
if (empty($module_plugin_macros)) $module_plugin_macros = array();
// Error
if (empty($module_plugin_macros))
throw new Exception(__('Error retrieving the module plugin macros'));
// Begin transaction
// db_process_sql_begin();
$errors = 0;
$count = 0;
foreach ($module_plugin_macros as $item) {
$module_id = $item['id_agente_modulo'];
$module_macros_str = $item['macros'];
// Macros retrieved from the agent module
$module_macros = json_decode($module_macros_str, true);
// Error
if (empty($module_macros))
throw new Exception(__('Error retrieving the module plugin macros data'));
// Get the new module plugin macros
$result_macros = array_map(function ($item) use ($macros, $module_macros) {
$result = array(
'macro' => $item['macro'],
'desc' => $item['desc'],
'help' => $item['help'],
'hide' => $item['hide']
);
// Get the default value os the module plugin macro
$default = array_reduce($module_macros, function ($carry, $module_macro) use ($result) {
if (isset($module_macro['macro']) && $module_macro['macro'] == $result['macro']) {
$carry = $module_macro['value'];
}
return $carry;
}, '');
set_if_defined($result['value'], $macros[$item['macro']]);
set_unless_defined($result['value'], $default);
return $result;
}, $plugin_macros);
// Error
if (empty($result_macros))
throw new Exception(__('Error building the new macros'));
$module_macros = json_encode($result_macros);
if (empty($module_macros)) {
$module_macros = $module_macros_str;
}
$values = array('macros' => $module_macros);
$where = array('id_agente_modulo' => $module_id);
// $result = db_process_sql_update('tagente_modulo', $values, $where, 'AND', false);
$result = db_process_sql_update('tagente_modulo', $values, $where);
if (!$result)
$errors++;
else
$count += $result;
}
// if (!$errors) {
// db_process_sql_commit();
// }
// else {
// db_process_sql_rollback();
// }
// Result message
ui_print_info_message(sprintf(__('%d modules updated'), $count));
}
catch (Exception $e) {
ui_print_error_message($e->getMessage());
}
}
$table = new StdClass();
$table->id = 'massive_plugin_edition';
$table->width = '100%';
$table->rowstyle = array();
$table->data = array();
// Plugins
$filter = array('order' => 'name');
$fields = array('id', 'name');
$plugins = db_get_all_rows_filter('tplugin', $filter, $fields);
if (empty($plugins)) {
ui_print_empty_data(__('There are not registered plugins'));
return;
}
$plugins_aux = array();
foreach ($plugins as $plugin) {
$plugins_aux[$plugin['id']] = $plugin['name'];
}
$plugins = $plugins_aux;
unset($plugins_aux);
$plugins_select = html_print_select ($plugins, 'plugin_id',
$plugin_id, '', __('None'), 0, true, false, false);
$row = array();
$row[] = '<b>' . __('Plugin') . '</b>';
$row[] = $plugins_select;
$table->data['plugin-ids-row'] = $row;
// Agents & modules
$row = array();
// Agents
$agents_select = html_print_select ($agent_ids, 'agent_ids[]',
false, '', '', 0, true, true, false);
$row[] = '<b>' . __('Agents') . '</b>';
$row[] = $agents_select;
// Modules
// $modules_select = html_print_select ($module_ids, 'module_ids',
// false, '', '', 0, true, true, false);
$modules_select = html_print_select ($module_names, 'module_names[]',
false, '', '', 0, true, true, false);
$row[] = '<b>' . _('Modules') . '</b>';
$row[] = $modules_select;
$table->rowstyle['agents-modules-row'] = 'vertical-align: top; display: none';
$table->data['agents-modules-row'] = $row;
echo '<form method="POST" id="form-massive_plugin_edition"
action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_plugins&option=edit_plugins">';
html_print_table($table);
echo "<div style='text-align: right; width: " . $table->width . "'>";
html_print_input_hidden('update', 1);
html_print_submit_button (__('Update'), 'upd-btn', false, 'class="sub upd"');
echo "</div>";
echo '</form>';
?>
<script type="text/javascript">
var $table = $('table#massive_plugin_edition'),
$form = $('form#form-massive_plugin_edition'),
$submitButton = $('input#submit-upd-btn'),
$agentModulesRow = $('tr#massive_plugin_edition-agents-modules-row'),
$pluginsSelect = $('select#plugin_id'),
$agentsSelect = $('select#agent_ids'),
$modulesSelect = $('select#module_names');
var agents = [],
ajaxPage = "<?php echo $config['homeurl'] . '/'; ?>ajax.php",
canSubmit = false,
pluginXHR,
agentsXHR,
modulesXHR,
modulePluginMacrosXHR;
var allowSubmit = function (val) {
if (typeof val === 'undefined')
val = true;
canSubmit = val;
$submitButton.prop('disabled', !val);
}
var showSpinner = function () {
var $loadingSpinner = $pluginsSelect.siblings('img#loading_spinner');
if ($loadingSpinner.length > 0) {
// Display inline instead using the show function
// cause its absolute positioning.
$loadingSpinner.css('display', 'inline');
return;
}
$loadingSpinner = $('<img />');
$loadingSpinner
.prop('id', 'loading_spinner')
.css('padding-left', '5px')
.css('position', 'absolute')
.css('top', $pluginsSelect.position().top + 'px')
.prop('src', "<?php echo $config['homeurl'] . '/'; ?>images/spinner.gif");
$pluginsSelect.parent().append($loadingSpinner);
}
var hideSpinner = function () {
var $loadingSpinner = $pluginsSelect.siblings('img#loading_spinner');
if ($loadingSpinner.length > 0)
$loadingSpinner.hide();
}
var clearModulePluginMacrosValues = function () {
$('input.plugin-macro')
.val('')
.prop('disabled', true)
.data('multiple_values', false)
.prop('placeholder', '')
.css('width', '99%')
.siblings('button')
.remove();
}
var hidePluginData = function () {
$('table#massive_plugin_edition tr.plugin-data-row').hide();
}
var clearPluginData = function () {
hidePluginData();
clearModulePluginMacrosValues();
$('table#massive_plugin_edition tr.plugin-data-row').remove();
}
var clearAgentsData = function () {
$agentsSelect.empty();
}
var clearModulesData = function () {
$modulesSelect.empty();
}
// Creates the plugin info and macros columns
var fillPlugin = function (plugin) {
clearPluginData();
if (typeof plugin === 'undefined'
|| typeof plugin.execute === 'undefined'
|| typeof plugin.parameters === 'undefined'
|| typeof plugin.description === 'undefined'
|| typeof plugin.macros === 'undefined')
throw new Error('<?php echo __("Invalid plugin data"); ?>');
if (_.isString(plugin.macros)) {
plugin.macros = JSON.parse(plugin.macros);
}
var $commandRow = $('<tr></tr>'),
$commandCellTitle = $('<td></td>'),
$commandCellData = $('<td></td>'),
$descriptionRow = $('<tr></tr>'),
$descriptionCellTitle = $('<td></td>'),
$descriptionCellData = $('<td></td>');
$commandCellTitle
.addClass('plugin-data-cell')
.css('font-weight', 'bold')
.html('<?php echo __("Command"); ?>');
$commandCellData
.addClass('plugin-data-cell')
.prop('colspan', 3)
.css('font-style', 'italic')
.html(plugin.execute + " " + plugin.parameters);
$commandRow
.addClass('plugin-data-row')
.css('vertical-align', 'top')
.append($commandCellTitle, $commandCellData);
$descriptionCellTitle
.addClass('plugin-data-cell')
.css('font-weight', 'bold')
.html('<?php echo __("Description"); ?>');
$descriptionCellData
.addClass('plugin-data-cell')
.prop('colspan', 3)
.html(plugin.description);
$descriptionRow
.addClass('plugin-data-row')
.css('vertical-align', 'top')
.append($descriptionCellTitle, $descriptionCellData);
$table.append($commandRow, $descriptionRow);
_.each(plugin.macros, function (macro, index) {
var $macroRow = $('<tr></tr>'),
$macroCellTitle = $('<td></td>'),
$macroCellData = $('<td></td>'),
$macroInput = $('<input>'),
$macroIdentifier = $('<span></span>');
$macroInput
.prop('id', macro.macro)
.prop('name', 'macros[' + macro.macro + ']')
.addClass('plugin-macro')
.addClass('plugin-data-input')
.prop('type', function () {
if (Number(macro.hide))
return 'password';
else
return 'text';
})
.css('width', '99%')
.prop('disabled', true)
.autocomplete({
source: [],
minLength: 0,
disabled: true
})
.bind('focus', function() {
$(this).autocomplete("search");
});
$macroIdentifier
.css('font-weight', 'normal')
.css('padding-left', '5px')
.append('(' + macro.macro + ')');
$macroCellTitle
.addClass('plugin-data-cell')
.css('font-weight', 'bold')
.html(macro.desc)
.append($macroIdentifier);
$macroCellData
.addClass('plugin-data-cell')
.prop('colspan', 3)
.html($macroInput);
$macroRow
.addClass('plugin-data-row')
.append($macroCellTitle, $macroCellData);
$table.append($macroRow);
});
}
var removeMultipleElementsButton = function (element) {
element
.css('width', '99%')
.siblings('button')
.remove();
}
// This button removes the special properties of the multiple values macro input
var addMultipleElementsButton = function (element) {
$button = $('<button>');
$button
.css('display', 'inline')
.css('margin-left', '3px')
.text("<?php echo __('Clear'); ?>")
.click(function (e) {
e.stopImmediatePropagation();
e.preventDefault();
if (!confirm("<?php echo __('Are you sure?'); ?>"))
return false;
removeMultipleElementsButton(element);
element
.val('')
.data('multiple_values', false)
.prop('placeholder', '');
});
element
.css('width', '90%')
.css('display', 'inline')
.parent()
.append($button);
}
// Fills the module plugin macros values
var fillPluginMacros = function (moduleMacros) {
clearModulePluginMacrosValues();
if (!(moduleMacros instanceof Array))
throw new Error('<?php echo __("Invalid macros array"); ?>');
$("input.plugin-macro").each(function(index, el) {
var id = $(el).prop('id');
var values = _.chain(moduleMacros)
.flatten()
.where({ macro: id })
.pluck('value')
.uniq()
.value();
$(el).prop('disabled', false);
// Remove the [""] element
if (values.length == 1 && _.first(values) === '') {
values = [];
}
if (values.length == 1) {
$(el).val(_.first(values));
}
else if (values.length > 1) {
$(el).val('')
.data('multiple_values', true)
.prop('placeholder', "<?php echo __('Multiple values'); ?>");
addMultipleElementsButton($(el));
}
else {
$(el).val('');
}
if ($(el).prop('type') !== 'password' && values.length > 0) {
$(el).autocomplete("option", {
disabled: false,
source: values
});
}
else {
$(el).autocomplete("option", { disabled: true });
}
});
$(".ui-autocomplete")
.css('max-height', '100px')
.css('overflow-y', 'auto')
.css('overflow-x', 'hidden')
.css('padding-right', '20px')
.css('text-align', 'left');
}
// Fills the agents select
var fillAgents = function (agents, selected) {
clearAgentsData();
if (!(agents instanceof Array))
throw new Error('<?php echo __("Invalid agents array"); ?>');
_.each(agents, function (agent, index) {
if (typeof agent.id !== 'undefined' && typeof agent.name !== 'undefined') {
$('<option>')
.val(agent.id)
.text(agent.name)
.prop('selected', function () {
if (typeof selected !== 'undefined')
return false;
return _.contains(selected, agent.id.toString());
})
.appendTo($agentsSelect);
}
else {
throw new Error('<?php echo __("Invalid agent element"); ?>');
return false;
}
});
}
// Fills the modules select
var fillModules = function (modules, selected) {
clearModulesData();
if (!(modules instanceof Array))
throw new Error('<?php echo __("Invalid modules array"); ?>');
_.each(modules, function (module, index) {
if (_.isString(module)) {
$('<option>')
.val(module)
.text(module)
.prop('selected', function () {
if (typeof selected === 'undefined')
return false;
return _.contains(selected, module);
})
.appendTo($modulesSelect);
}
else if (typeof module.id !== 'undefined' && typeof module.name !== 'undefined') {
$('<option>')
.val(module.name)
.text(module.name)
.prop('selected', function () {
if (typeof selected === 'undefined')
return false;
return _.contains(selected, module.name);
})
.appendTo($modulesSelect);
}
else {
throw new Error('<?php echo __("Invalid module element"); ?>');
return false;
}
});
$modulesSelect.change();
}
var processGet = function (params, callback) {
return jQuery.get(ajaxPage, params, 'json')
.done(function (data, textStatus, jqXHR) {
try {
data = JSON.parse(data);
callback(null, data);
}
catch (err) {
callback(err);
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
if (textStatus !== 'abort')
callback(errorThrown);
})
.always(function (jqXHR, textStatus) {
});
}
var getPlugin = function (pluginID, callback) {
var params = {
page: 'godmode/massive/massive_edit_plugins',
get_plugin: 1,
plugin_id: pluginID
};
pluginXHR = processGet(params, function (error, data) {
callback(error, data);
});
}
var getAgents = function (pluginID, callback) {
var params = {
page: 'godmode/massive/massive_edit_plugins',
get_agents: 1,
plugin_id: pluginID
};
agentsXHR = processGet(params, function (error, data) {
callback(error, data);
});
}
var getModules = function (pluginID, agentIDs, callback) {
var params = {
page: 'godmode/massive/massive_edit_plugins',
get_modules: 1,
plugin_id: pluginID,
agent_ids: agentIDs
};
modulesXHR = processGet(params, function (error, data) {
callback(error, data);
});
}
var getModulePluginMacros = function (pluginID, agentIDs, moduleNames, callback) {
var params = {
page: 'godmode/massive/massive_edit_plugins',
get_module_plugin_macros: 1,
plugin_id: pluginID,
agent_ids: agentIDs,
module_names: moduleNames
};
modulePluginMacrosXHR = processGet(params, function (error, data) {
callback(error, data);
});
}
// Extract the a module names array from the agents
var moduleNamesFromAgents = function (agents) {
if (!(agents instanceof Array))
throw new Error('<?php echo __("Invalid agents array"); ?>');
var moduleNames = _.map(agents, function (agent) {
return agent['module_names'];
});
moduleNames = _.intersection.apply(_, moduleNames);
moduleNames = _.chain(moduleNames)
.flatten()
.uniq()
.value();
return moduleNames;
}
var agentsFilteredWithAgents = function (agents, agentIDs) {
if (!(agents instanceof Array))
throw new Error('<?php echo __("Invalid agents array"); ?>');
var agentsFiltered = _.filter(agents, function (agent) {
return _.contains(agentIDs, agent.id.toString());
});
// Hack. Is possible that find returns an object instead of an array
// when the only array item is an object. Probably an Underscore.js bug
if (typeof agentsFiltered !== 'undefined'
&& !(agentsFiltered instanceof Array)
&& (agentsFiltered instanceof Object))
agentsFiltered = [agentsFiltered];
return agentsFiltered;
}
var resetController = function () {
if (typeof pluginXHR !== 'undefined') {
pluginXHR.abort();
pluginXHR = undefined;
}
if (typeof agentsXHR !== 'undefined') {
agentsXHR.abort();
agentsXHR = undefined;
}
if (typeof modulesXHR !== 'undefined') {
modulesXHR.abort();
modulesXHR = undefined;
}
if (typeof modulePluginMacrosXHR !== 'undefined') {
modulePluginMacrosXHR.abort();
modulePluginMacrosXHR = undefined;
}
allowSubmit(false);
agents = [];
hideSpinner();
clearPluginData();
$agentModulesRow.hide();
clearAgentsData();
clearModulesData();
}
var errorHandler = function (error) {
console.log("<?php echo __('Error'); ?>: " + error.message);
// alert("<?php echo __('Error'); ?>: " + err.message);
// Init the plugin id select
$pluginsSelect.val(0).change();
}
$pluginsSelect.change(function (e) {
allowSubmit(false);
// Plugin id
var currentVal = $(this).val();
resetController();
if (currentVal == 0)
return;
try {
showSpinner();
// This asyc functions are executed at the same time
getPlugin(currentVal, function (error, data) {
if (error) {
errorHandler(error);
return;
}
plugin = data;
try {
fillPlugin(plugin);
// Hide spinner only if the another call has finished
if (typeof agentsXHR === 'undefined'
|| agentsXHR.state() === 'resolved'
|| agentsXHR.state() === 'rejected') {
hideSpinner();
}
}
catch (err) {
errorHandler(err);
return;
}
});
// This asyc functions are executed at the same time
getAgents(currentVal, function (error, data) {
if (error) {
errorHandler(error);
return;
}
// This agent variable is global to this script scope
agents = data;
try {
if (agents.length > 0) {
fillAgents(agents);
$agentModulesRow.show();
}
else {
alert("<?php echo __('There are no modules using this plugin'); ?>");
// Abort the another call
if (typeof pluginXHR !== 'undefined') {
pluginXHR.abort();
pluginXHR = undefined;
}
}
// Hide spinner only if the another call has finished
if (typeof pluginXHR === 'undefined'
|| pluginXHR.state() === 'resolved'
|| pluginXHR.state() === 'rejected') {
hideSpinner();
}
}
catch (err) {
errorHandler(err);
return;
}
});
}
catch (err) {
errorHandler(err);
return;
}
}).change(); // Trigger the change
$agentsSelect.change(function (e) {
allowSubmit(false);
var ids = $(this).val();
var modulesSelected = $modulesSelect.val();
try {
var agentsFiltered = agentsFilteredWithAgents(agents, ids);
var modules = moduleNamesFromAgents(agentsFiltered);
fillModules(modules, modulesSelected);
}
catch (err) {
errorHandler(err);
return;
}
});
$modulesSelect.change(function (e) {
allowSubmit(false);
var pluginID = $pluginsSelect.val();
var moduleNames = $(this).val();
var agentIDs = $agentsSelect.val();
if (_.isNull(moduleNames) || _.isUndefined(moduleNames)) {
e.preventDefault();
return false;
}
try {
showSpinner();
clearModulePluginMacrosValues();
getModulePluginMacros(pluginID, agentIDs, moduleNames, function (error, data) {
if (error) {
errorHandler(error);
return;
}
try {
var modulePluginMacros = data;
if (_.isArray(modulePluginMacros) && modulePluginMacros.length > 0) {
fillPluginMacros(modulePluginMacros);
allowSubmit(true);
}
else {
throw new Error('<?php echo __("There was a problem loading the module plugin macros data"); ?>');
}
hideSpinner();
}
catch (err) {
errorHandler(err);
return;
}
});
}
catch (err) {
errorHandler(err);
return;
}
});
$form.submit(function(e) {
if (!canSubmit) {
e.stopImmediatePropagation();
e.preventDefault();
}
else {
$form.find('input.plugin-macro')
.filter(function() {
var val = $(this).val();
if ($(this).data("multiple_values") == true
&& (typeof val === 'undefined'
|| val.length == 0))
return true;
else
return false;
}).prop('disabled', true);
}
});
$(document).ready (function () {
});
</script>

View File

@ -58,6 +58,10 @@ $options_modules = array(
'edit_modules' => __('Bulk module edit'),
'copy_modules' => __('Bulk module copy'));
$options_plugins = array(
'edit_plugins' => __('Bulk plugin edit')
);
if (! check_acl ($config['id_user'], 0, "PM")) {
unset($options_modules['edit_modules']);
}
@ -107,6 +111,9 @@ elseif (in_array($option, array_keys($options_snmp))) {
elseif (in_array($option, array_keys($options_satellite))) {
$tab = 'massive_satellite';
}
elseif (in_array($option, array_keys($options_plugins))) {
$tab = 'massive_plugins';
}
else {
$option = '';
}
@ -133,6 +140,9 @@ switch ($tab) {
case 'massive_satellite':
$options = $options_satellite;
break;
case 'massive_plugins':
$options = $options_plugins;
break;
}
// Set the default option of the category
@ -140,35 +150,30 @@ if ($option == '') {
$option = array_shift(array_keys($options));
}
$alertstab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">'
. html_print_image ('images/op_alerts.png', true,
array ('title' => __('Alerts operations')))
. '</a>',
'active' => $tab == 'massive_alerts');
$alertstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">'
. html_print_image ('images/op_alerts.png', true,
array ('title' => __('Alerts operations')))
. '</a>', 'active' => $tab == 'massive_alerts');
$userstab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">'
. html_print_image ('images/op_workspace.png', true,
array ('title' => __('Users operations')))
. '</a>',
'active' => $tab == 'massive_users');
$userstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">'
. html_print_image ('images/op_workspace.png', true,
array ('title' => __('Users operations')))
. '</a>', 'active' => $tab == 'massive_users');
$agentstab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">'
. html_print_image ('images/bricks.png', true,
array ('title' => __('Agents operations')))
. '</a>',
'active' => $tab == 'massive_agents');
$modulestab = array(
'text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">'
. html_print_image ('images/brick.png', true,
array ('title' => __('Modules operations')))
. '</a>',
'active' => $tab == 'massive_modules');
$agentstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">'
. html_print_image ('images/bricks.png', true,
array ('title' => __('Agents operations')))
. '</a>', 'active' => $tab == 'massive_agents');
$modulestab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">'
. html_print_image ('images/brick.png', true,
array ('title' => __('Modules operations')))
. '</a>', 'active' => $tab == 'massive_modules');
$pluginstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_plugins">'
. html_print_image ('images/plugin.png', true,
array ('title' => __('Plugins operations')))
. '</a>', 'active' => $tab == 'massive_plugins');
$policiestab = enterprise_hook('massive_policies_tab');
@ -189,6 +194,7 @@ if ($satellitetab == ENTERPRISE_NOT_HOOK)
$onheader = array();
$onheader['massive_agents'] = $agentstab;
$onheader['massive_modules'] = $modulestab;
$onheader['massive_plugins'] = $pluginstab;
if (check_acl ($config['id_user'], 0, "PM")) {
$onheader['user_agents'] = $userstab;
}
@ -221,8 +227,7 @@ $submit_template_standby = get_parameter('id_alert_template_standby');
$submit_add = get_parameter('crtbutton');
echo '<div id="loading" display="none">';
echo html_print_image("images/wait.gif", true, array("border" => '0')) .
'<br />';
echo html_print_image("images/wait.gif", true, array("border" => '0')) . '<br />';
echo '<strong>' . __('Please wait...') . '</strong>';
echo '</div>';
?>
@ -254,19 +259,14 @@ echo '</div>';
<?php
echo "<br />";
echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">';
echo '<table border="0">';
echo '<tr>';
echo '<td>';
echo '<table border="0"><tr><td>';
echo __("Action");
echo '</td>';
echo '<td>';
echo '</td><td>';
html_print_select($options, 'option', $option, 'this.form.submit()', '',
0, false, false, false);
if ($option == 'edit_agents' || $option == 'edit_modules')
ui_print_help_tip(__("The blank fields will not be updated"));
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</td></tr></table>';
echo '</form>';
echo "<br />";
@ -310,6 +310,9 @@ switch ($option) {
case 'copy_modules':
require_once ('godmode/massive/massive_copy_modules.php');
break;
case 'edit_plugins':
require_once ('godmode/massive/massive_edit_plugins.php');
break;
default:
if (!enterprise_hook('massive_operations', array($option))) {
require_once ('godmode/massive/massive_config.php');

View File

@ -105,6 +105,7 @@ if (check_acl ($config['id_user'], 0, "PM")) {
$sub2 = array ();
$sub2["godmode/massive/massive_operations&amp;tab=massive_agents"]["text"] = __('Agents operations');
$sub2["godmode/massive/massive_operations&amp;tab=massive_modules"]["text"] = __('Modules operations');
$sub2["godmode/massive/massive_operations&amp;tab=massive_plugins"]["text"] = __('Plugins operations');
if (check_acl ($config['id_user'], 0, "PM")) {
$sub2["godmode/massive/massive_operations&amp;tab=massive_users"]["text"] = __('Users operations');
}

View File

@ -312,7 +312,7 @@ if (($create != "") OR ($view != "")) {
$data[0] = __('Plugin command');
$data[1] = '<input type="text" name="form_execute" id="form_execute" class="command_component command_advanced_conf" size=100 value="'.$form_execute.'" '.$disabled.'>';
if ($locked) {
$data[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf'));
$data[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf lock'));
}
$data[1] .= ' <a href="index.php?sec=gservers&sec2=godmode/servers/plugin&filemanager=1&id_plugin=' . $form_id . '" style="vertical-align: bottom;">';
$data[1] .= html_print_image('images/file.png', true);
@ -323,7 +323,7 @@ if (($create != "") OR ($view != "")) {
$data[0] = __('Plug-in parameters').ui_print_help_icon ('plugin_parameters', true);
$data[1] = '<input type="text" name="form_parameters" id="form_parameters" class="command_component command_advanced_conf" size=100 value="'.$parameters.'" '.$disabled.'>';
if ($locked) {
$data[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf'));
$data[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf lock'));
}
$table->data['plugin_parameters'] = $data;
@ -358,7 +358,7 @@ if (($create != "") OR ($view != "")) {
$i = 1;
while (1) {
// Always print at least one macro
if((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
if ((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
break;
}
$macro_desc_name = 'field'.$i.'_desc';
@ -372,19 +372,19 @@ if (($create != "") OR ($view != "")) {
$macro_hide_value_name = 'field'.$i.'_hide';
$macro_hide_value_value = 0;
if(isset($macros[$i]['desc'])) {
if (isset($macros[$i]['desc'])) {
$macro_desc_value = $macros[$i]['desc'];
}
if(isset($macros[$i]['help'])) {
if (isset($macros[$i]['help'])) {
$macro_help_value = $macros[$i]['help'];
}
if(isset($macros[$i]['value'])) {
if (isset($macros[$i]['value'])) {
$macro_value_value = $macros[$i]['value'];
}
if(isset($macros[$i]['hide'])) {
if (isset($macros[$i]['hide'])) {
$macro_hide_value_value = $macros[$i]['hide'];
// Decrypt hidden macros.
@ -394,15 +394,15 @@ if (($create != "") OR ($view != "")) {
$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[1] = html_print_input_text_extended ($macro_desc_name, $macro_desc_value, 'text-'.$macro_desc_name, '', 30, 255, $locked, '', "class='command_macro'", true);
if ($locked) {
$datam[1] .= html_print_image('images/lock.png', true, array('class' => 'command_macro lock'));
}
$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'));
$datam[3] = html_print_input_text_extended ($macro_value_name, $macro_value_value, 'text-'.$macro_value_name, '', 30, 255, $locked, '', "class='command_component command_macro'", true);
if ($locked) {
$datam[3] .= html_print_image('images/lock.png', true, array('class' => 'command_macro lock'));
}
$table->data['plugin_'.$next_name_number] = $datam;
@ -413,7 +413,7 @@ if (($create != "") OR ($view != "")) {
$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);
$datam[1] = html_print_checkbox_extended ($macro_hide_value_name, 1, $macro_hide_value_value, 0, '', array('class' => 'command_macro'), true, 'checkbox-'.$macro_hide_value_name);
$table->data['plugin_'.$next_name_number] = $datam;
$next_name_number++;
@ -423,10 +423,10 @@ if (($create != "") OR ($view != "")) {
$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);
$datam[1] = html_print_textarea ($macro_help_name, 6, 100, $macro_help_value, 'class="command_macro" style="width: 97%;"' . $tadisabled, true);
if($locked) {
$datam[1] .= html_print_image('images/lock.png', true, array('class' => 'command_advanced_conf'));
if ($locked) {
$datam[1] .= html_print_image('images/lock.png', true, array('class' => 'command_macro lock'));
}
$datam[1] .= "<br><br><br>";
@ -435,22 +435,41 @@ if (($create != "") OR ($view != "")) {
$i++;
}
// Add/Delete buttons
$datam = array ();
$datam[0] = '<a id="add_macro_btn" href="javascript:;">' .
'<span style="font-weight: bold;">' .
__('Add macro') .
'</span>' . '&nbsp;' .
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>';
if (!$locked) {
$datam = array ();
$datam[0] = '<span style="font-weight: bold">'.__('Add macro').'</span> <a href="javascript:new_macro(\'table-form-plugin_\');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) {
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-plugin_\');update_preview();">'.html_print_image('images/delete.png',true).'</a></div>';
$datam[2] = '<div id="delete_macro_button" style="'.$delete_macro_style.'">' .
'<a href="javascript:;">' .
'<span style="font-weight: bold;">' .
__('Delete macro') .
'</span>' . '&nbsp;' .
html_print_image('images/delete.png',true) .
'</a>' .
'</div>';
$table->colspan['plugin_action'][0] = 2;
$table->rowstyle['plugin_action'] = 'text-align:center';
$table->colspan['plugin_action'][2] = 2;
$table->data['plugin_action'] = $datam;
}
else {
$table->colspan['plugin_action'][0] = 4;
}
$table->rowstyle['plugin_action'] = 'text-align:center';
$table->data['plugin_action'] = $datam;
if (defined("METACONSOLE")) {
$table->width = '100%';
@ -749,37 +768,31 @@ ui_require_javascript_file('pandora_modules');
?>
<script type="text/javascript">
$(document).ready(function() {
function update_preview() {
var command = $('#form_execute').val();
var parameters = $('#form_parameters').val();
var i = 1;
while (1) {
if ($('#text-field' + i + '_value').val() == undefined) {
break;
}
if ($('#text-field'+i+'_value').val() != '') {
parameters = parameters
.replace('_field' + i + '_',
$('#text-field' + i + '_value').val());
}
i++;
var locked = <?php echo (int)json_encode((int)$locked); ?>;
function update_preview() {
var command = $('#form_execute').val();
var parameters = $('#form_parameters').val();
var i = 1;
while (1) {
if ($('#text-field' + i + '_value').val() == undefined) {
break;
}
$('#command_preview').html(command+' '+parameters);
if ($('#text-field'+i+'_value').val() != '') {
parameters = parameters
.replace('_field' + i + '_',
$('#text-field' + i + '_value').val());
}
i++;
}
update_preview();
$('.command_component').keyup(function() {
update_preview();
});
});
$('#command_preview').html(command+' '+parameters);
}
function show_locked_dialog(id_plugin, plugin_name) {
var parameters = {};
@ -797,8 +810,7 @@ ui_require_javascript_file('pandora_modules');
$("#dialog_locked")
.prop('title', title)
.html(data);
$("#dialog_locked")
.html(data)
.dialog ({
resizable: true,
draggable: true,
@ -815,16 +827,93 @@ ui_require_javascript_file('pandora_modules');
});
}
<?php
if (!isset($locked)) {
$locked = false;
}
if ($locked) {
?>
$('.command_advanced_conf').click(function() {
alert('<?php echo __("The plugin command cannot be updated because some modules or components are using the plugin."); ?>');
$(document).ready(function() {
// Add macro
var add_macro_click_event = function (event) {
new_macro('table-form-plugin_', function () {
// Remove the locked images and enable the inputs
if (arguments.length > 0) {
var rows = _.toArray(arguments);
_.each(rows, function(row, index) {
row.find('input.command_macro, textarea.command_macro')
.prop('readonly', false)
.prop('disabled', false)
.siblings('img.command_macro.lock')
.remove();
});
}
});
update_preview();
}
$('a#add_macro_btn').click(add_macro_click_event);
// Delete macro
var delete_macro_click_event = function (event) {
delete_macro('table-form-plugin_');
update_preview();
}
$('div#delete_macro_button>a').click(delete_macro_click_event);
update_preview();
$('.command_component').keyup(function() {
update_preview();
});
<?php
});
var add_macro_click_locked_event = function (event) {
var message = '<?php echo __("Some modules or components are using the plugin"); ?>.'
+ '\n' + '<?php echo __("The modules or components should be updated manually or using the bulk operations for plugins after this change"); ?>.'
+ '\n'
+ '\n' + '<?php echo __("Are you sure you want to perform this action?"); ?>';
if (!confirm(message)) {
event.stopImmediatePropagation();
event.preventDefault();
}
}
?>
var command_click_locked_event = function (event) {
var $element = $(this);
if (!$element.is('input') || ($element.is('input') && ($element.prop('readonly') || $element.prop('disabled')))) {
if ($element.prop('id') === 'form_parameters') {
var message = '<?php echo __("Some modules or components are using the plugin"); ?>'
+ '.\n' + '<?php echo __("Are you sure you want to unlock this item?"); ?>';
if (confirm(message)) {
if ($element.is('input')) {
$element
.prop('readonly', false)
.prop('disabled', false)
.siblings('img.command_advanced_conf.lock')
.remove();
}
else {
$element
.siblings('input.command_advanced_conf')
.prop('readonly', false)
.prop('disabled', false)
$element.remove();
}
}
}
else {
alert('<?php echo __("The plugin command cannot be updated because some modules or components are using the plugin."); ?>');
}
}
}
var macros_click_locked_event = function (event) {
alert('<?php echo __("The plugin macros cannot be updated because some modules or components are using the plugin"); ?>');
}
if (locked) {
$('a#add_macro_btn').click(add_macro_click_locked_event);
$('.command_advanced_conf').click(command_click_locked_event);
$('.command_macro').click(macros_click_locked_event);
}
</script>

View File

@ -117,52 +117,53 @@ else {
$result = tags_search_tag(false, $filter);
}
// Form to add new tags or search tags
if (!defined('METACONSOLE')) {
echo "<table border=0 cellpadding=4 cellspacing=4 class='databox data' width=100%>";
echo "<tr>";
echo "<td>";
echo '<b>' . __("Name") . "/" . __("Description") . '</b>';
echo "</td>";
echo "<td align=center>";
echo '<form method=post action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag=0">';
html_print_input_hidden ("search_tag", "1");
html_print_input_text ('tag_name', $tag_name, '', 30, 255, false);
echo "&nbsp;&nbsp;&nbsp;";
html_print_submit_button (__('Filter'), 'filter_button', false, 'class="sub search"');
echo "</form>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
else {
$filters = '<form method=post class="filters_form" action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag=0">';
$filters .= "<table border=0 cellpadding=0 cellspacing=0 class=databox_filters width=70%>";
$filters .= "<tr>";
$filters .= "<td>";
$filters .= __("Name") . "/" . __("Description");
$filters .= "&nbsp;&nbsp;";
$filters .= html_print_input_hidden ("search_tag", "1",true);
$filters .= html_print_input_text ('tag_name', $tag_name, '', 30, 255, true);
$filters .= "</td>";
$filters .= "<td>";
$filters .= html_print_submit_button (__('Filter'), 'filter_button', false, 'class="sub search"',true);
$filters .= "</td>";
$filters .= "</tr>";
$filters .= "</table>";
$filters .= "</form>";
ui_toggle($filters, __("Show Options"));
}
// Prepare pagination
ui_pagination ($total_tags, $url);
// Display tags previously filtered or not
$rowPair = true;
$iterator = 0;
if (!empty($result)) {
// Form to add new tags or search tags
if (!defined('METACONSOLE')) {
echo "<table border=0 cellpadding=4 cellspacing=4 class='databox data' width=100%>";
echo "<tr>";
echo "<td>";
echo '<b>' . __("Name") . "/" . __("Description") . '</b>';
echo "</td>";
echo "<td align=center>";
echo '<form method=post action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag=0">';
html_print_input_hidden ("search_tag", "1");
html_print_input_text ('tag_name', $tag_name, '', 30, 255, false);
echo "&nbsp;&nbsp;&nbsp;";
html_print_submit_button (__('Filter'), 'filter_button', false, 'class="sub search"');
echo "</form>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
else {
$filters = '<form method=post class="filters_form" action="index.php?sec='.$sec.'&sec2=godmode/tag/tag&delete_tag=0">';
$filters .= "<table border=0 cellpadding=0 cellspacing=0 class=databox_filters width=70%>";
$filters .= "<tr>";
$filters .= "<td>";
$filters .= __("Name") . "/" . __("Description");
$filters .= "&nbsp;&nbsp;";
$filters .= html_print_input_hidden ("search_tag", "1",true);
$filters .= html_print_input_text ('tag_name', $tag_name, '', 30, 255, true);
$filters .= "</td>";
$filters .= "<td>";
$filters .= html_print_submit_button (__('Filter'), 'filter_button', false, 'class="sub search"',true);
$filters .= "</td>";
$filters .= "</tr>";
$filters .= "</table>";
$filters .= "</form>";
ui_toggle($filters, __("Show Options"));
}
// Prepare pagination
ui_pagination ($total_tags, $url);
// Display tags previously filtered or not
$rowPair = true;
$iterator = 0;
$table = new stdClass();
$table->width = '100%';
@ -241,7 +242,12 @@ if (!empty($result)) {
html_print_table ($table);
}
else{
if(!defined("METACONSOLE")){
require_once ($config['homedir'] . "/general/firts_task/tags.php");
return;
}
}
echo "<table border=0 cellpadding=0 cellspacing=0 width=100%>";
echo "<tr>";
echo "<td align=right>";

View File

@ -1,141 +1,141 @@
.fileupload_form {
background-color: #373A3D;
background-image: -moz-linear-gradient(center top , #373A3D, #313437);
border-radius: 3px;
font-family: 'PT Sans Narrow',sans-serif;
margin: 0px;
padding: 30px;
background-color: #373A3D;
background-image: -moz-linear-gradient(center top , #373A3D, #313437);
border-radius: 3px;
font-family: 'PT Sans Narrow',sans-serif;
margin: 0px;
padding: 30px;
}
#drop_file {
background-color: #E6E6E6;
border: 20px solid rgba(0, 0, 0, 0);
border-radius: 3px;
color: #707070;
font-size: 16px;
font-weight: bold;
margin-bottom: 30px;
padding: 40px 50px;
text-align: center;
text-transform: uppercase;
background-color: #E6E6E6;
border: 20px solid rgba(0, 0, 0, 0);
border-radius: 3px;
color: #707070;
font-size: 16px;
font-weight: bold;
margin-bottom: 30px;
padding: 40px 50px;
text-align: center;
text-transform: uppercase;
}
#drop_file table {
vertical-align: middle;
vertical-align: middle;
}
#drop_file table td, #drop_file table label {
color: #707070;
font-family: 'PT Sans Narrow',sans-serif;
font-size: 16px;
font-weight: bold;
margin-top: 0;
vertical-align: middle;
color: #707070;
font-family: 'PT Sans Narrow',sans-serif;
font-size: 16px;
font-weight: bold;
margin-top: 0;
vertical-align: middle;
}
#drop_file table select {
float: none;
float: none;
}
#drop_file a {
background-color: #FF9933;
border-radius: 2px;
color: #FFFFFF;
cursor: pointer;
display: inline-block;
font-size: 14px;
line-height: 1;
padding: 12px 26px;
background-color: #80BA27;
border-radius: 2px;
color: #FFFFFF;
cursor: pointer;
display: inline-block;
font-size: 14px;
line-height: 1;
padding: 12px 26px;
}
#drop_file a:hover {
background-color: #FFB972;
text-decoration: none;
background-color: #A6CE67;
text-decoration: none;
}
#drop_file input {
display: none;
display: none;
}
.fileupload_form ul {
border-bottom: 1px solid #3D4043;
border-top: 1px solid #2B2E31;
list-style: none outside none;
margin: 0 -30px;
padding: 0;
border-bottom: 1px solid #3D4043;
border-top: 1px solid #2B2E31;
list-style: none outside none;
margin: 0 -30px;
padding: 0;
}
.fileupload_form ul li {
background-color: #333639;
background-image: -moz-linear-gradient(center top , #333639, #303335);
border-bottom: 1px solid #2B2E31;
border-top: 1px solid #3D4043;
padding: 15px;
position: relative;
background-color: #333639;
background-image: -moz-linear-gradient(center top , #333639, #303335);
border-bottom: 1px solid #2B2E31;
border-top: 1px solid #3D4043;
padding: 15px;
position: relative;
}
.fileupload_form ul li #input-progress {
left: 68px;
position: absolute;
left: 68px;
position: absolute;
}
.fileupload_form ul li p {
color: #EEEEEE;
font-size: 12px;
font-weight: bold;
left: 95px;
overflow: hidden;
position: absolute;
top: 12px;
white-space: nowrap;
color: #EEEEEE;
font-size: 12px;
font-weight: bold;
left: 95px;
overflow: hidden;
position: absolute;
top: 12px;
white-space: nowrap;
}
.fileupload_form ul li i {
color: #7F7F7F;
display: block;
font-style: normal;
font-weight: normal;
color: #7F7F7F;
display: block;
font-style: normal;
font-weight: normal;
}
.fileupload_form ul li canvas {
left: 13px;
position: absolute;
top: 15px;
left: 13px;
position: absolute;
top: 15px;
}
.fileupload_form ul li span {
background: url("../../images/check-cross.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
cursor: pointer;
height: 12px;
position: absolute;
right: 13px;
top: 34px;
width: 15px;
background: url("../../images/check-cross.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
cursor: pointer;
height: 12px;
position: absolute;
right: 13px;
top: 34px;
width: 15px;
}
.fileupload_form ul li div {
display: block !important;
display: block !important;
}
.fileupload_form ul li.working span {
background-position: 0 -12px;
height: 16px;
background-position: 0 -12px;
height: 16px;
}
.fileupload_form ul li.loading span {
background: url("../../images/spinner.gif") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
height: 16px;
background: url("../../images/spinner.gif") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
height: 16px;
}
.fileupload_form ul li.suc span {
background: url("../../images/check-cross.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
height: 12px;
background: url("../../images/check-cross.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
height: 12px;
}
.fileupload_form ul li.suc p {
color: #5A8629;
color: #5A8629;
}
.fileupload_form ul li.error span {
background: url("../../images/check-cross.png") no-repeat scroll 0 -12px rgba(0, 0, 0, 0);
height: 16px;
background: url("../../images/check-cross.png") no-repeat scroll 0 -12px rgba(0, 0, 0, 0);
height: 16px;
}
.fileupload_form ul li.error p {
color: #FF3333;
color: #FF3333;
}
#log_zone {
background-color: #E6E6E6;
border: 20px solid rgba(0, 0, 0, 0);
border-radius: 3px;
color: #707070;
font-size: 12px;
margin-bottom: 30px;
padding: 10px;
text-align: left;
background-color: #E6E6E6;
border: 20px solid rgba(0, 0, 0, 0);
border-radius: 3px;
color: #707070;
font-size: 12px;
margin-bottom: 30px;
padding: 10px;
text-align: left;
}
#box_online {
background-color: #E6E6E6;
padding: 10px;
background-color: #E6E6E6;
padding: 10px;
}

View File

@ -16,21 +16,25 @@
global $config;
ui_require_css_file('update_manager', 'godmode/update_manager/');
// ui_require_css_file('update_manager', 'godmode/update_manager/');
$baseurl = ui_get_full_url(false, false, false, false);
?>
<!-- Add the stylesheet here cause somehow the 'ui_require_css_file' is not working on the metaconsole and there is no time to fix it -->
<link rel="stylesheet" type="text/css" href="<?php echo $baseurl; ?>/godmode/update_manager/update_manager.css">
<script type="text/javascript">
<?php
echo "var drop_the_package_here_or ='" . __('Drop the package here or') . "';\n";
echo "var browse_it ='" . __('browse it') . "';\n";
echo "var the_package_has_been_uploaded_successfully ='" . __('The package has been uploaded successfully.') . "';\n";
echo "var remember_that_this_package_will =\"" . __('Remember that this package will override the actual Pandora FMS files and it is recommended to do a backup before continue with the update.') . "\";\n";
echo "var click_on_the_file_below_to_begin ='" . __('Click on the file below to begin.') . "';\n";
echo "var updating ='" . __('Updating') . "';\n";
echo "var package_updated_successfully ='" . __('Package updated successfully.') . "';\n";
echo "var if_there_are_any_database_change ='" . __('If there are any database change, it will be applied on the next login.') . "';\n";
echo "var package_not_updated ='" . __('Package not updated.') . "';\n";
?>
var drop_the_package_here_or = "<?php echo __('Drop the package here or'); ?>\n";
var browse_it = "<?php echo __('browse it'); ?>\n";
var the_package_has_been_uploaded_successfully = "<?php echo __('The package has been uploaded successfully.'); ?>\n";
var remember_that_this_package_will = "<?php echo __('Remember that this package will override the actual Pandora FMS files and it is recommended to do a backup before continue with the update.'); ?>\n";
var click_on_the_file_below_to_begin = "<?php echo __('Click on the file below to begin.'); ?>\n";
var updating = "<?php echo __('Updating'); ?>\n";
var package_updated_successfully = "<?php echo __('Package updated successfully.'); ?>\n";
var if_there_are_any_database_change = "<?php echo __('If there are any database change, it will be applied on the next login.'); ?>\n";
var package_not_updated = "<?php echo __('Package not updated.'); ?>\n";
</script>
<form id="form-offline_update" method="post" enctype="multipart/form-data" class="fileupload_form">
@ -38,12 +42,12 @@ ui_require_css_file('update_manager', 'godmode/update_manager/');
<ul></ul>
</form>
<script src="include/javascript/jquery.fileupload.js"></script>
<script src="include/javascript/jquery.iframe-transport.js"></script>
<script src="include/javascript/jquery.knob.js"></script>
<script src="<?php echo $baseurl; ?>/include/javascript/jquery.fileupload.js"></script>
<script src="<?php echo $baseurl; ?>/include/javascript/jquery.iframe-transport.js"></script>
<script src="<?php echo $baseurl; ?>/include/javascript/jquery.knob.js"></script>
<script src="include/javascript/update_manager.js"></script>
<script src="<?php echo $baseurl; ?>/include/javascript/update_manager.js"></script>
<script type="text/javascript">
form_upload();
</script>
form_upload("<?php echo $baseurl; ?>");
</script>

View File

@ -53,14 +53,14 @@ ui_print_page_header($title,
switch ($tab) {
case 'setup':
require("update_manager.setup.php");
require($config['homedir'] . "/godmode/update_manager/update_manager.setup.php");
break;
case 'offline':
require("update_manager.offline.php");
require($config['homedir'] . "/godmode/update_manager/update_manager.offline.php");
break;
case 'online':
default:
require("update_manager.online.php");
require($config['homedir'] . "/godmode/update_manager/update_manager.online.php");
break;
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 854 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

View File

@ -15,8 +15,8 @@
global $config;
require_once("include/functions_update_manager.php");
require_once("include/functions_graph.php");
require_once($config['homedir'] . "/include/functions_update_manager.php");
require_once($config['homedir'] . "/include/functions_graph.php");
enterprise_include_once("include/functions_update_manager.php");
$upload_file = (boolean) get_parameter("upload_file");
@ -131,7 +131,7 @@ if ($install_package) {
if (file_exists($config["homedir"]."/".$line)) {
rename($config["homedir"]."/".$line, $package."/backup/".$line);
}
// Tries to move the new file to the Integria directory
// Tries to move the new file to the Pandora directory
$dirname = dirname($line);
if (!file_exists($config["homedir"]."/".$dirname)) {
$dir_array = explode("/", $dirname);

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC150629';
$build_version = 'PC150630';
$pandora_version = 'v6.0dev';
// Do not overwrite default timezone set if defined.

View File

@ -8049,40 +8049,46 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
if (defined ('METACONSOLE')) {
return;
}
if (is_nan($id_module) || $id_module <= 0) {
returnError('error_module_graph', __(''));
return;
}
$id_exist = (bool) db_get_value ('id_agente_modulo', 'tagente_modulo', 'id_agente_modulo', $id_module);
if (!$id_exist) {
// returnError('id_not_found');
return;
}
$graph_seconds =(!empty($other) && isset($other['data'])) ? $other['data'] : 3600; // 1 hour by default
$graph_seconds =
(!empty($other) && isset($other['data']))
?
$other['data']
:
SECONDS_1HOUR; // 1 hour by default
if (is_nan($graph_seconds) || $graph_seconds <= 0) {
// returnError('error_module_graph', __(''));
return;
}
// Get the html item
$graph_html = grafico_modulo_sparse($id_module, $graph_seconds, false, 600, 300, '',
'', false, false, true, time(), '', 0, 0, true, true,
ui_get_full_url(false) . '/', 1, false, '', false, true);
$graph_html = grafico_modulo_sparse(
$id_module, $graph_seconds, false, 600, 300, '',
'', false, false, true, time(), '', 0, 0, true, true,
ui_get_full_url(false) . '/', 1, false, '', false, true);
$graph_image_file_encoded = false;
// Get the src of the html item
if (preg_match("/<img src='(.+)'>/", $graph_html, $matches)) {
if (isset($matches) && isset($matches[1])) {
$file_url = $matches[1];
// Get the file
$graph_image_file = file_get_contents($file_url);
if ($graph_image_file !== false) {
// Encode the file
$graph_image_file_encoded = base64_encode($graph_image_file);

View File

@ -95,36 +95,43 @@ function reporting_get_name($id_report) {
return db_get_value('name', 'treport', 'id_report', $id_report);
}
function reporting_make_reporting_data($id_report, $date, $time,
$period = null, $type = 'dinamic', $force_width_chart = null,
$force_height_chart = null) {
function reporting_make_reporting_data($report = null, $id_report,
$date, $time, $period = null, $type = 'dinamic',
$force_width_chart = null, $force_height_chart = null) {
global $config;
$return = array();
$report = db_get_row ('treport', 'id_report', $id_report);
if (!empty($report)) {
$contents = $report['contents'];
}
else {
$report = db_get_row ('treport', 'id_report', $id_report);
switch ($config["dbtype"]) {
case "mysql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, "`order`");
break;
case "postgresql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
case "oracle":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
}
}
$datetime = strtotime($date . ' ' . $time);
$report["datetime"] = $datetime;
$report["group"] = $report['id_group'];
$report["group_name"] = groups_get_name ($report['id_group']);
$report['contents'] = array();
$datetime = strtotime($date . ' ' . $time);
$report["datetime"] = $datetime;
switch ($config["dbtype"]) {
case "mysql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, "`order`");
break;
case "postgresql":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
case "oracle":
$contents = db_get_all_rows_field_filter ("treport_content",
"id_report", $id_report, '"order"');
break;
}
if ($contents === false) {
if (empty($contents)) {
return reporting_check_structure_report($report);
}
@ -477,9 +484,14 @@ function reporting_SLA($report, $content, $type = 'dinamic',
$edge_interval = 10;
$slas = db_get_all_rows_field_filter (
'treport_content_sla_combined',
'id_report_content', $content['id_rc']);
if (empty($content['subitems'])) {
$slas = db_get_all_rows_field_filter (
'treport_content_sla_combined',
'id_report_content', $content['id_rc']);
}
else {
$slas = $content['subitems'];
}
if (empty($slas)) {
$return['failed'] = __('There are no SLAs defined');
@ -929,12 +941,19 @@ function reporting_event_top_n($report, $content, $type = 'dinamic',
$top_n_value = $content['top_n_value'];
$show_graph = $content['show_graph'];
//Get all the related data
$sql = sprintf("SELECT id_agent_module, server_name
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$tops = db_process_sql ($sql);
if (empty($content['subitems'])) {
//Get all the related data
$sql = sprintf("SELECT id_agent_module, server_name
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$tops = db_process_sql ($sql);
}
else {
$tops = $content['subitems'];
}
// Get chart
reporting_set_conf_charts($width, $height, $only_image, $type,
@ -1727,13 +1746,22 @@ function reporting_exception($report, $content, $type = 'dinamic',
//Get all the related data
$sql = sprintf("
SELECT id_agent_module, server_name, operation
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$exceptions = db_process_sql ($sql);
if (empty($content['subitems'])) {
//Get all the related data
$sql = sprintf("
SELECT id_agent_module, server_name, operation
FROM treport_content_item
WHERE id_report_content = %d", $content['id_rc']);
$exceptions = db_process_sql ($sql);
}
else {
$exceptions = $content['subitems'];
}
if ($exceptions === false) {
$return['failed'] = __('There are no Agent/Modules defined');
}
@ -3729,14 +3757,21 @@ function reporting_availability($report, $content) {
}
$sql = sprintf("
SELECT id_agent_module,
server_name, operation
FROM treport_content_item
WHERE id_report_content = %d",
$content['id_rc']);
if (empty($content['subitems'])) {
$sql = sprintf("
SELECT id_agent_module,
server_name, operation
FROM treport_content_item
WHERE id_report_content = %d",
$content['id_rc']);
$items = db_process_sql ($sql);
}
else {
$items = $content['subitems'];
}
$items = db_process_sql ($sql);
$data = array();
@ -3964,9 +3999,16 @@ function reporting_general($report, $content) {
$return["max"]["agent"] = null;
$return["max"]["module"] = null;
$generals = db_get_all_rows_filter(
'treport_content_item',
array('id_report_content' => $content['id_rc']));
if (empty($content['subitems'])) {
$generals = db_get_all_rows_filter(
'treport_content_item',
array('id_report_content' => $content['id_rc']));
}
else {
$generals = $content['subitems'];
}
if (empty($generals)) {
$generals = array();
}

View File

@ -500,7 +500,8 @@ function reports_get_report_types ($template = false, $not_editor = false) {
$types['simple_baseline_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Simple baseline graph'));
if ($not_editor == false)
$types['automatic_custom_graph'] = array('optgroup' => __('Graphs'),
$types['automatic_custom_graph'] = array(
'optgroup' => __('Graphs'),
'name' => __('Custom graph'));
$types['custom_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Custom graph'));
@ -513,7 +514,7 @@ function reports_get_report_types ($template = false, $not_editor = false) {
$types['sql_graph_hbar'] = array('optgroup' => __('Graphs'),
'name' => __('SQL horizonal bar graph'));
}
if ($template) {
if ($template && !defined('METACONSOLE')) {
$types['automatic_graph'] = array('optgroup' => __('Graphs'),
'name' => __('Automatic combined Graph'));
}

View File

@ -797,7 +797,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
}));
$('#menu_cancelzoom_' + graph_id)
.attr('src', homeurl + '/images/zoom_cross.png');
.attr('src', homeurl + '/images/zoom_cross_grey.png');
currentRanges = ranges;
// don't fire event on the overview to prevent eternal loop
@ -1250,7 +1250,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
}));
$('#menu_cancelzoom_' + graph_id)
.attr('src', homeurl + '/images/zoom_cross.disabled.png');
.attr('src', homeurl + '/images/zoom_cross_grey.disabled.png');
overview.clearSelection();
currentRanges = null;
});

View File

@ -299,14 +299,14 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
"border: solid 1px #666; ".
"border-bottom: 0px; " .
"padding: 4px 4px 4px 4px'>
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
<a href='javascript:'><img id='menu_cancelzoom_$graph_id' src='".$homeurl."images/zoom_cross_grey.disabled.png' alt='".__('Cancel zoom')."' title='".__('Cancel zoom')."'></a>";
if ($threshold) {
$return .= " <a href='javascript:'><img id='menu_threshold_$graph_id' src='".$homeurl."images/chart_curve_threshold.png' alt='".__('Warning and Critical thresholds')."' title='".__('Warning and Critical thresholds')."'></a>";
}
$return .= " <a href='javascript:'><img id='menu_overview_$graph_id' src='".$homeurl."images/chart_curve_overview.png' alt='".__('Overview graph')."' title='".__('Overview graph')."'></a>";
// Export buttons
$return .= " <a href='javascript:'><img id='menu_export_csv_$graph_id' src='".$homeurl."images/csv.png' alt='".__('Export to CSV')."' title='".__('Export to CSV')."'></a>";
$return .= " <a href='javascript:'><img id='menu_export_csv_$graph_id' src='".$homeurl."images/csv_grey.png' alt='".__('Export to CSV')."' title='".__('Export to CSV')."'></a>";
// Button disabled. This feature works, but seems that is not useful enough to the final users.
//$return .= " <a href='javascript:'><img id='menu_export_json_$graph_id' src='".$homeurl."images/json.png' alt='".__('Export to JSON')."' title='".__('Export to JSON')."'></a>";

View File

@ -6,10 +6,16 @@
<h1>Action Threshold</h1>
<p>
An alert action will not be executed more than once every action_threshold seconds, regardless of the number of times the alert is fired.
For example, if you have configured an action that sends you an email when the alert fires and you don't want to receive more than one email per hour, you can set the action_threshold to 3600.
Bear in mind that the individual action_threshold of an action overrides the global action_threshold of the alert.
An alert action will not be executed more than once every
action_threshold seconds, regardless of the number of times the alert is
fired.
</p>
<p>
For example, if you have configured an action that sends you an email
when the alert fires and you don't want to receive more than one email
per hour, you can set the action_threshold to 3600.
</p>
<p>
Bear in mind that the individual action_threshold of an action overrides
the global action_threshold of the alert.
</p>

View File

@ -6,10 +6,16 @@
<h1>Umbral de acción</h1>
<p>
Una acción de una alerta no se ejecutará más de una vez cada action_threshold segundos, independientemenete del número de veces que se dispare la alerta.
Por ejemplo, si ha configurado una acción que le envía un email cuando la alerta se dispara y no quiere recibir más de un email por hora, puede configurar un action_threshold de 3600.
Tenga en cuenta que el action_threshold individual de una acción tiene precedencia sobre el action_threshold global de una alerta.
Una acción de una alerta no se ejecutará más de una vez cada
action_threshold segundos, independientemenete del número de veces que
se dispare la alerta.
</p>
<p>
Por ejemplo, si ha configurado una acción que le envía un email cuando
la alerta se dispara y no quiere recibir más de un email por hora, puede
configurar un action_threshold de 3600.
</p>
<p>
Tenga en cuenta que el action_threshold individual de una acción tiene
precedencia sobre el action_threshold global de una alerta.
</p>

View File

@ -475,7 +475,10 @@ function delete_macro(prefix) {
var $row3 = $('#'+prefix+nrow3).remove();
}
function new_macro(prefix) {
// The callback parameter is for a callback function
// that will receive the 3 rows (function(row1, row2, row3))
// to edit them before the new_macro function ends.
function new_macro(prefix, callback) {
$('#delete_macro_button').show();
var next_row = parseInt($('#next_row').html());
@ -539,6 +542,9 @@ function new_macro(prefix) {
$('#text-field' + next_number + '_value').val('');
$('#radio-field' + next_number + '_hide').val(0);
if (typeof callback === 'function')
callback($row1, $row2, $row3);
function changeTdId() {
switch(this.id) {
case prefix + (nrow1) + '-0':
@ -677,6 +683,9 @@ function load_plugin_macros_fields(row_model_id) {
add_macro_field(macro, row_model_id);
}
});
// Add again the hover event to the 'force_callback' elements
forced_title_callback();
}
}
});

View File

@ -1,6 +1,11 @@
var correct_install_progress = true;
function form_upload () {
function form_upload (homeurl) {
if (typeof homeurl !== 'undefined')
homeurl += '/';
else
homeurl = '';
//Thanks to: http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/
var ul = $('#form-offline_update ul');
@ -18,7 +23,7 @@ function form_upload () {
// Initialize the jQuery File Upload plugin
$('#form-offline_update').fileupload({
url: 'ajax.php?page=include/ajax/update_manager.ajax&upload_file=true',
url: homeurl + 'ajax.php?page=include/ajax/update_manager.ajax&upload_file=true',
// This element will accept file drag/drop uploading
dropZone: $('#drop_file'),
@ -31,8 +36,8 @@ function form_upload () {
var tpl = $('<li>' +
'<input type="text" id="input-progress" ' +
'value="0" data-width="55" data-height="55" '+
'data-fgColor="#FF9933" data-readOnly="1" ' +
'data-bgColor="#3e4043" />' +
'data-fgColor="#80BA27" data-readOnly="1" ' +
'data-bgColor="#3E4043" />' +
'<p></p><span></span>' +
'</li>');
@ -139,7 +144,7 @@ function form_upload () {
data.context.find('input').val(0).change();
// Begin the installation
install_package(res.package, 'filename');
install_package(res.package, homeurl);
});
}
else {
@ -188,30 +193,12 @@ function formatFileSize(bytes) {
return (bytes / 1000).toFixed(2) + ' KB';
}
function install_package(package) {
var parameters = {};
parameters['page'] = 'include/ajax/update_manager.ajax';
parameters['install_package'] = 1;
parameters['package'] = package;
function install_package (package, homeurl) {
if (typeof homeurl !== 'undefined')
homeurl += '/';
else
homeurl = '';
jQuery.post(
"ajax.php",
parameters,
function (data) {
if (data["status"] == "success") {
install_package_step2(package);
}
else {
$("#box_online .loading").hide();
$("#box_online .content").html(data['message']);
stop_check_progress = 1;
}
},
"json"
);
}
function install_package (package) {
var parameters = {};
parameters['page'] = 'include/ajax/update_manager.ajax';
parameters['install_package'] = 1;
@ -222,7 +209,7 @@ function install_package (package) {
$.ajax({
type: 'POST',
url: 'ajax.php',
url: homeurl + 'ajax.php',
data: parameters,
dataType: "json",
success: function (data) {
@ -245,10 +232,10 @@ function install_package (package) {
});
// Check the status of the update
check_install_package(package);
check_install_package(package, homeurl);
}
function check_install_package(package) {
function check_install_package(package, homeurl) {
var parameters = {};
parameters['page'] = 'include/ajax/update_manager.ajax';
parameters['check_install_package'] = 1;
@ -256,7 +243,7 @@ function check_install_package(package) {
$.ajax({
type: 'POST',
url: 'ajax.php',
url: homeurl + 'ajax.php',
data: parameters,
dataType: "json",
success: function(data) {
@ -275,13 +262,18 @@ function check_install_package(package) {
var isInstalling = $('#form-offline_update ul').find('li').hasClass('loading');
if (data.progress < 100 && isInstalling) {
// Recursive call to check the update status
check_install_package(package);
check_install_package(package, homeurl);
}
}
})
}
function check_online_free_packages() {
function check_online_free_packages(homeurl) {
if (typeof homeurl !== 'undefined')
homeurl += '/';
else
homeurl = '';
$("#box_online .checking_package").show();
var parameters = {};
@ -289,7 +281,7 @@ function check_online_free_packages() {
parameters['check_online_free_packages'] = 1;
jQuery.post(
"ajax.php",
homeurl + "ajax.php",
parameters,
function (data) {
$("#box_online .checking_package").hide();
@ -301,7 +293,12 @@ function check_online_free_packages() {
);
}
function update_last_package(package, version) {
function update_last_package(package, version, homeurl) {
if (typeof homeurl !== 'undefined')
homeurl += '/';
else
homeurl = '';
version_update = version;
$("#box_online .content").html("");
@ -316,7 +313,7 @@ function update_last_package(package, version) {
parameters['version'] = version;
jQuery.post(
"ajax.php",
homeurl + "ajax.php",
parameters,
function (data) {
if (data['in_progress']) {
@ -325,8 +322,10 @@ function update_last_package(package, version) {
$("#box_online .content").html(data['message']);
install_free_package(package,version);
setTimeout(check_progress_update, 1000);
install_free_package(package, version, homeurl);
setTimeout(function () {
check_progress_update(homeurl);
}, 1000);
}
else {
$("#box_online .content").html(data['message']);
@ -336,7 +335,12 @@ function update_last_package(package, version) {
);
}
function check_progress_update() {
function check_progress_update(homeurl) {
if (typeof homeurl !== 'undefined')
homeurl += '/';
else
homeurl = '';
if (stop_check_progress) {
return;
}
@ -346,7 +350,7 @@ function check_progress_update() {
parameters['check_update_free_package'] = 1;
jQuery.post(
"ajax.php",
homeurl + "ajax.php",
parameters,
function (data) {
if (stop_check_progress) {
@ -363,7 +367,9 @@ function check_progress_update() {
$("#box_online .progressbar .progressbar_img").attr('src',
data['progressbar']);
setTimeout(check_progress_update, 1000);
setTimeout(function () {
check_progress_update(homeurl);
}, 1000);
}
}
else {
@ -375,7 +381,12 @@ function check_progress_update() {
);
}
function install_free_package(package,version) {
function install_free_package(package, version, homeurl) {
if (typeof homeurl !== 'undefined')
homeurl += '/';
else
homeurl = '';
var parameters = {};
parameters['page'] = 'include/ajax/update_manager.ajax';
parameters['install_free_package'] = 1;
@ -385,7 +396,7 @@ function install_free_package(package,version) {
jQuery.ajax ({
data: parameters,
type: 'POST',
url: "ajax.php",
url: homeurl + "ajax.php",
timeout: 600000,
dataType: "json",
error: function(data) {
@ -393,7 +404,7 @@ function install_free_package(package,version) {
stop_check_progress = 1;
$("#box_online .loading").hide();
$("#box_online .progressbar").hide();
$("#box_online .progressbar").hide();
$("#box_online .content").html(unknown_error_update_manager);
},
success: function (data) {

View File

@ -63,7 +63,7 @@
<div style='height: 10px'>
<?php
$version = '6.0dev';
$build = '150629';
$build = '150630';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -176,7 +176,8 @@ $table->size[0] = '60px';
$table->colspan[0][1] = 2;
$table->style[0] = 'text-align:center;';
$table->data = array ();
$table->data[0][0] = html_print_image("images/reporting32.png", true, array("width" => "32", "height" => "32"));
$table->data[0][0] = html_print_image("images/reporting32.png", true,
array("width" => "32", "height" => "32"));
if (defined("METACONSOLE")) {
if ($report['description'] != '') {
$table->data[0][1] = '<div style="">' . __("Description: ") . $report['description'] . '</div>';
@ -215,7 +216,8 @@ else {
}
$table->data[0][1] .= '<div style="text-align:right; width:100%; margin-right:50px">'.__('Set initial date') . html_print_checkbox('enable_init_date', 1, $enable_init_date, true);
$html_enterprise = enterprise_hook('reporting_print_button_PDF', array($id_report));
$html_enterprise = enterprise_hook('reporting_print_button_PDF',
array($id_report));
if ($html_enterprise !== ENTERPRISE_NOT_HOOK) {
$table->data[0][1] .= $html_enterprise;
}
@ -245,7 +247,9 @@ if ($enable_init_date) {
}
}
$report = reporting_make_reporting_data($id_report, $date, $time, $period, 'dinamic');
$report = reporting_make_reporting_data(null, $id_report, $date, $time,
$period, 'dinamic');
reporting_html_print_report($report);
echo "<br>";

View File

@ -120,7 +120,7 @@ switch ($date_mode) {
}
$report = reporting_make_reporting_data($id_report, $date, $time,
$report = reporting_make_reporting_data(null, $id_report, $date, $time,
$period, 'static');
//------- Removed the unused fields ------------------------------------

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 6.0dev
%define release 150629
%define release 150630
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 6.0dev
%define release 150629
%define release 150630
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('graph_res','5'),
('step_compact','1'),
('db_scheme_version','6.0dev'),
('db_scheme_build','PD150629'),
('db_scheme_build','PD150630'),
('show_unknown','0'),
('show_lastalerts','1'),
('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 6.0dev-150629
Version: 6.0dev-150630
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="6.0dev-150629"
pandora_version="6.0dev-150630"
package_cpan=0
package_pandora=1

View File

@ -43,7 +43,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "6.0dev";
my $pandora_build = "150629";
my $pandora_build = "150630";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.0dev
%define release 150629
%define release 150630
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.0dev
%define release 150629
%define release 150630
Summary: Pandora FMS Server
Name: %{name}

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB;
# version: define current version
my $version = "6.0dev PS150629";
my $version = "6.0dev PS150630";
# Pandora server configuration
my %conf;

View File

@ -35,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "6.0dev PS150629";
my $version = "6.0dev PS150630";
# save program name for logging
my $progname = basename($0);