Merge branch 'develop' into feature/NewView
This commit is contained in:
commit
a9bf3490fb
|
@ -1,5 +1,5 @@
|
||||||
package: pandorafms-agent-unix
|
package: pandorafms-agent-unix
|
||||||
Version: 6.0dev-150326
|
Version: 6.0dev-150329
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
|
|
@ -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-150326"
|
pandora_version="6.0dev-150329"
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -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 => '150326';
|
use constant AGENT_BUILD => '150329';
|
||||||
|
|
||||||
# Commands to retrieve total memory information in kB
|
# Commands to retrieve total memory information in kB
|
||||||
use constant TOTALMEMORY_CMDS => {
|
use constant TOTALMEMORY_CMDS => {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 6.0dev
|
%define version 6.0dev
|
||||||
%define release 150326
|
%define release 150329
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_agent_unix
|
%define name pandorafms_agent_unix
|
||||||
%define version 6.0dev
|
%define version 6.0dev
|
||||||
%define release 150326
|
%define release 150329
|
||||||
|
|
||||||
Summary: Pandora FMS Linux agent, PERL version
|
Summary: Pandora FMS Linux agent, PERL version
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
|
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Version
|
Version
|
||||||
{150326}
|
{150329}
|
||||||
|
|
||||||
ViewReadme
|
ViewReadme
|
||||||
{Yes}
|
{Yes}
|
||||||
|
|
|
@ -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 150326)")
|
#define PANDORA_VERSION ("6.0dev(Build 150329)")
|
||||||
|
|
||||||
string pandora_path;
|
string pandora_path;
|
||||||
string pandora_dir;
|
string pandora_dir;
|
||||||
|
|
|
@ -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 150326))"
|
VALUE "ProductVersion", "(6.0dev(Build 150329))"
|
||||||
VALUE "FileVersion", "1.0.0.0"
|
VALUE "FileVersion", "1.0.0.0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package: pandorafms-console
|
package: pandorafms-console
|
||||||
Version: 6.0dev-150326
|
Version: 6.0dev-150329
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
|
|
@ -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-150326"
|
pandora_version="6.0dev-150329"
|
||||||
|
|
||||||
package_pear=0
|
package_pear=0
|
||||||
package_pandora=1
|
package_pandora=1
|
||||||
|
|
|
@ -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))
|
|
||||||
continue;
|
if (empty($fv_option))
|
||||||
|
continue;
|
||||||
if (!isset($fv_option[1]))
|
|
||||||
$fv_option[1] = $fv_option[0];
|
if (!isset($fv_option[1]))
|
||||||
|
$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 {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -1038,6 +1038,14 @@ if ($list_modules) {
|
||||||
.click (function () {
|
.click (function () {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
$("a.relations_details").cluetip ({
|
||||||
|
arrows: true,
|
||||||
|
attribute: 'href',
|
||||||
|
cluetipClass: 'default'
|
||||||
|
})
|
||||||
|
.click (function () {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
function toggle_full_value(id) {
|
function toggle_full_value(id) {
|
||||||
text = $("#hidden_value_module_" + id).html();
|
text = $("#hidden_value_module_" + id).html();
|
||||||
|
|
|
@ -58,50 +58,17 @@ switch($action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($stats['agents'])) {
|
if (isset($stats['agents'])) {
|
||||||
if ($metaconsole) {
|
// TODO: GET STATUS OF THE AGENTS AND ADD IT TO SUMMARY
|
||||||
include_once ('include/functions_reporting.php');
|
$summary .= count($stats['agents']) .
|
||||||
|
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||||
$servers = db_get_all_rows_sql ("SELECT *
|
' ' . __('Agents') . "<br>";
|
||||||
FROM tmetaconsole_setup");
|
|
||||||
if ($servers === false)
|
|
||||||
$servers = array();
|
|
||||||
|
|
||||||
$total_agents = 0;
|
|
||||||
|
|
||||||
foreach ($servers as $server) {
|
|
||||||
// If connection was good then retrieve all data server
|
|
||||||
if (metaconsole_load_external_db ($server)) {
|
|
||||||
$connection = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$connection = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($connection)
|
|
||||||
$data = reporting_get_group_stats();
|
|
||||||
|
|
||||||
metaconsole_restore_db();
|
|
||||||
|
|
||||||
$total_agents += $data["total_agents"];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$total_agents = format_numeric($total_agents);
|
|
||||||
|
|
||||||
$summary .= $total_agents .
|
|
||||||
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
|
||||||
' ' . __('Agents') . "<br>";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$summary .= count($stats['agents']) .
|
|
||||||
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
|
||||||
' ' . __('Agents') . "<br>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($stats['modules'])) {
|
if (isset($stats['modules'])) {
|
||||||
// TODO: GET STATUS OF THE MODULES AND ADD IT TO SUMMARY
|
// TODO: GET STATUS OF THE MODULES AND ADD IT TO SUMMARY
|
||||||
$summary .= count($stats['modules'])." x ".html_print_image('images/brick.png',true).' '.__('Modules')."<br>";
|
$summary .= count($stats['modules']) .
|
||||||
|
" x " . html_print_image($hack_metaconsole . 'images/brick.png',true) .
|
||||||
|
' ' . __('Modules') . "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
||||||
|
@ -120,46 +87,9 @@ switch($action) {
|
||||||
$summary = '<br>';
|
$summary = '<br>';
|
||||||
|
|
||||||
if (isset($stats['agents'])) {
|
if (isset($stats['agents'])) {
|
||||||
if ($metaconsole) {
|
$summary .= count($stats['agents']) .
|
||||||
include_once ('include/functions_reporting.php');
|
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
||||||
|
' ' . __('Agents') . "<br>";
|
||||||
$servers = db_get_all_rows_sql ("SELECT *
|
|
||||||
FROM tmetaconsole_setup
|
|
||||||
WHERE id = " . $id_server);
|
|
||||||
if ($servers === false)
|
|
||||||
$servers = array();
|
|
||||||
|
|
||||||
$total_agents = 0;
|
|
||||||
|
|
||||||
foreach ($servers as $server) {
|
|
||||||
// If connection was good then retrieve all data server
|
|
||||||
if (metaconsole_load_external_db ($server)) {
|
|
||||||
$connection = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$connection = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($connection)
|
|
||||||
$data = reporting_get_group_stats();
|
|
||||||
|
|
||||||
metaconsole_restore_db();
|
|
||||||
|
|
||||||
$total_agents += $data["total_agents"];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$total_agents = format_numeric($total_agents);
|
|
||||||
|
|
||||||
$summary .= $total_agents .
|
|
||||||
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
|
||||||
' ' . __('Agents') . "<br>";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$summary .= count($stats['agents']) .
|
|
||||||
" x " . html_print_image($hack_metaconsole . 'images/bricks.png',true) .
|
|
||||||
' ' . __('Agents') . "<br>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
echo '<h3>'.__('Map summary').'</h3><strong>'.$summary.'</strong>';
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
/**
|
/**
|
||||||
* Pandora build version and version
|
* Pandora build version and version
|
||||||
*/
|
*/
|
||||||
$build_version = 'PC150326';
|
$build_version = 'PC150329';
|
||||||
$pandora_version = 'v6.0dev';
|
$pandora_version = 'v6.0dev';
|
||||||
|
|
||||||
// Do not overwrite default timezone set if defined.
|
// Do not overwrite default timezone set if defined.
|
||||||
|
|
|
@ -2318,4 +2318,26 @@ function set_pandora_error_for_header($message, $title = null) {
|
||||||
$_SESSION["alert_msg"] .= ui_print_error_message($message_config,
|
$_SESSION["alert_msg"] .= ui_print_error_message($message_config,
|
||||||
'', true);
|
'', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function set_if_defined (&$var, $test) {
|
||||||
|
if (isset($test)) {
|
||||||
|
$var = $test;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_unless_defined (&$var, $default) {
|
||||||
|
if (! isset($var)) {
|
||||||
|
$var = $default;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1161,9 +1161,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":
|
||||||
|
@ -1189,6 +1191,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)) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)).")";
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
@ -713,7 +719,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
||||||
//Avoid the user profiles with all group access.
|
//Avoid the user profiles with all group access.
|
||||||
$group_condition = " 1 = 1 ";
|
$group_condition = " 1 = 1 ";
|
||||||
}
|
}
|
||||||
|
|
||||||
//When the acl is only group without tags
|
//When the acl is only group without tags
|
||||||
if (empty($group_tags)) {
|
if (empty($group_tags)) {
|
||||||
$condition .= "($group_condition)\n";
|
$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 (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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2147,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)
|
AND tagente_modulo.id_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag = $id_tag)
|
||||||
$agents_clause
|
$agents_clause
|
||||||
$groups_clause";
|
$groups_clause";
|
||||||
|
|
||||||
$count = db_get_sql ($sql);
|
$count = db_get_sql ($sql);
|
||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function __add_acltags (&$acltags, $group_id, $tags_str) {
|
function __add_acltags (&$acltags, $group_id, $tags_str) {
|
||||||
|
@ -2215,7 +2226,7 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
|
||||||
tperfil.%s = 1
|
tperfil.%s = 1
|
||||||
ORDER BY id_grupo", $id_user, $acl_column);
|
ORDER BY id_grupo", $id_user, $acl_column);
|
||||||
$tags_and_groups = db_get_all_rows_sql($sql);
|
$tags_and_groups = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
if ($tags_and_groups === false)
|
if ($tags_and_groups === false)
|
||||||
$tags_and_groups = array();
|
$tags_and_groups = array();
|
||||||
|
|
||||||
|
@ -2226,11 +2237,12 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
|
||||||
$all_groups = groups_get_all();
|
$all_groups = groups_get_all();
|
||||||
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) {
|
||||||
|
@ -2257,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2298,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'])) {
|
||||||
|
@ -2419,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;
|
||||||
|
|
||||||
|
@ -2427,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";
|
||||||
|
@ -2445,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]."))";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -721,6 +721,8 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $
|
||||||
$fontsize = 7;
|
$fontsize = 7;
|
||||||
|
|
||||||
$extra_height = 15;
|
$extra_height = 15;
|
||||||
|
if (defined("METACONSOLE"))
|
||||||
|
$extra_height = 20;
|
||||||
|
|
||||||
$return .= "<div id='extra_$graph_id' style='font-size: ".$fontsize."pt; display:none; position:absolute; overflow: auto; height: ".$extra_height."px; background:#fff; padding: 2px 2px 2px 2px; border: solid #000 1px;'></div>";
|
$return .= "<div id='extra_$graph_id' style='font-size: ".$fontsize."pt; display:none; position:absolute; overflow: auto; height: ".$extra_height."px; background:#fff; padding: 2px 2px 2px 2px; border: solid #000 1px;'></div>";
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
<div style='height: 10px'>
|
<div style='height: 10px'>
|
||||||
<?php
|
<?php
|
||||||
$version = '6.0dev';
|
$version = '6.0dev';
|
||||||
$build = '150326';
|
$build = '150329';
|
||||||
$banner = "v$version Build $build";
|
$banner = "v$version Build $build";
|
||||||
|
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
|
|
@ -438,6 +438,7 @@ if (is_ajax ()) {
|
||||||
|
|
||||||
$server = null;
|
$server = null;
|
||||||
if ($metaconsole) {
|
if ($metaconsole) {
|
||||||
|
$strict_user = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||||
$server = db_get_row('tmetaconsole_setup', 'id', $id_server);
|
$server = db_get_row('tmetaconsole_setup', 'id', $id_server);
|
||||||
|
|
||||||
if (metaconsole_connect($server) != NOERR) {
|
if (metaconsole_connect($server) != NOERR) {
|
||||||
|
@ -527,7 +528,7 @@ if (is_ajax ()) {
|
||||||
$size_bad_modules = sizeof ($bad_modules);
|
$size_bad_modules = sizeof ($bad_modules);
|
||||||
|
|
||||||
// Modules down
|
// Modules down
|
||||||
if ($size_bad_modules > 0) {
|
if ($size_bad_modules > 0 && (!$metaconsole || !$strict_user)) {
|
||||||
echo '<strong>'.__('Monitors down').':</strong> '.$size_bad_modules.' / '.$total_modules;
|
echo '<strong>'.__('Monitors down').':</strong> '.$size_bad_modules.' / '.$total_modules;
|
||||||
echo '<ul>';
|
echo '<ul>';
|
||||||
foreach ($bad_modules as $module) {
|
foreach ($bad_modules as $module) {
|
||||||
|
@ -561,7 +562,7 @@ if (is_ajax ()) {
|
||||||
$alert_modules = db_get_sql ($sql);
|
$alert_modules = db_get_sql ($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($alert_modules > 0) {
|
if ($alert_modules > 0 && (!$metaconsole || !$strict_user)) {
|
||||||
$sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired
|
$sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired
|
||||||
FROM talert_template_modules, tagente_modulo, tagente
|
FROM talert_template_modules, tagente_modulo, tagente
|
||||||
WHERE tagente.id_agente = %d
|
WHERE tagente.id_agente = %d
|
||||||
|
|
|
@ -233,7 +233,10 @@ if (check_acl ($config["id_user"], 0, "EW") || check_acl ($config["id_user"], 0,
|
||||||
$table->rowid[1] = 'save_filter_row1';
|
$table->rowid[1] = 'save_filter_row1';
|
||||||
$data[0] = __('Filter name') . $jump;
|
$data[0] = __('Filter name') . $jump;
|
||||||
$data[0] .= html_print_input_text ('id_name', '', '', 15, 255, true);
|
$data[0] .= html_print_input_text ('id_name', '', '', 15, 255, true);
|
||||||
$data[1] = __('Filter group') . $jump;
|
if(defined('METACONSOLE'))
|
||||||
|
$data[1] = __('Group') . $jump;
|
||||||
|
else
|
||||||
|
$data[1] = __('Filter group') . $jump;
|
||||||
# Fix : Only admin users can see group ALL
|
# Fix : Only admin users can see group ALL
|
||||||
$data[1] .= html_print_select_groups($config['id_user'], "ER", users_can_manage_group_all(), "id_group", $id_group, '', '', 0, true, false, false, 'w130', false, '', false, false, 'id_grupo', $strict_user);
|
$data[1] .= html_print_select_groups($config['id_user'], "ER", users_can_manage_group_all(), "id_group", $id_group, '', '', 0, true, false, false, 'w130', false, '', false, false, 'id_grupo', $strict_user);
|
||||||
$table->data[] = $data;
|
$table->data[] = $data;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_console
|
%define name pandorafms_console
|
||||||
%define version 6.0dev
|
%define version 6.0dev
|
||||||
%define release 150326
|
%define release 150329
|
||||||
|
|
||||||
# User and Group under which Apache is running
|
# User and Group under which Apache is running
|
||||||
%define httpd_name httpd
|
%define httpd_name httpd
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_console
|
%define name pandorafms_console
|
||||||
%define version 6.0dev
|
%define version 6.0dev
|
||||||
%define release 150326
|
%define release 150329
|
||||||
%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
|
||||||
|
|
|
@ -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','PD150326'),
|
('db_scheme_build','PD150329'),
|
||||||
('show_unknown','0'),
|
('show_unknown','0'),
|
||||||
('show_lastalerts','1'),
|
('show_lastalerts','1'),
|
||||||
('style','pandora'),
|
('style','pandora'),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package: pandorafms-server
|
package: pandorafms-server
|
||||||
Version: 6.0dev-150326
|
Version: 6.0dev-150329
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: admin
|
Section: admin
|
||||||
|
|
|
@ -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-150326"
|
pandora_version="6.0dev-150329"
|
||||||
|
|
||||||
package_cpan=0
|
package_cpan=0
|
||||||
package_pandora=1
|
package_pandora=1
|
||||||
|
|
|
@ -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 = "150326";
|
my $pandora_build = "150329";
|
||||||
our $VERSION = $pandora_version." ".$pandora_build;
|
our $VERSION = $pandora_version." ".$pandora_build;
|
||||||
|
|
||||||
# Setup hash
|
# Setup hash
|
||||||
|
|
|
@ -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.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_server
|
%define name pandorafms_server
|
||||||
%define version 6.0dev
|
%define version 6.0dev
|
||||||
%define release 150326
|
%define release 150329
|
||||||
|
|
||||||
Summary: Pandora FMS Server
|
Summary: Pandora FMS Server
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
%define name pandorafms_server
|
%define name pandorafms_server
|
||||||
%define version 6.0dev
|
%define version 6.0dev
|
||||||
%define release 150326
|
%define release 150329
|
||||||
|
|
||||||
Summary: Pandora FMS Server
|
Summary: Pandora FMS Server
|
||||||
Name: %{name}
|
Name: %{name}
|
||||||
|
|
|
@ -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 PS150326";
|
my $version = "6.0dev PS150329";
|
||||||
|
|
||||||
# Pandora server configuration
|
# Pandora server configuration
|
||||||
my %conf;
|
my %conf;
|
||||||
|
|
|
@ -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 PS150326";
|
my $version = "6.0dev PS150329";
|
||||||
|
|
||||||
# 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";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue