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
Version: 6.0dev-150325
Version: 6.0dev-150327
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-150325"
pandora_version="6.0dev-150327"
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 => '150325';
use constant AGENT_BUILD => '150327';
# 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 150325
%define release 150327
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 150325
%define release 150327
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{150325}
{150327}
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 150325)")
#define PANDORA_VERSION ("6.0dev(Build 150327)")
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 150325))"
VALUE "ProductVersion", "(6.0dev(Build 150327))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 6.0dev-150325
Version: 6.0dev-150327
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-150325"
pandora_version="6.0dev-150327"
package_pear=0
package_pandora=1

View File

@ -62,4 +62,11 @@ UPDATE `talert_commands` SET `fields_descriptions` = '[\"Destination addres
-- ---------------------------------------------------------------------
-- 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

@ -62,4 +62,11 @@ UPDATE talert_commands SET fields_descriptions = '[\"Destination address\",
-- ---------------------------------------------------------------------
-- 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

@ -60,4 +60,11 @@ UPDATE "talert_commands" SET "fields_descriptions" = '[\"Destination addres
-- ---------------------------------------------------------------------
-- 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();
$fv = explode(';', $field_value);
if (!empty($fv)) {
foreach ($fv as $fv_option) {
$fv_option = explode(',', $fv_option);
if (empty($fv_option))
continue;
if (!isset($fv_option[1]))
$fv_option[1] = $fv_option[0];
$fields_value_select[$fv_option[0]] = $fv_option[1];
if (count($fv) > 1) {
if (!empty($fv)) {
foreach ($fv as $fv_option) {
$fv_option = explode(',', $fv_option);
if (empty($fv_option))
continue;
if (!isset($fv_option[1]))
$fv_option[1] = $fv_option[0];
$fields_value_select[$fv_option[0]] = $fv_option[1];
}
}
}
$ffield = html_print_select($fields_value_select,
'field'.$i.'_value', '', '', '', 0, true, false, false, 'fields');
$rfield = html_print_select($fields_value_select,
'field'.$i.'_recovery_value', '', '', '', 0, true, false, false, 'fields_recovery');
$ffield = html_print_select($fields_value_select,
'field'.$i.'_value', '', '', '', 0, true, false, false, 'fields');
$rfield = html_print_select($fields_value_select,
'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 {

View File

@ -284,7 +284,8 @@ $(document).ready (function () {
$table_macros_field.hide();
continue;
}
old_value = '';
old_recovery_value = '';
// Only keep the value if is provided from hidden (first time)
if (($("[name=field" + i + "_value]").attr('id'))
== ("hidden-field" + i + "_value")) {
@ -301,10 +302,14 @@ $(document).ready (function () {
// Replace the old column with the new
$table_macros_field.replaceWith(field_row);
$("[name=field" + i + "_value]").val(old_value);
$("[name=field" + i + "_recovery_value]").val(old_recovery_value);
if (old_value != '' && old_recovery_value != ''){
$("[name=field" + i + "_value]").val(old_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
if (i == 1) {
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')){
$table->width = '50%';
$table->width = '96%';
$form_filter = "<form class='filters_form' method='post'>";
$form_filter .= html_print_table($table, true);
$form_filter .= "</form>";
echo $form_filter;
ui_toggle($form_filter, __('Show Options'));
}else{
$form_filter = "<form method='post'>";
$form_filter .= html_print_table($table, true);

View File

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

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC150325';
$build_version = 'PC150327';
$pandora_version = 'v6.0dev';
// 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_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"]) {
case "mysql":
@ -1190,6 +1192,7 @@ function agents_get_modules ($id_agent = null, $details = false,
break;
}
$result = db_get_all_rows_sql ($sql);
if (empty ($result)) {

View File

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

View File

@ -376,7 +376,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
// Get agent modules data
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 {
$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
if ($strict_user) {
$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 {
$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'];
$counts_info = array();
$counts_info['normal_count'] = count(tags_get_agent_modules ($id_agent, $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['critical_count'] = count(tags_get_agent_modules ($id_agent, $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['unknown_count'] = count(tags_get_agent_modules ($id_agent, $acltags, false, $filter, false, AGENT_MODULE_STATUS_UNKNOWN));
$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, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_WARNING));
$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, false, $acltags, false, $filter, false, AGENT_MODULE_STATUS_NOT_INIT));
$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'];
$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)) {
$mod_clause = "(".implode(',', array_keys($all_agent_modules)).")";
@ -8405,7 +8405,9 @@ function reporting_get_event_histogram ($events) {
global $config;
include_once ('../../include/graphs/functions_gd.php');
$max_value = count($events);
if (defined("METACONSOLE"))
$max_value = SECONDS_1HOUR;
$ttl = 1;
$urlImage = ui_get_full_url(false, true, false, false);
@ -8418,7 +8420,11 @@ function reporting_get_event_histogram ($events) {
EVENT_CRIT_MAJOR => COL_MAJOR,
EVENT_CRIT_CRITICAL => COL_CRITICAL
);
if(defined("METACONSOLE")){
$full_legend = array();
$cont = 0;
}
foreach ($events as $data) {
switch ($data['criticity']) {
@ -8450,10 +8456,21 @@ function reporting_get_event_histogram ($events) {
$color = EVENT_CRIT_WARNING_OR_CRITICAL;
break;
}
$graph_data[] = array(
'data' => $color,
'utimestamp' => 1
);
if(defined("METACONSOLE")){
$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%';
@ -8464,7 +8481,11 @@ function reporting_get_event_histogram ($events) {
$table->data[0][0] = "" ;
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;
} else {
$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
*/
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;
@ -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);
// 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
$acltags_aux = array();
@ -660,7 +664,9 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
break;
case 'module_condition':
// 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)) {
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)
if ($i == 0)
$condition .= ' ( ';
$condition .= ' ( ' . "\n";
// 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
@ -713,7 +719,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
//Avoid the user profiles with all group access.
$group_condition = " 1 = 1 ";
}
//When the acl is only group without tags
if (empty($group_tags)) {
$condition .= "($group_condition)\n";
@ -727,9 +733,14 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
// 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);
$condition .= "($group_condition AND \n$tags_condition)\n";
$condition .=
" ( \n" .
" $group_condition \n" .
" AND \n" .
" $tags_condition \n" .
" )\n";
}
$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 ((empty($acls) || empty($tags)) && check_acl($id_user, $id_group, $access)) {
return true;
if (empty($acls) || empty($tags)) {
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
@ -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 ((empty($acls) || empty($tags)) && check_acl($id_user, $id_group, $access)) {
return true;
if (empty($acls) || empty($tags)) {
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
@ -2135,10 +2158,10 @@ function tags_get_monitors_alerts ($id_tag, $groups_and_tags = array(), $id_agen
AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag)
$agents_clause
$groups_clause";
$count = db_get_sql ($sql);
return $count;
return $count;
}
function __add_acltags (&$acltags, $group_id, $tags_str) {
@ -2203,7 +2226,7 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
tperfil.%s = 1
ORDER BY id_grupo", $id_user, $acl_column);
$tags_and_groups = db_get_all_rows_sql($sql);
if ($tags_and_groups === false)
$tags_and_groups = array();
@ -2214,11 +2237,12 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
$all_groups = groups_get_all();
if (!empty($all_groups))
$all_group_ids = array_keys($all_groups);
$tags_and_groups_aux = array();
foreach ($tags_and_groups as $data) {
// All group
if ($data['id_grupo'] == 0) {
if ((int)$data['id_grupo'] === 0) {
// All group with empty tags. All groups without tags permission!
if (empty($data['tags'])) {
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;
unset($tags_and_groups_aux);
foreach ($tags_and_groups as $group_tag) {
__add_acltags($acltags, $group_tag['id_grupo'], $group_tag['tags']);
}
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");
}
} 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'])) {
@ -2407,7 +2433,7 @@ function tags_get_all_user_agents ($id_tag = false, $id_user = false, $groups_an
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;
@ -2415,6 +2441,12 @@ function tags_get_agent_modules ($id_agent, $groups_and_tags = array(), $fields
if (empty($id_agent))
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)) {
$fields = array ();
$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)) {
$agent_group = db_get_value('id_grupo', 'tagente', 'id_agente', $id_agent);
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 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');
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));
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) {
if (!empty($interface['traffic'])) {
$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));
$permission = false;
$graph_url = '';
if (!defined('METACONSOLE')) {
$graph_url = $config['homeurl'] .
"operation/agentes/interface_traffic_graph_win.php?" .
"params=$params_encoded";
if ($strict_user) {
if (tags_check_acl_by_module($interface['traffic']['in'], $config['id_user'], 'RR') === true
&& tags_check_acl_by_module($interface['traffic']['out'], $config['id_user'], 'RR') === true)
$permission = true;
}
else if (!empty($server_data)) {
$graph_url = ui_meta_get_url_console_child(
$server_data, null, null, null, null,
"operation/agentes/interface_traffic_graph_win.php?" .
"params=$params_encoded");
else {
$permission = check_acl($config['id_user'], $agent["id_grupo"], "RR");
}
$graph_link = "<a href=\"javascript:winopeng('$graph_url','$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']
);
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 {
$graph_link = "";

View File

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

View File

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

View File

@ -29,6 +29,7 @@ include_once($config['homedir'] . "/include/functions_clippy.php");
check_login ();
$strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
$id_agente = get_parameter_get ("id_agente", -1);
@ -415,17 +416,33 @@ if (!empty($network_interfaces)) {
foreach ($network_interfaces as $interface_name => $interface) {
if (!empty($interface['traffic'])) {
$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>";
$permission = false;
if ($strict_user) {
if (tags_check_acl_by_module($interface['traffic']['in'], $config['id_user'], 'RR') === true
&& tags_check_acl_by_module($interface['traffic']['out'], $config['id_user'], 'RR') === true)
$permission = true;
}
else {
$permission = check_acl($config['id_user'], $agent["id_grupo"], "RR");
}
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 {
$graph_link = "";

View File

@ -21,31 +21,37 @@ if (! isset($_SESSION['id_usuario'])) {
// Global & session management
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_db.php');
require_once ($config['homedir'] . '/include/functions_reporting.php');
require_once ($config['homedir'] . '/include/functions_graph.php');
require_once ($config['homedir'] . '/include/functions_custom_graphs.php');
require_once ($config['homedir'] . '/include/functions_modules.php');
// Hash login process
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;
}
}
require_once ($config['homedir'] . '/include/functions_agents.php');
require_once ($config['homedir'] . '/include/functions_tags.php');
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']);
if (file_exists ('../../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"/>';
$params_json = base64_decode((string) get_parameter('params'));
$params = json_decode($params_json, true);
$interface_name = (string) $params['interface_name'];
$agent_id = (int) $params['agent_id'];
$interface_traffic_modules = array(
@ -106,6 +109,34 @@ $interface_traffic_modules = array(
<body bgcolor="#ffffff" style='background:#ffffff;'>
<?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
$period = (int) get_parameter('period', SECONDS_1HOUR);
$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'] .= 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
$table = html_get_predefined_table('transparent', 2);

View File

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

View File

@ -86,7 +86,7 @@ if (is_ajax()) {
'id_filter', 'tevent_filter', $values);
if ($exists) {
echo 'error';
echo 'duplicate';
}
else {
$result = db_process_sql_insert('tevent_filter', $values);
@ -664,8 +664,25 @@ else
ui_toggle($events_filter, __('Event control filter'), '', !$open_filter);
// 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>";
?>
<script type="text/javascript">
$(document).ready(
function() {
$(".info_box").hide();
$("#show_filter_error").show();
}
);
</script>
<?php
$event_table = events_get_events_table($meta, $history);
@ -918,31 +935,55 @@ $(document).ready( function() {
var id_filter_save;
jQuery.post ("<?php echo ui_get_full_url("ajax.php", false, false, false); ?>",
{"page" : "operation/events/events_list",
"save_event_filter" : 1,
"id_name" : $("#text-id_name").val(),
"id_group" : $("#id_group").val(),
"event_type" : $("#event_type").val(),
"severity" : $("#severity").val(),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"text_agent" : $("#text_id_agent").val(),
"pagination" : $("#pagination").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag_with": Base64.decode($("#hidden-tag_with").val()),
"tag_without": Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group").val()
{
"page" : "operation/events/events_list",
"save_event_filter" : 1,
"id_name" : $("#text-id_name").val(),
"id_group" : $("#id_group").val(),
"event_type" : $("#event_type").val(),
"severity" : $("#severity").val(),
"status" : $("#status").val(),
"search" : $("#text-search").val(),
"text_agent" : $("#text_id_agent").val(),
"pagination" : $("#pagination").val(),
"event_view_hr" : $("#text-event_view_hr").val(),
"id_user_ack" : $("#id_user_ack").val(),
"group_rep" : $("#group_rep").val(),
"tag_with": Base64.decode($("#hidden-tag_with").val()),
"tag_without": Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group").val()
},
function (data) {
$(".info_box").hide();
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 {
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();
}
});
@ -978,7 +1019,7 @@ $(document).ready( function() {
// Update the info with the loaded filter
$("#hidden-id_name").val($('#text-id_name').val());
$('#filter_loaded_span').html($('#filter_loaded_text').html() + ': ' + $('#text-id_name').val());
return false;
});
@ -1007,11 +1048,24 @@ $(document).ready( function() {
"id_group_filter": $("#id_group").val()
},
function (data) {
$(".info_box").hide();
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 {
$('#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 version 6.0dev
%define release 150325
%define release 150327
# 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 150325
%define release 150327
%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','PD150325'),
('db_scheme_build','PD150327'),
('show_unknown','0'),
('show_lastalerts','1'),
('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 6.0dev-150325
Version: 6.0dev-150327
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-150325"
pandora_version="6.0dev-150327"
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 = "150325";
my $pandora_build = "150327";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -73,10 +73,13 @@ our @EXPORT = qw(
get_profile_id
get_priority_name
get_server_id
get_tag_id
get_group_name
get_template_id
get_template_module_id
get_user_disabled
get_user_exists
get_user_profile_id
is_agent_address
is_group_disabled
get_agent_status
@ -191,6 +194,18 @@ sub get_server_id ($$$) {
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.
########################################################################
@ -549,6 +564,22 @@ sub get_nc_profile_name ($$) {
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.
##########################################################################

View File

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

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.0dev
%define release 150325
%define release 150327
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 PS150325";
my $version = "6.0dev PS150327";
# Pandora server configuration
my %conf;

View File

@ -20,6 +20,7 @@ use File::Basename;
use JSON qw(decode_json encode_json);
use MIME::Base64;
use Encode qw(decode encode_utf8);
use LWP::Simple;
# Default lib dir for RPM and DEB packages
use lib '/usr/lib/perl5';
@ -34,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "6.0dev PS150325";
my $version = "6.0dev PS150327";
# save program name for logging
my $progname = basename($0);
@ -186,10 +187,50 @@ sub help_screen{
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");
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";
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
###############################################################################
@ -4083,6 +4124,18 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 1);
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 {
print_log "[ERROR] Invalid option '$param'.\n\n";
$param = '';
@ -4281,5 +4334,77 @@ sub cli_create_local_component() {
$parameters{'ff_timeout'} = $ff_timeout unless !defined ($ff_timeout);
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";
}