Merge branch 'develop' into feature/meta-agent-cache

This commit is contained in:
Ramon Novoa 2015-04-06 15:26:51 +02:00
commit 45ff0d0b6a
41 changed files with 534 additions and 188 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{150325} {150327}
ViewReadme ViewReadme
{Yes} {Yes}

View File

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

View File

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

View File

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

View File

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

View File

@ -63,3 +63,10 @@ UPDATE `talert_commands` SET `fields_descriptions` = '[\"Destination addres
-- Table `tconfig` -- Table `tconfig`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
INSERT INTO `tconfig` (`token`, `value`) VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}');
-- ---------------------------------------------------------------------
-- Table `tnetwork_map`
-- ---------------------------------------------------------------------
ALTER TABLE `tnetwork_map` ADD COLUMN `id_tag` int(11) DEFAULT 0;
ALTER TABLE `tnetwork_map` ADD COLUMN `store_group` int(11) DEFAULT 0;
UPDATE `tnetwork_map` SET `store_group` = `id_group`;

View File

@ -63,3 +63,10 @@ UPDATE talert_commands SET fields_descriptions = '[\"Destination address\",
-- Table `tconfig` -- Table `tconfig`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
INSERT INTO tconfig (token, value) VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); INSERT INTO tconfig (token, value) VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}');
-- ---------------------------------------------------------------------
-- Table `tnetwork_map`
-- ---------------------------------------------------------------------
ALTER TABLE tnetwork_map ADD COLUMN id_tag NUMBER(11, 0) DEFAULT 0;
ALTER TABLE tnetwork_map ADD COLUMN store_group NUMBER(11, 0) DEFAULT 0;
UPDATE tnetwork_map SET store_group = id_group;

View File

@ -61,3 +61,10 @@ UPDATE "talert_commands" SET "fields_descriptions" = '[\"Destination addres
-- Table `tconfig` -- Table `tconfig`
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
INSERT INTO "tconfig" ("token", "value") VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'); INSERT INTO "tconfig" ("token", "value") VALUES ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}');
-- ---------------------------------------------------------------------
-- Table `tnetwork_map`
-- ---------------------------------------------------------------------
ALTER TABLE "tnetwork_map" ADD COLUMN "id_tag" INTEGER DEFAULT 0;
ALTER TABLE "tnetwork_map" ADD COLUMN "store_group" INTEGER DEFAULT 0;
UPDATE "tnetwork_map" SET "store_group" = "id_group";

View File

@ -120,24 +120,32 @@ if (is_ajax ()) {
$fields_value_select = array(); $fields_value_select = array();
$fv = explode(';', $field_value); $fv = explode(';', $field_value);
if (!empty($fv)) { if (count($fv) > 1) {
foreach ($fv as $fv_option) { if (!empty($fv)) {
$fv_option = explode(',', $fv_option); foreach ($fv as $fv_option) {
$fv_option = explode(',', $fv_option);
if (empty($fv_option)) if (empty($fv_option))
continue; continue;
if (!isset($fv_option[1])) if (!isset($fv_option[1]))
$fv_option[1] = $fv_option[0]; $fv_option[1] = $fv_option[0];
$fields_value_select[$fv_option[0]] = $fv_option[1]; $fields_value_select[$fv_option[0]] = $fv_option[1];
}
} }
}
$ffield = html_print_select($fields_value_select, $ffield = html_print_select($fields_value_select,
'field'.$i.'_value', '', '', '', 0, true, false, false, 'fields'); 'field'.$i.'_value', '', '', '', 0, true, false, false, 'fields');
$rfield = html_print_select($fields_value_select, $rfield = html_print_select($fields_value_select,
'field'.$i.'_recovery_value', '', '', '', 0, true, false, false, 'fields_recovery'); 'field'.$i.'_recovery_value', '', '', '', 0, true, false, false, 'fields_recovery');
}
else{
$ffield = html_print_textarea ('field' . $i . '_value',1, 1, $fv[0],
'style="min-height:40px" class="fields"', true);
$rfield = html_print_textarea ('field' . $i . '_recovery_value', 1, 1, $fv[0],
'style="min-height:40px" class="fields_recovery"', true);
}
} }
} }
else { else {

View File

@ -284,7 +284,8 @@ $(document).ready (function () {
$table_macros_field.hide(); $table_macros_field.hide();
continue; continue;
} }
old_value = '';
old_recovery_value = '';
// Only keep the value if is provided from hidden (first time) // Only keep the value if is provided from hidden (first time)
if (($("[name=field" + i + "_value]").attr('id')) if (($("[name=field" + i + "_value]").attr('id'))
== ("hidden-field" + i + "_value")) { == ("hidden-field" + i + "_value")) {
@ -301,10 +302,14 @@ $(document).ready (function () {
// Replace the old column with the new // Replace the old column with the new
$table_macros_field.replaceWith(field_row); $table_macros_field.replaceWith(field_row);
if (old_value != '' && old_recovery_value != ''){
$("[name=field" + i + "_value]").val(old_value); $("[name=field" + i + "_value]").val(old_value);
$("[name=field" + i + "_recovery_value]").val(old_recovery_value); $("[name=field" + i + "_recovery_value]").val(old_recovery_value);
}
else{
$("[name=field" + i + "_value]").val($("[name=field" + i + "_value]").val());
$("[name=field" + i + "_recovery_value]").val($("[name=field" + i + "_recovery_value]").val());
}
// Add help hint only in first field // Add help hint only in first field
if (i == 1) { if (i == 1) {
var td_content = $table_macros_field.find('td').eq(0); var td_content = $table_macros_field.find('td').eq(0);

View File

@ -236,11 +236,11 @@ $table->data[0][4] = html_print_submit_button(__('Search'), 'search',
if(defined('METACONSOLE')){ if(defined('METACONSOLE')){
$table->width = '50%'; $table->width = '96%';
$form_filter = "<form class='filters_form' method='post'>"; $form_filter = "<form class='filters_form' method='post'>";
$form_filter .= html_print_table($table, true); $form_filter .= html_print_table($table, true);
$form_filter .= "</form>"; $form_filter .= "</form>";
echo $form_filter; ui_toggle($form_filter, __('Show Options'));
}else{ }else{
$form_filter = "<form method='post'>"; $form_filter = "<form method='post'>";
$form_filter .= html_print_table($table, true); $form_filter .= html_print_table($table, true);

View File

@ -1344,6 +1344,7 @@ class Tree {
); );
if (defined('METACONSOLE') && !empty($server)) { if (defined('METACONSOLE') && !empty($server)) {
$graph_params["avg_only"] = 1;
// Set the server id // Set the server id
$graph_params["server"] = $module['serverID']; $graph_params["server"] = $module['serverID'];
} }

View File

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

View File

@ -1162,9 +1162,11 @@ function agents_get_modules ($id_agent = null, $details = false,
//$where .= " AND id_policy_module = 0 "; //$where .= " AND id_policy_module = 0 ";
$where_tags = tags_get_acl_tags($config['id_user'], $id_groups, 'AR', 'module_condition', 'AND', 'tagente_modulo'); $where_tags = tags_get_acl_tags($config['id_user'], $id_groups, 'AR',
'module_condition', 'AND', 'tagente_modulo', false, array(),
true);
$where .= $where_tags; $where .= "\n\n" . $where_tags;
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
@ -1190,6 +1192,7 @@ function agents_get_modules ($id_agent = null, $details = false,
break; break;
} }
$result = db_get_all_rows_sql ($sql); $result = db_get_all_rows_sql ($sql);
if (empty ($result)) { if (empty ($result)) {

View File

@ -1914,13 +1914,17 @@ function events_page_details ($event, $server = "") {
global $config; global $config;
// If server is provided, get the hash parameters // If server is provided, get the hash parameters
if (!empty($server)) { if (!empty($server) && defined("METACONSOLE")) {
$hashdata = metaconsole_get_server_hashdata($server); $hashdata = metaconsole_get_server_hashdata($server);
$hashstring = "&amp;" . $hashstring = "&amp;" .
"loginhash=auto&" . "loginhash=auto&" .
"loginhash_data=" . $hashdata . "&" . "loginhash_data=" . $hashdata . "&" .
"loginhash_user=" . str_rot13($config["id_user"]); "loginhash_user=" . str_rot13($config["id_user"]);
$serverstring = $server['server_url'] . "/"; $serverstring = $server['server_url'] . "/";
if (metaconsole_connect($server) !== NOERR) {
return ui_print_error_message(__('There was an error connecting to the node'), '', true);
}
} }
else { else {
$hashstring = ""; $hashstring = "";
@ -1951,14 +1955,7 @@ function events_page_details ($event, $server = "") {
} }
if ($event["id_agente"] != 0) { if ($event["id_agente"] != 0) {
if (!empty($server)) { $agent = db_get_row('tagente','id_agente',$event["id_agente"]);
$agent = agents_meta_get_agent(array('id_agent' => $event["id_agente"],
'id_server' => $server['id'],
'server_name' => $server['server_name']));
}
else {
$agent = db_get_row('tagente','id_agente',$event["id_agente"]);
}
} }
else { else {
$agent = array(); $agent = array();
@ -2007,12 +2004,7 @@ function events_page_details ($event, $server = "") {
} }
if ($event["id_agentmodule"] != 0) { if ($event["id_agentmodule"] != 0) {
if (!empty($server)) { $module = db_get_row_filter('tagente_modulo',array('id_agente_modulo' => $event["id_agentmodule"], 'delete_pending' => 0));
$module = meta_modules_get_agentmodule ($event["id_agentmodule"], $server['id']);
}
else {
$module = db_get_row_filter('tagente_modulo',array('id_agente_modulo' => $event["id_agentmodule"], 'delete_pending' => 0));
}
} }
else { else {
$module = array(); $module = array();
@ -2081,6 +2073,7 @@ function events_page_details ($event, $server = "") {
); );
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
$graph_params["avg_only"] = 1;
// Set the server id // Set the server id
$graph_params["server"] = $server["id"]; $graph_params["server"] = $server["id"];
} }
@ -2204,6 +2197,9 @@ function events_page_details ($event, $server = "") {
$details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>'; $details = '<div id="extended_event_details_page" class="extended_event_pages">'.html_print_table($table_details, true).'</div>';
if (!empty($server) && defined("METACONSOLE"))
metaconsole_restore_db();
return $details; return $details;
} }

View File

@ -376,7 +376,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
// Get agent modules data // Get agent modules data
if ($strict_user) { if ($strict_user) {
$modules = tags_get_agent_modules ($agent['id_agente'], $acltags, false, $filter, false); $modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false);
} else { } else {
$modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true); $modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true);
} }
@ -792,7 +792,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0,
// Get agent modules data // Get agent modules data
if ($strict_user) { if ($strict_user) {
$filter['disabled'] = 0; $filter['disabled'] = 0;
$modules = tags_get_agent_modules ($agent['id_agente'], $acltags, false, $filter, false); $modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false);
} else { } else {
$modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false); $modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false);
} }

View File

@ -7862,14 +7862,14 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
$id_agent = $counts_info['id_agente']; $id_agent = $counts_info['id_agente'];
$counts_info = array(); $counts_info = array();
$counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NORMAL)); $counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NORMAL));
$counts_info['warning_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING)); $counts_info['warning_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING));
$counts_info['critical_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_CRITICAL_BAD)); $counts_info['critical_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_CRITICAL_BAD));
$counts_info['notinit_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT)); $counts_info['notinit_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT));
$counts_info['unknown_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN)); $counts_info['unknown_count'] = count(tags_get_agent_modules ($id_agent, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN));
$counts_info['total_count'] = $counts_info['normal_count'] + $counts_info['warning_count'] + $counts_info['critical_count'] + $counts_info['unknown_count'] + $counts_info['notinit_count']; $counts_info['total_count'] = $counts_info['normal_count'] + $counts_info['warning_count'] + $counts_info['critical_count'] + $counts_info['unknown_count'] + $counts_info['notinit_count'];
$all_agent_modules = tags_get_agent_modules ($id_agent, $acltags, false, $filter); $all_agent_modules = tags_get_agent_modules ($id_agent, false, $acltags, false, $filter);
if (!empty($all_agent_modules)) { if (!empty($all_agent_modules)) {
$mod_clause = "(".implode(',', array_keys($all_agent_modules)).")"; $mod_clause = "(".implode(',', array_keys($all_agent_modules)).")";
@ -8405,6 +8405,8 @@ function reporting_get_event_histogram ($events) {
global $config; global $config;
include_once ('../../include/graphs/functions_gd.php'); include_once ('../../include/graphs/functions_gd.php');
$max_value = count($events); $max_value = count($events);
if (defined("METACONSOLE"))
$max_value = SECONDS_1HOUR;
$ttl = 1; $ttl = 1;
$urlImage = ui_get_full_url(false, true, false, false); $urlImage = ui_get_full_url(false, true, false, false);
@ -8418,6 +8420,10 @@ function reporting_get_event_histogram ($events) {
EVENT_CRIT_MAJOR => COL_MAJOR, EVENT_CRIT_MAJOR => COL_MAJOR,
EVENT_CRIT_CRITICAL => COL_CRITICAL EVENT_CRIT_CRITICAL => COL_CRITICAL
); );
if(defined("METACONSOLE")){
$full_legend = array();
$cont = 0;
}
foreach ($events as $data) { foreach ($events as $data) {
@ -8450,10 +8456,21 @@ function reporting_get_event_histogram ($events) {
$color = EVENT_CRIT_WARNING_OR_CRITICAL; $color = EVENT_CRIT_WARNING_OR_CRITICAL;
break; break;
} }
$graph_data[] = array(
'data' => $color, if(defined("METACONSOLE")){
'utimestamp' => 1 $full_legend[$cont] = $data['timestamp'];
); $graph_data[] = array(
'data' => $color,
'utimestamp' => $data['utimestamp'] - get_system_time ()
);
$cont++;
}
else{
$graph_data[] = array(
'data' => $color,
'utimestamp' => 1
);
}
} }
$table->width = '100%'; $table->width = '100%';
@ -8464,7 +8481,11 @@ function reporting_get_event_histogram ($events) {
$table->data[0][0] = "" ; $table->data[0][0] = "" ;
if (!empty($graph_data)) { if (!empty($graph_data)) {
$slicebar = slicesbar_graph($graph_data, $max_value, 700, 25, $colors, $config['fontpath'], $config['round_corner'], $urlImage, $ttl); if (defined("METACONSOLE"))
$slicebar = flot_slicesbar_graph($graph_data, $max_value, "100%", 35, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $urlImage);
else
$slicebar = slicesbar_graph($graph_data, $max_value, 700, 25, $colors, $config['fontpath'], $config['round_corner'], $urlImage, $ttl);
$table->data[0][0] = $slicebar; $table->data[0][0] = $slicebar;
} else { } else {
$table->data[0][0] = __('No events'); $table->data[0][0] = __('No events');

View File

@ -596,7 +596,10 @@ function tags_get_tags_formatted ($tags_array, $get_url = true) {
* @return mixed/string Tag ids * @return mixed/string Tag ids
*/ */
function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = 'module_condition', $query_prefix = '', $query_table = '', $meta = false, $childrens_ids = array(), $force_group_and_tag = false) { function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
$return_mode = 'module_condition', $query_prefix = '',
$query_table = '', $meta = false, $childrens_ids = array(),
$force_group_and_tag = false) {
global $config; global $config;
@ -635,6 +638,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
$acltags = tags_get_user_module_and_tags($id_user, $access); $acltags = tags_get_user_module_and_tags($id_user, $access);
// Delete the groups without tag restrictions from the acl tags array if $force_group_and_tag == false // Delete the groups without tag restrictions from the acl tags array if $force_group_and_tag == false
// Delete the groups that aren't in the received groups id // Delete the groups that aren't in the received groups id
$acltags_aux = array(); $acltags_aux = array();
@ -660,7 +664,9 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
break; break;
case 'module_condition': case 'module_condition':
// Return the condition of the tags for tagente_modulo table // Return the condition of the tags for tagente_modulo table
$condition = tags_get_acl_tags_module_condition($acltags, $query_table, true);
$condition = tags_get_acl_tags_module_condition($acltags,
$query_table);
if (!empty($condition)) { if (!empty($condition)) {
return " $query_prefix " . $condition; return " $query_prefix " . $condition;
} }
@ -701,7 +707,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
// Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression) // Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression)
if ($i == 0) if ($i == 0)
$condition .= ' ( '; $condition .= ' ( ' . "\n";
// Group condition (The module belongs to an agent of the group X) // Group condition (The module belongs to an agent of the group X)
// Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition // Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition
@ -727,7 +733,12 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
// Tags condition (The module has at least one of the restricted tags) // Tags condition (The module has at least one of the restricted tags)
$tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query); $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query);
$condition .= "($group_condition AND \n$tags_condition)\n"; $condition .=
" ( \n" .
" $group_condition \n" .
" AND \n" .
" $tags_condition \n" .
" )\n";
} }
$i++; $i++;
@ -1030,8 +1041,14 @@ function tags_check_acl($id_user, $id_group, $access, $tags = array(), $flag_id_
} }
// If there are not tags restrictions or tags passed, check the group access // If there are not tags restrictions or tags passed, check the group access
if ((empty($acls) || empty($tags)) && check_acl($id_user, $id_group, $access)) { if (empty($acls) || empty($tags)) {
return true; if (!is_array($id_group))
$group_id_array = array($id_group);
foreach ($id_group as $group) {
if (check_acl($id_user, $group, $access))
return true;
}
} }
# Fix: If user profile has more than one group, due to ACL propagation then id_group can be an array # Fix: If user profile has more than one group, due to ACL propagation then id_group can be an array
@ -1128,8 +1145,14 @@ function tags_check_acl_event($id_user, $id_group, $access, $tags = array(),$p =
} }
// If there are not tags restrictions or tags passed, check the group access // If there are not tags restrictions or tags passed, check the group access
if ((empty($acls) || empty($tags)) && check_acl($id_user, $id_group, $access)) { if (empty($acls) || empty($tags)) {
return true; if (!is_array($id_group))
$group_id_array = array($id_group);
foreach ($id_group as $group) {
if (check_acl($id_user, $group, $access))
return true;
}
} }
# Fix: If user profile has more than one group, due to ACL propagation then id_group can be an array # Fix: If user profile has more than one group, due to ACL propagation then id_group can be an array
@ -2215,10 +2238,11 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
if (!empty($all_groups)) if (!empty($all_groups))
$all_group_ids = array_keys($all_groups); $all_group_ids = array_keys($all_groups);
$tags_and_groups_aux = array(); $tags_and_groups_aux = array();
foreach ($tags_and_groups as $data) { foreach ($tags_and_groups as $data) {
// All group // All group
if ($data['id_grupo'] == 0) { if ((int)$data['id_grupo'] === 0) {
// All group with empty tags. All groups without tags permission! // All group with empty tags. All groups without tags permission!
if (empty($data['tags'])) { if (empty($data['tags'])) {
foreach ($all_group_ids as $group_id) { foreach ($all_group_ids as $group_id) {
@ -2245,10 +2269,12 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
$tags_and_groups = $tags_and_groups_aux; $tags_and_groups = $tags_and_groups_aux;
unset($tags_and_groups_aux); unset($tags_and_groups_aux);
foreach ($tags_and_groups as $group_tag) { foreach ($tags_and_groups as $group_tag) {
__add_acltags($acltags, $group_tag['id_grupo'], $group_tag['tags']); __add_acltags($acltags, $group_tag['id_grupo'], $group_tag['tags']);
} }
return $acltags; return $acltags;
} }
@ -2286,7 +2312,7 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an
$groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo"); $groups_clause = " AND ".tags_get_acl_tags_module_condition($groups_and_tags, "tagente_modulo");
} }
} else { } else {
$groups_clause = " AND tagente.id_grupo IN (".implode(',',$groups_and_tags).")"; $groups_clause = " AND tagente.id_grupo IN (".implode(',', array_keys($groups_and_tags)).")";
} }
if (!empty($filter['id_group'])) { if (!empty($filter['id_group'])) {
@ -2407,7 +2433,7 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an
return $user_agents; return $user_agents;
} }
function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields = false, $filter = false, $return_all_fields = false, $get_filter_status = -1) { function tags_get_agent_modules ($id_agent, $id_tag = false, $groups_and_tags = array(), $fields = false, $filter = false, $return_all_fields = false, $get_filter_status = -1) {
global $config; global $config;
@ -2415,6 +2441,12 @@ function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields
if (empty($id_agent)) if (empty($id_agent))
return false; return false;
if (empty($id_tag)) {
$tag_filter = "";
} else {
$tag_filter = " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag) ";
}
if (!is_array ($fields)) { if (!is_array ($fields)) {
$fields = array (); $fields = array ();
$fields[0] = "tagente_modulo.id_agente_modulo"; $fields[0] = "tagente_modulo.id_agente_modulo";
@ -2433,12 +2465,11 @@ function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields
} }
$tag_filter = "";
if (!empty($groups_and_tags)) { if (!empty($groups_and_tags)) {
$agent_group = db_get_value('id_grupo', 'tagente', 'id_agente', $id_agent); $agent_group = db_get_value('id_grupo', 'tagente', 'id_agente', $id_agent);
if (isset($groups_and_tags[$agent_group]) && ($groups_and_tags[$agent_group] != '')) { if (isset($groups_and_tags[$agent_group]) && ($groups_and_tags[$agent_group] != '')) {
//~ $tag_filter = " AND ttag_module.id_tag IN (".$groups_and_tags[$agent_group].")"; //~ $tag_filter = " AND ttag_module.id_tag IN (".$groups_and_tags[$agent_group].")";
$tag_filter = " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (".$groups_and_tags[$agent_group]."))"; $tag_filter .= " AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (".$groups_and_tags[$agent_group]."))";
} }
} }

View File

@ -314,6 +314,8 @@ function treeview_printTable($id_agente, $server_data = array()) {
enterprise_include_once ('meta/include/functions_ui_meta.php'); enterprise_include_once ('meta/include/functions_ui_meta.php');
include_graphs_dependencies(); include_graphs_dependencies();
$strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente)); $is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
if ($is_extra === ENTERPRISE_NOT_HOOK) { if ($is_extra === ENTERPRISE_NOT_HOOK) {
@ -546,31 +548,40 @@ function treeview_printTable($id_agente, $server_data = array()) {
foreach ($network_interfaces as $interface_name => $interface) { foreach ($network_interfaces as $interface_name => $interface) {
if (!empty($interface['traffic'])) { if (!empty($interface['traffic'])) {
$params = array( $permission = false;
'interface_name' => $interface_name,
'agent_id' => $id_agente,
'traffic_module_in' => $interface['traffic']['in'],
'traffic_module_out' => $interface['traffic']['out']
);
$params_json = json_encode($params);
$params_encoded = base64_encode($params_json);
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name));
$graph_url = ''; if ($strict_user) {
if (!defined('METACONSOLE')) { if (tags_check_acl_by_module($interface['traffic']['in'], $config['id_user'], 'RR') === true
$graph_url = $config['homeurl'] . && tags_check_acl_by_module($interface['traffic']['out'], $config['id_user'], 'RR') === true)
"operation/agentes/interface_traffic_graph_win.php?" . $permission = true;
"params=$params_encoded";
} }
else if (!empty($server_data)) { else {
$graph_url = ui_meta_get_url_console_child( $permission = check_acl($config['id_user'], $agent["id_grupo"], "RR");
$server_data, null, null, null, null,
"operation/agentes/interface_traffic_graph_win.php?" .
"params=$params_encoded");
} }
$graph_link = "<a href=\"javascript:winopeng('$graph_url','$win_handle')\">" . if ($permission) {
html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>"; $params = array(
'interface_name' => $interface_name,
'agent_id' => $id_agente,
'traffic_module_in' => $interface['traffic']['in'],
'traffic_module_out' => $interface['traffic']['out']
);
if (defined('METACONSOLE') && !empty($server_id))
$params["server"] = $server_id;
$params_json = json_encode($params);
$params_encoded = base64_encode($params_json);
$url = ui_get_full_url("operation/agentes/interface_traffic_graph_win.php", false, false, false);
$graph_url = "$url?params=$params_encoded";
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name));
$graph_link = "<a href=\"javascript:winopeng('$graph_url','$win_handle')\">" .
html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>";
}
else {
$graph_link = "";
}
} }
else { else {
$graph_link = ""; $graph_link = "";

View File

@ -22,7 +22,7 @@ TreeController = {
index: -1, index: -1,
recipient: '', recipient: '',
tree: [], tree: [],
emptyMessage: "Empty", emptyMessage: "No data found.",
errorMessage: "Error", errorMessage: "Error",
baseURL: "", baseURL: "",
ajaxURL: "ajax.php", ajaxURL: "ajax.php",
@ -709,7 +709,7 @@ TreeNodeDetailController = {
type: 'none', type: 'none',
id: -1, id: -1,
serverID: -1, serverID: -1,
emptyMessage: "Empty", emptyMessage: "No data found.",
errorMessage: "Error", errorMessage: "Error",
baseURL: "", baseURL: "",
ajaxURL: "ajax.php", ajaxURL: "ajax.php",

View File

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

View File

@ -29,6 +29,7 @@ include_once($config['homedir'] . "/include/functions_clippy.php");
check_login (); check_login ();
$strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
$id_agente = get_parameter_get ("id_agente", -1); $id_agente = get_parameter_get ("id_agente", -1);
@ -415,17 +416,33 @@ if (!empty($network_interfaces)) {
foreach ($network_interfaces as $interface_name => $interface) { foreach ($network_interfaces as $interface_name => $interface) {
if (!empty($interface['traffic'])) { if (!empty($interface['traffic'])) {
$params = array( $permission = false;
'interface_name' => $interface_name,
'agent_id' => $id_agente, if ($strict_user) {
'traffic_module_in' => $interface['traffic']['in'], if (tags_check_acl_by_module($interface['traffic']['in'], $config['id_user'], 'RR') === true
'traffic_module_out' => $interface['traffic']['out'] && tags_check_acl_by_module($interface['traffic']['out'], $config['id_user'], 'RR') === true)
); $permission = true;
$params_json = json_encode($params); }
$params_encoded = base64_encode($params_json); else {
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name)); $permission = check_acl($config['id_user'], $agent["id_grupo"], "RR");
$graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=$params_encoded','$win_handle')\">" . }
html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>";
if ($permission) {
$params = array(
'interface_name' => $interface_name,
'agent_id' => $id_agente,
'traffic_module_in' => $interface['traffic']['in'],
'traffic_module_out' => $interface['traffic']['out']
);
$params_json = json_encode($params);
$params_encoded = base64_encode($params_json);
$win_handle = dechex(crc32($interface['status_module_id'].$interface_name));
$graph_link = "<a href=\"javascript:winopeng('operation/agentes/interface_traffic_graph_win.php?params=$params_encoded','$win_handle')\">" .
html_print_image("images/chart_curve.png", true, array("title" => __('Interface traffic'))) . "</a>";
}
else {
$graph_link = "";
}
} }
else { else {
$graph_link = ""; $graph_link = "";

View File

@ -21,31 +21,37 @@ if (! isset($_SESSION['id_usuario'])) {
// Global & session management // Global & session management
require_once ('../../include/config.php'); require_once ('../../include/config.php');
require_once ('../../include/auth/mysql.php'); require_once ($config['homedir'] . '/include/auth/mysql.php');
require_once ($config['homedir'] . '/include/functions.php'); require_once ($config['homedir'] . '/include/functions.php');
require_once ($config['homedir'] . '/include/functions_db.php'); require_once ($config['homedir'] . '/include/functions_db.php');
require_once ($config['homedir'] . '/include/functions_reporting.php'); require_once ($config['homedir'] . '/include/functions_reporting.php');
require_once ($config['homedir'] . '/include/functions_graph.php'); require_once ($config['homedir'] . '/include/functions_graph.php');
require_once ($config['homedir'] . '/include/functions_custom_graphs.php'); require_once ($config['homedir'] . '/include/functions_custom_graphs.php');
require_once ($config['homedir'] . '/include/functions_modules.php'); require_once ($config['homedir'] . '/include/functions_modules.php');
require_once ($config['homedir'] . '/include/functions_agents.php');
// Hash login process require_once ($config['homedir'] . '/include/functions_tags.php');
if (! isset ($config['id_user']) && get_parameter("loginhash", 0)) {
$loginhash_data = get_parameter("loginhash_data", "");
$loginhash_user = str_rot13(get_parameter("loginhash_user", ""));
if ($config["loginhash_pwd"] != "" && $loginhash_data == md5($loginhash_user.io_output_password($config["loginhash_pwd"]))) {
db_logon ($loginhash_user, $_SERVER['REMOTE_ADDR']);
$_SESSION['id_usuario'] = $loginhash_user;
$config["id_user"] = $loginhash_user;
$hash_connection_data = true;
}
}
check_login(); check_login();
$params_json = base64_decode((string) get_parameter('params'));
$params = json_decode($params_json, true);
// Metaconsole connection to the node
$server_id = (int) (isset($params['server']) ? $params['server'] : 0);
if ($config["metaconsole"] && !empty($server_id)) {
$server = metaconsole_get_connection_by_id($server_id);
// Error connecting
if (metaconsole_connect($server) !== NOERR) {
echo "<html>";
echo "<body>";
ui_print_error_message(__('There was a problem connecting with the node'));
echo "</body>";
echo "</html>";
exit;
}
}
$user_language = get_user_language($config['id_user']); $user_language = get_user_language($config['id_user']);
if (file_exists ('../../include/languages/'.$user_language.'.mo')) { if (file_exists ('../../include/languages/'.$user_language.'.mo')) {
$l10n = new gettext_reader (new CachedFileReader ('../../include/languages/'.$user_language.'.mo')); $l10n = new gettext_reader (new CachedFileReader ('../../include/languages/'.$user_language.'.mo'));
@ -54,9 +60,6 @@ if (file_exists ('../../include/languages/'.$user_language.'.mo')) {
echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css"/>'; echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/css"/>';
$params_json = base64_decode((string) get_parameter('params'));
$params = json_decode($params_json, true);
$interface_name = (string) $params['interface_name']; $interface_name = (string) $params['interface_name'];
$agent_id = (int) $params['agent_id']; $agent_id = (int) $params['agent_id'];
$interface_traffic_modules = array( $interface_traffic_modules = array(
@ -106,6 +109,34 @@ $interface_traffic_modules = array(
<body bgcolor="#ffffff" style='background:#ffffff;'> <body bgcolor="#ffffff" style='background:#ffffff;'>
<?php <?php
// ACL
$permission = false;
$agent_group = (int) agents_get_agent_group($agent_id);
$strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
// The traffic modules should belong to the agent id
$in_agent_id = (int) db_get_value("id_agente", "tagente_modulo", "id_agente_modulo", $params['traffic_module_in']);
$out_agent_id = (int) db_get_value("id_agente", "tagente_modulo", "id_agente_modulo", $params['traffic_module_out']);
$traffic_modules_belong_to_agent = $agent_id == $in_agent_id && $agent_id == $out_agent_id;
if (!empty($agent_group) && !empty($params['traffic_module_in'])
&& !empty($params['traffic_module_out']) && $traffic_modules_belong_to_agent) {
if ($strict_user) {
if (tags_check_acl_by_module($params['traffic_module_in'], $config['id_user'], 'RR') === true
&& tags_check_acl_by_module($params['traffic_module_out'], $config['id_user'], 'RR') === true)
$permission = true;
}
else {
$permission = check_acl($config['id_user'], $agent_group, "RR");
}
}
if (!$permission) {
require ($config['homedir'] . "/general/noaccess.php");
exit;
}
// Get input parameters // Get input parameters
$period = (int) get_parameter('period', SECONDS_1HOUR); $period = (int) get_parameter('period', SECONDS_1HOUR);
$width = (int) get_parameter("width", 555); $width = (int) get_parameter("width", 555);
@ -165,16 +196,6 @@ $interface_traffic_modules = array(
$side_layer_params['body_text'] .= '<form method="get" action="interface_traffic_graph_win.php">'; $side_layer_params['body_text'] .= '<form method="get" action="interface_traffic_graph_win.php">';
$side_layer_params['body_text'] .= html_print_input_hidden("params", base64_encode($params_json), true); $side_layer_params['body_text'] .= html_print_input_hidden("params", base64_encode($params_json), true);
if (isset($hash_connection_data)) {
$side_layer_params['body_text'] .=
html_print_input_hidden("loginhash", "auto", true);
$side_layer_params['body_text'] .=
html_print_input_hidden("loginhash_data", $loginhash_data, true);
$side_layer_params['body_text'] .=
html_print_input_hidden("loginhash_user",
str_rot13($loginhash_user), true);
}
// FORM TABLE // FORM TABLE
$table = html_get_predefined_table('transparent', 2); $table = html_get_predefined_table('transparent', 2);

View File

@ -1229,6 +1229,7 @@ foreach ($result as $row) {
); );
if (defined('METACONSOLE') && isset($row["server_id"])) { if (defined('METACONSOLE') && isset($row["server_id"])) {
$graph_params["avg_only"] = 1;
// Set the server id // Set the server id
$graph_params["server"] = $row["server_id"]; $graph_params["server"] = $row["server_id"];
} }

View File

@ -86,7 +86,7 @@ if (is_ajax()) {
'id_filter', 'tevent_filter', $values); 'id_filter', 'tevent_filter', $values);
if ($exists) { if ($exists) {
echo 'error'; echo 'duplicate';
} }
else { else {
$result = db_process_sql_insert('tevent_filter', $values); $result = db_process_sql_insert('tevent_filter', $values);
@ -664,8 +664,25 @@ else
ui_toggle($events_filter, __('Event control filter'), '', !$open_filter); ui_toggle($events_filter, __('Event control filter'), '', !$open_filter);
// Error div for ajax messages // Error div for ajax messages
echo "<div id='show_filter_error'>"; echo "<div id='show_filter_error' style='display: none;'>";
ui_print_error_message(__('Error creating filter.'), 'data-type_info_box="error_create_filter"');
ui_print_error_message(__('Error creating filter is duplicated.'), 'data-type_info_box="duplicate_create_filter"');
ui_print_success_message(__('Filter created.'), 'data-type_info_box="success_create_filter"');
ui_print_success_message(__('Filter updated.'), 'data-type_info_box="success_update_filter"');
ui_print_error_message(__('Error updating filter.'), 'data-type_info_box="error_create_filter"');
echo "</div>"; echo "</div>";
?>
<script type="text/javascript">
$(document).ready(
function() {
$(".info_box").hide();
$("#show_filter_error").show();
}
);
</script>
<?php
$event_table = events_get_events_table($meta, $history); $event_table = events_get_events_table($meta, $history);
@ -918,31 +935,55 @@ $(document).ready( function() {
var id_filter_save; var id_filter_save;
jQuery.post ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>", jQuery.post ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
{"page" : "operation/events/events_list", {
"save_event_filter" : 1, "page" : "operation/events/events_list",
"id_name" : $("#text-id_name").val(), "save_event_filter" : 1,
"id_group" : $("#id_group").val(), "id_name" : $("#text-id_name").val(),
"event_type" : $("#event_type").val(), "id_group" : $("#id_group").val(),
"severity" : $("#severity").val(), "event_type" : $("#event_type").val(),
"status" : $("#status").val(), "severity" : $("#severity").val(),
"search" : $("#text-search").val(), "status" : $("#status").val(),
"text_agent" : $("#text_id_agent").val(), "search" : $("#text-search").val(),
"pagination" : $("#pagination").val(), "text_agent" : $("#text_id_agent").val(),
"event_view_hr" : $("#text-event_view_hr").val(), "pagination" : $("#pagination").val(),
"id_user_ack" : $("#id_user_ack").val(), "event_view_hr" : $("#text-event_view_hr").val(),
"group_rep" : $("#group_rep").val(), "id_user_ack" : $("#id_user_ack").val(),
"tag_with": Base64.decode($("#hidden-tag_with").val()), "group_rep" : $("#group_rep").val(),
"tag_without": Base64.decode($("#hidden-tag_without").val()), "tag_with": Base64.decode($("#hidden-tag_with").val()),
"filter_only_alert" : $("#filter_only_alert").val(), "tag_without": Base64.decode($("#hidden-tag_without").val()),
"id_group_filter": $("#id_group").val() "filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group").val()
}, },
function (data) { function (data) {
$(".info_box").hide();
if (data == 'error') { if (data == 'error') {
$('#show_filter_error').html('<h3 class="error"> <?php echo __('Error creating filter'); ?> </h3>'); $(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "error_create_filter") {
return true;
}
else
return false;
}).show();
}
else if (data == 'duplicate') {
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "duplicate_create_filter") {
return true;
}
else
return false;
}).show();
} }
else { else {
id_filter_save = data; id_filter_save = data;
$('#show_filter_error').html('<h3 class="suc"> <?php echo __('Filter created'); ?> </h3>');
$(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "success_create_filter") {
return true;
}
else
return false;
}).show();
} }
}); });
@ -1007,11 +1048,24 @@ $(document).ready( function() {
"id_group_filter": $("#id_group").val() "id_group_filter": $("#id_group").val()
}, },
function (data) { function (data) {
$(".info_box").hide();
if (data == 'ok') { if (data == 'ok') {
$('#show_filter_error').html('<h3 class="suc"> <?php echo __('Filter updated'); ?> </h3>'); $(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "success_update_filter") {
return true;
}
else
return false;
}).show();
} }
else { else {
$('#show_filter_error').html('<h3 class="error"> <?php echo __('Error updating filter'); ?> </h3>'); $(".info_box").filter(function(i, item) {
if ($(item).data('type_info_box') == "error_create_filter") {
return true;
}
else
return false;
}).show();
} }
}); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -73,10 +73,13 @@ our @EXPORT = qw(
get_profile_id get_profile_id
get_priority_name get_priority_name
get_server_id get_server_id
get_tag_id
get_group_name
get_template_id get_template_id
get_template_module_id get_template_module_id
get_user_disabled get_user_disabled
get_user_exists get_user_exists
get_user_profile_id
is_agent_address is_agent_address
is_group_disabled is_group_disabled
get_agent_status get_agent_status
@ -191,6 +194,18 @@ sub get_server_id ($$$) {
return defined ($rc) ? $rc : -1; return defined ($rc) ? $rc : -1;
} }
########################################################################
## Return the ID of a tag given the tag name.
########################################################################
sub get_tag_id ($$) {
my ($dbh, $tag_name) = @_;
my $rc = get_db_value ($dbh, "SELECT id_tag FROM ttag
WHERE name = ?",
safe_input($tag_name));
return defined ($rc) ? $rc : -1;
}
######################################################################## ########################################################################
## Return the first enabled server name found. ## Return the first enabled server name found.
######################################################################## ########################################################################
@ -549,6 +564,22 @@ sub get_nc_profile_name ($$) {
return get_db_value ($dbh, "SELECT * FROM tnetwork_profile WHERE id_np = ?", $nc_id); return get_db_value ($dbh, "SELECT * FROM tnetwork_profile WHERE id_np = ?", $nc_id);
} }
##########################################################################
## Return user profile ID given the user id, group id and profile id.
##########################################################################
sub get_user_profile_id ($$$$) {
my ($dbh, $user_id, $profile_id, $group_id) = @_;
my $rc = get_db_value ($dbh, "SELECT id_up FROM tusuario_perfil
WHERE id_usuario = ?
AND id_perfil = ?
AND id_grupo = ?",
safe_input($user_id),
$profile_id,
$group_id);
return defined ($rc) ? $rc : -1;
}
########################################################################## ##########################################################################
## Return profile ID given the profile name. ## Return profile ID given the profile name.
########################################################################## ##########################################################################

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@ use File::Basename;
use JSON qw(decode_json encode_json); use JSON qw(decode_json encode_json);
use MIME::Base64; use MIME::Base64;
use Encode qw(decode encode_utf8); use Encode qw(decode encode_utf8);
use LWP::Simple;
# Default lib dir for RPM and DEB packages # Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5'; use lib '/usr/lib/perl5';
@ -34,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "6.0dev PS150325"; my $version = "6.0dev PS150327";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -186,10 +187,50 @@ sub help_screen{
print "\nSETUP:\n\n" unless $param ne ''; print "\nSETUP:\n\n" unless $param ne '';
help_screen_line('--set_event_storm_protection', '<value>', "Enable (1) or disable (0) event \n\t storm protection"); help_screen_line('--set_event_storm_protection', '<value>', "Enable (1) or disable (0) event \n\t storm protection");
print "\nTAGS\n\n" unless $param ne '';
help_screen_line('--create_tag', '<tag_name> <tag_description> [<tag_url>] [<tag_email>]', 'Create a new tag');
help_screen_line('--add_tag_to_user_profile', '<user_id> <tag_name> <group_name> <profile_name>', 'Add a tag to the given user profile');
help_screen_line('--add_tag_to_module', '<agent_name> <module_name> <tag_name>', 'Add a tag to the given module');
print "\n"; print "\n";
exit; exit;
} }
###############################################################################
#
###############################################################################
sub api_call($$$;$$$) {
my ($pa_config, $op, $op2, $id, $id2, $other) = @_;
my $content = undef;
eval {
# Set the parameters for the POST request.
my $params = {};
$params->{"apipass"} = $pa_config->{"console_api_pass"};
$params->{"user"} = $pa_config->{"console_user"};
$params->{"pass"} = $pa_config->{"console_pass"};
$params->{"op"} = $op;
$params->{"op2"} = $op2;
$params->{"id"} = $id;
$params->{"id2"} = $id2;
$params->{"other"} = $other;
$params->{"other_mode"} = "url_encode_separator_|";
# Call the API.
my $ua = new LWP::UserAgent;
my $url = $pa_config->{"console_api_url"};
my $response = $ua->post($url, $params);
if ($response->is_success) {
$content = $response->decoded_content();
} else {
$content = $response->decoded_content();
}
};
return $content;
}
############################################################################### ###############################################################################
# Disable a entire group # Disable a entire group
############################################################################### ###############################################################################
@ -4083,6 +4124,18 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 1); param_check($ltotal, 1);
cli_recreate_collection(); cli_recreate_collection();
} }
elsif ($param eq '--create_tag') {
param_check($ltotal, 4, 2);
cli_create_tag();
}
elsif ($param eq '--add_tag_to_user_profile') {
param_check($ltotal, 4);
cli_add_tag_to_user_profile();
}
elsif ($param eq '--add_tag_to_module') {
param_check($ltotal, 3);
cli_add_tag_to_module();
}
else { else {
print_log "[ERROR] Invalid option '$param'.\n\n"; print_log "[ERROR] Invalid option '$param'.\n\n";
$param = ''; $param = '';
@ -4281,5 +4334,77 @@ sub cli_create_local_component() {
$parameters{'ff_timeout'} = $ff_timeout unless !defined ($ff_timeout); $parameters{'ff_timeout'} = $ff_timeout unless !defined ($ff_timeout);
my $component_id = enterprise_hook('pandora_create_local_component_from_hash',[$conf, \%parameters, $dbh]); my $component_id = enterprise_hook('pandora_create_local_component_from_hash',[$conf, \%parameters, $dbh]);
}
##############################################################################
# Create a new tag.
##############################################################################
sub cli_create_tag() {
my ($tag_name, $tag_description, $tag_url, $tag_email) = @ARGV[2..5];
# Call the API.
my $result = api_call(\%conf, 'set', 'create_tag', undef, undef, "$tag_name|$tag_description|$tag_url|$tag_email");
print "\n$result\n";
}
##############################################################################
# Add a tag to the specified profile and group.
##############################################################################
sub cli_add_tag_to_user_profile() {
my ($user_id, $tag_name, $group_name, $profile_name) = @ARGV[2..5];
# Check the user.
my $user_exists = get_user_exists($dbh, $user_id);
exist_check($user_exists, 'user', $user_id);
# Check the group.
my $group_id;
if ($group_name eq 'All') {
$group_id = 0;
} else {
$group_id = get_group_id($dbh, $group_name);
exist_check($group_id, 'group', $group_name);
}
# Check the profile.
my $profile_id = get_profile_id($dbh, $profile_name);
exist_check($profile_id, 'profile', $profile_name);
# Make sure the tag exists.
my $tag_id = get_tag_id($dbh, $tag_name);
exist_check($tag_id, 'tag', $tag_name);
# Make sure the profile is associated to the user.
my $user_profile_id = get_user_profile_id($dbh, $user_id, $profile_id, $group_id);
exist_check($user_profile_id, 'given profile and group combination for user', $user_id);
# Call the API.
my $result = api_call(\%conf, 'set', 'tag_user_profile', $user_id, $tag_id, "$group_id|$profile_id");
print "\n$result\n";
}
##############################################################################
# Add a tag to the specified profile and group.
##############################################################################
sub cli_add_tag_to_module() {
my ($agent_name, $module_name, $tag_name) = @ARGV[2..4];
# Check the tag.
my $tag_id = get_tag_id($dbh, $tag_name);
exist_check($tag_id, 'tag', $tag_name);
# Check the agent.
my $agent_id = get_agent_id($dbh, $agent_name);
exist_check($agent_id, 'agent', $agent_name);
# Check the module.
my $module_id = get_agent_module_id($dbh, $module_name, $agent_id);
exist_check($module_id, 'module name', $module_name);
# Call the API.
my $result = api_call(\%conf, 'set', 'add_tag_module', $module_id, $tag_id);
print "\n$result\n";
} }