This commit is contained in:
m-lopez-f 2015-04-27 13:35:52 +02:00
commit 25e5a476f0
40 changed files with 764 additions and 641 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 6.0dev-150424
Version: 6.0dev-150427
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-150424"
pandora_version="6.0dev-150427"
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 => '150424';
use constant AGENT_BUILD => '150427';
# 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 150424
%define release 150427
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 150424
%define release 150427
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

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

View File

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

View File

@ -340,11 +340,9 @@ foreach ($layoutDatas as $layoutData) {
$params['javascript_ajax_page'] = '../../ajax.php';
$params['disabled_javascript_on_blur_function'] = true;
$params['print_input_server'] = true;
$params['input_server_id'] =
$params['input_server_name'] = 'id_server_name_' . $idLayoutData;
$params['input_server_value'] =
db_get_value('server_name', 'tmetaconsole_setup', 'id', $layoutData['id_metaconsole']);
$params['print_input_id_server'] = true;
$params['input_id_server_id'] = $params['input_id_server_name'] = 'id_server_id_' . $idLayoutData;
$params['input_id_server_value'] = $layoutData['id_metaconsole'];
$params['metaconsole_enabled'] = true;
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_name'] = 'id_agent_' . $idLayoutData;

View File

@ -281,11 +281,8 @@ switch ($activeTab) {
}
$agentName = get_parameter('agent_' . $id, '');
if (defined('METACONSOLE')) {
$values['id_metaconsole'] = db_get_value('id',
'tmetaconsole_setup', 'server_name',
get_parameter('id_server_name_' . $id, ''));
$values['id_agent'] =
(int)get_parameter('id_agent_' . $id, 0);
$values['id_metaconsole'] = (int) get_parameter('id_server_id_' . $id, '');
$values['id_agent'] = (int) get_parameter('id_agent_' . $id, 0);
}
else {
$values['id_agent'] = agents_get_agent_id($agentName);

View File

@ -183,7 +183,7 @@ if (defined('METACONSOLE')) {
$table->rowstyle["all_2"] = 'display: none;';
$table->data["all_2"][0] = __('Servers');
$table->data["all_2"][1] = html_meta_print_select_servers(false,
false, 'servers', '', '', '', 0, true);
false, 'servers', '', 'metaconsole_init();', '', 0, true);
}
@ -210,8 +210,12 @@ $table->data["all_one_item_per_agent"][1] .= html_print_input_hidden(
$table->rowstyle["all_4"] = 'display: none;';
$table->data["all_4"][0] = __('Agents');
$table->data["all_4"][1] = html_print_select(
agents_get_group_agents(0, false, "none", false, true),
$agents_list = array();
if (!defined('METACONSOLE'))
$agents_list = agents_get_group_agents(0, false, "none", false, true);
$table->data["all_4"][1] = html_print_select($agents_list,
'id_agents[]', 0, false, '', '', true, true);
$table->data["all_4"][2] = ' <span style="vertical-align: top;">' .
__('Modules') . '</span>';
@ -272,7 +276,7 @@ else {
onsubmit="if (! confirm(\''.__('Are you sure to add many elements\nin visual map?').'\')) return false; else return check_fields();">';
}
if(defined("METACONSOLE")){
if (defined("METACONSOLE")) {
echo "<div class='title_tactical' style='margin-top: 15px; '>" . __('Wizard') . "</div>";
}
@ -296,16 +300,14 @@ echo '<span id="none_text" style="display: none;">' . __('None') . '</span>';
echo '<span id="loading_text" style="display: none;">' . __('Loading...') . '</span>';
?>
<script type="text/javascript">
var show_only_enabled_modules = true;
<?php
if (defined('METACONSOLE')) {
echo 'var url_ajax = "../../ajax.php";';
var metaconsole_enabled = <?php echo json_encode(defined('METACONSOLE')); ?>;
var show_only_enabled_modules = true;
var url_ajax = "ajax.php";
if (metaconsole_enabled) {
url_ajax = "../../ajax.php";
}
else {
echo 'var url_ajax = "ajax.php";';
}
?>
$(document).ready (function () {
hidden_rows();
@ -314,40 +316,42 @@ $(document).ready (function () {
selected = $("#process_value").val();
if (selected == <?php echo PROCESS_VALUE_NONE; ?>) {
$("tr", "#wizard_table").filter(function () {return /^.*modulegraph_simplevalue.*/.test(this.id); }).hide();
$("tr", "#wizard_table").filter(function () {
return /^.*modulegraph_simplevalue.*/.test(this.id);
}).hide();
}
else {
$("tr", "#wizard_table").filter(function () {return /^.*modulegraph_simplevalue.*/.test(this.id); }).show();
$("tr", "#wizard_table").filter(function () {
return /^.*modulegraph_simplevalue.*/.test(this.id);
}).show();
}
});
$("#groups").change (function () {
$('#id_agents').attr('disabled', true);
$('#id_agents').empty ();
$('#id_agents').append ($('<option></option>').html($("#loading_text").html()));
$('#id_agents').css ("width", "auto");
$('#id_agents').css ("max-width", "");
$('#id_agents')
.attr('disabled', true)
.empty ()
.css ("width", "auto")
.css ("max-width", "")
.append ($('<option></option>').html($("#loading_text").html()));
var data_params = {"page": "include/ajax/agent",
"get_agents_group": 1,
"id_group": $("#groups").val(),
<?php
if (defined('METACONSOLE')) {
echo '"id_server": $("#servers").val(),' . "\n";
}
?>
"mode": "json"
};
var data_params = {
page: "include/ajax/agent",
get_agents_group: 1,
id_group: $("#groups").val(),
mode: "json"
};
if (metaconsole_enabled)
data_params.id_server = $("#servers").val();
jQuery.ajax ({
data: data_params,
async: false,
type: 'POST',
url: url_ajax,
timeout: 10000,
dataType: 'json',
success: function (data) {
$('#id_agents').empty ();
$('#id_agents').empty();
if (isEmptyObject(data)) {
var noneText = $("#none_text").html(); //Trick for catch the translate text.
@ -361,35 +365,32 @@ $(document).ready (function () {
});
}
$('#id_agents').css ("width", "auto");
$('#id_agents').css ("max-width", "");
$('#id_agents').removeAttr('disabled');
return;
}
});
return;
});
$("#id_agents").change ( function() {
if ($("#hidden-item_per_agent_test").val() == 0)
agent_changed_by_multiple_agents(
<?php
if (defined('METACONSOLE')) {
echo "{'data': {'id_server': 'servers', 'metaconsole': 1, 'homedir': '../../'}}";
if ($("#hidden-item_per_agent_test").val() == 0) {
var options = {};
if (metaconsole_enabled) {
options = {
'data': {
'id_server': 'servers',
'metaconsole': 1,
'homedir': '../../'
}
};
}
?>
);
agent_changed_by_multiple_agents(options);
}
});
<?php
if (defined('METACONSOLE')) {
echo "metaconsole_init();";
if (metaconsole_enabled) {
metaconsole_init();
}
?>
$("select[name='kind_relationship']").change(function() {
@ -500,7 +501,7 @@ function item_per_agent_change(itemPerAgent) {
}
function metaconsole_init() {
$("#groups").trigger('change');
$("#groups").change();
}
</script>
<style type="text/css">

View File

@ -36,34 +36,12 @@ if ($get_agents_group) {
$return = array();
if ($id_group != -1) {
if (defined('METACONSOLE')) {
if ($id_server == 0) {
$servers = $servers = db_get_all_rows_sql ("SELECT *
FROM tmetaconsole_setup
WHERE disabled = 0");
}
else {
$servers = db_get_all_rows_sql ("SELECT *
FROM tmetaconsole_setup
WHERE id = " . $id_server . "
AND disabled = 0");
}
foreach ($servers as $server) {
if (metaconsole_load_external_db ($server) != NOERR) {
continue;
}
$return = agents_get_group_agents($id_group);
//Restore db connection
metaconsole_restore_db();
}
}
else {
$return = agents_get_group_agents($id_group);
}
$filter = array();
if (defined('METACONSOLE'))
$filter['id_server'] = $id_server;
$return = agents_get_group_agents($id_group, $filter, "none");
}
switch ($mode) {
@ -185,12 +163,6 @@ if ($search_agents && ((!defined('METACONSOLE')) || $force_local)) {
return;
}
elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE')) {
$servers = db_get_all_rows_sql ("SELECT *
FROM tmetaconsole_setup
WHERE disabled = 0");
if (!isset($servers)) {
return;
}
$id_agent = (int) get_parameter ('id_agent');
$string = (string) get_parameter ('q'); /* q is what autocomplete plugin gives */
@ -204,7 +176,7 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
}
}
$filter = array ();
$filter = array();
if ($id_group != -1) {
if ($id_group == 0) {
@ -217,90 +189,63 @@ elseif ($search_agents && ($config['metaconsole'] == 1) && defined('METACONSOLE'
}
}
$data = array();
foreach ($servers as $server) {
if (metaconsole_load_external_db ($server) != NOERR) {
continue;
}
if (!empty($id_agent)) {
$filter['id_agente'] = $id_agent;
}
if (!empty($string)) {
$search_filters = array();
//Get agents for only the name.
$filter_agents = $filter;
switch ($config['dbtype']) {
case "mysql":
$filter_agents[] = '(nombre COLLATE utf8_general_ci LIKE "%'.$string.'%")';
//Get agents for only the name.
$search_filters[] = "(nombre COLLATE utf8_general_ci LIKE '%$string%')";
//Get agents for only the address
$search_filters[] = "(direccion LIKE '%$string%')";
//Get agents for only the description
$search_filters[] = "(comentarios LIKE '%$string%')";
break;
case "postgresql":
$filter_agents[] = '(nombre LIKE \'%'.$string.'%\')';
//Get agents for only the name.
$search_filters[] = "(nombre LIKE '%$string%')";
//Get agents for only the address
$search_filters[] = "(direccion LIKE '%$string%')";
//Get agents for only the description
$search_filters[] = "(comentarios LIKE '%$string%')";
break;
case "oracle":
$filter_agents[] = '(UPPER(nombre) LIKE UPPER(\'%'.$string.'%\')';
//Get agents for only the name.
$search_filters[] = "(UPPER(nombre) LIKE UPPER('%$string%')";
//Get agents for only the address
$search_filters[] = "(UPPER(direccion) LIKE UPPER('%$string%'))";
//Get agents for only the description
$search_filters[] = "(UPPER(comentarios) LIKE UPPER('%$string%'))";
break;
}
$agents = agents_get_agents($filter_agents, array ('id_agente', 'nombre', 'direccion'));
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'filter' => 'agent',
'id_server' => $server['id']);
}
}
//Get agents for only the address
$filter_address = $filter;
switch ($config['dbtype']) {
case "mysql":
$filter_address[] = '(nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion LIKE "%'.$string.'%")';
break;
case "postgresql":
$filter_address[] = '(nombre NOT LIKE \'%'.$string.'%\' AND direccion LIKE \'%'.$string.'%\')';
break;
case "oracle":
$filter_address[] = '(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = agents_get_agents($filter_address, array ('id_agente', 'nombre', 'direccion'));
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'filter' => 'address',
'id_server' => $server['id']);
}
}
$search_filters_str = implode($search_filters, ' OR ');
//Get agents for only the description
$filter_description = $filter;
switch ($config['dbtype']) {
case "mysql":
$filter_description[] =
'(nombre COLLATE utf8_general_ci NOT LIKE "%'.$string.'%" AND direccion NOT LIKE "%'.$string.'%" AND comentarios LIKE "%'.$string.'%")';
break;
case "postgresql":
$filter_description[] =
'(nombre NOT LIKE \'%'.$string.'%\' AND direccion NOT LIKE \'%'.$string.'%\' AND comentarios LIKE \'%'.$string.'%\')';
break;
case "oracle":
$filter_description[] =
'(UPPER(nombre) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(direccion) NOT LIKE UPPER(\'%'.$string.'%\') AND UPPER(comentarios) LIKE UPPER(\'%'.$string.'%\'))';
break;
}
$agents = agents_get_agents($filter_description,
array ('id_agente', 'nombre', 'direccion'));
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'filter' => 'description',
'id_server' => $server['id']);
}
}
//Restore db connection
metaconsole_restore_db();
if (!empty($search_filters_str))
$filter[] = "($search_filters_str)";
}
$fields = array(
'id_tagente AS id_agente', 'nombre',
'direccion', 'id_tmetaconsole_setup AS id_server'
);
$agents = db_get_all_rows_filter('tmetaconsole_agent', $filter, $fields);
$data = array();
if ($agents !== false) {
foreach ($agents as $agent) {
$data[] = array('id' => $agent['id_agente'],
'name' => io_safe_output($agent['nombre']),
'ip' => io_safe_output($agent['direccion']),
'filter' => 'description',
'id_server' => $agent['id_server']);
}
}
echo json_encode($data);

View File

@ -351,67 +351,110 @@ class Tree {
if (empty($rootID) || $rootID == -1) {
if ($this->strictACL)
return false;
$columns = 'tg.id_grupo AS id, tg.nombre AS name, tg.parent, tg.icon, COUNT(DISTINCT(ta.id_agente)) AS total_count';
$columns = 'tg.id_grupo AS id, tg.nombre AS name, tg.parent, tg.icon';
$order_fields = 'tg.nombre ASC, tg.id_grupo ASC';
// Add the agent counters to the columns
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
WHERE ta.disabled = 0
AND ta.id_grupo = tg.id_grupo
if (! defined('METACONSOLE')) {
// Add the agent counters to the columns
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
WHERE ta.disabled = 0
AND ta.id_grupo = tg.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter";
$counter_columns = $this->getAgentCounterColumnsSql($agent_table);
if (!empty($counter_columns))
$columns .= ", $counter_columns";
$sql = "SELECT $columns
FROM tgrupo AS tg
LEFT JOIN tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
ON ta.disabled = 0
AND tg.id_grupo = ta.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter
$module_search_filter";
$counter_columns = $this->getAgentCounterColumnsSql($agent_table);
if (!empty($counter_columns))
$columns .= ", $counter_columns";
GROUP BY tg.id_grupo
ORDER BY $order_fields";
}
// Metaconsole
else {
// Add the agent counters to the columns
$agent_table = "SELECT COUNT(DISTINCT(ta.id_agente))
FROM tmetaconsole_agent AS ta
WHERE ta.disabled = 0
AND ta.id_grupo = tg.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter";
$counter_columns = $this->getAgentCounterColumnsSql($agent_table);
if (!empty($counter_columns))
$columns .= ", $counter_columns";
$sql = "SELECT $columns
FROM tgrupo AS tg
LEFT JOIN tagente AS ta
ON ta.disabled = 0
AND tg.id_grupo = ta.id_grupo
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY tg.id_grupo
ORDER BY $order_fields";
}
}
else {
if (! defined('METACONSOLE') || $this->strictACL) {
$columns = 'ta.id_agente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
FROM tgrupo AS tg
LEFT JOIN tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
ON ta.disabled = 0
AND tg.id_grupo = ta.id_grupo
$sql = "SELECT $columns
FROM tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
WHERE ta.disabled = 0
AND ta.id_grupo = $rootID
$group_acl
$agent_search_filter
$agent_status_filter
$module_search_filter
GROUP BY tg.id_grupo
ORDER BY $order_fields";
}
else {
$columns = 'ta.id_agente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet';
$order_fields = 'ta.nombre ASC, ta.id_agente ASC';
$sql = "SELECT $columns
FROM tagente AS ta
LEFT JOIN tagente_modulo AS tam
ON tam.disabled = 0
AND ta.id_agente = tam.id_agente
$module_search_filter
$module_status_join
WHERE ta.disabled = 0
AND ta.id_grupo = $rootID
$group_acl
$agent_search_filter
$agent_status_filter
$module_search_filter
GROUP BY ta.id_agente
ORDER BY $order_fields";
GROUP BY ta.id_agente
ORDER BY $order_fields";
}
else {
$columns = 'ta.id_tagente AS id, ta.nombre AS name,
ta.fired_count, ta.normal_count, ta.warning_count,
ta.critical_count, ta.unknown_count, ta.notinit_count,
ta.total_count, ta.quiet, id_tmetaconsole_setup AS server_id';
$order_fields = 'ta.nombre ASC, ta.id_tagente ASC';
$sql = "SELECT $columns
FROM tmetaconsole_agent AS ta
WHERE ta.disabled = 0
AND ta.id_grupo = $rootID
$group_acl
$agent_search_filter
$agent_status_filter
GROUP BY ta.id_tagente
ORDER BY $order_fields";
}
}
break;
// Get the modules of an agent
@ -419,7 +462,7 @@ class Tree {
$columns = 'tam.id_agente_modulo AS id, tam.nombre AS name,
tam.id_tipo_modulo, tam.id_modulo, tae.estado, tae.datos';
$order_fields = 'tam.nombre ASC, tam.id_agente_modulo ASC';
$sql = "SELECT $columns
FROM tagente_modulo AS tam
$module_status_join
@ -1387,8 +1430,12 @@ class Tree {
$agent['rootID'] = $this->rootID;
$agent['rootType'] = $this->rootType;
if (defined("METACONSOLE") && !empty($server))
$agent['serverID'] = $server['id'];
if (defined("METACONSOLE")) {
if (isset($agent['server_id']))
$agent['serverID'] = $agent['server_id'];
else if (!empty($server))
$agent['serverID'] = $server['id'];
}
// Realtime counters for Strict ACL
if ($this->strictACL) {
@ -1535,37 +1582,37 @@ class Tree {
if (isset($agent['unknown_count']))
$agent['counters']['unknown'] = $agent['unknown_count'];
else
$agent['counters']['unknown'] = agents_monitor_unknown($agent['id']);
$agent['counters']['unknown'] = (int) agents_monitor_unknown($agent['id']);
if (isset($agent['critical_count']))
$agent['counters']['critical'] = $agent['critical_count'];
else
$agent['counters']['critical'] = agents_monitor_critical($agent['id']);
$agent['counters']['critical'] = (int) agents_monitor_critical($agent['id']);
if (isset($agent['warning_count']))
$agent['counters']['warning'] = $agent['warning_count'];
else
$agent['counters']['warning'] = agents_monitor_warning($agent['id']);
$agent['counters']['warning'] = (int) agents_monitor_warning($agent['id']);
if (isset($agent['notinit_count']))
$agent['counters']['not_init'] = $agent['notinit_count'];
else
$agent['counters']['not_init'] = agents_monitor_notinit($agent['id']);
$agent['counters']['not_init'] = (int) agents_monitor_notinit($agent['id']);
if (isset($agent['normal_count']))
$agent['counters']['ok'] = $agent['normal_count'];
else
$agent['counters']['ok'] = agents_monitor_ok($agent['id']);
$agent['counters']['ok'] = (int) agents_monitor_ok($agent['id']);
if (isset($agent['total_count']))
$agent['counters']['total'] = $agent['total_count'];
else
$agent['counters']['total'] = agents_monitor_total($agent['id']);
$agent['counters']['total'] = (int) agents_monitor_total($agent['id']);
if (isset($agent['fired_count']))
$agent['counters']['alerts'] = $agent['fired_count'];
else
$agent['counters']['alerts'] = agents_get_alerts_fired($agent['id']);
$agent['counters']['alerts'] = (int) agents_get_alerts_fired($agent['id']);
}
// Status image
@ -1643,25 +1690,25 @@ class Tree {
}
}
private static function extractItemWithID ($items, $item_id, $item_type = "group") {
private static function extractItemWithID ($items, $item_id, $item_type = "group", $strictACL = false) {
foreach ($items as $item) {
if ($item["type"] != $item_type)
continue;
// Item found
if (! defined("METACONSOLE")) {
if ($item["id"] == $item_id)
return $item;
}
else {
if ($strictACL && defined("METACONSOLE")) {
foreach ($item["id"] as $server_id => $id) {
if ($id == $item_id)
return $item;
}
}
else {
if ($item["id"] == $item_id)
return $item;
}
if ($item["type"] == "group" && !empty($item["children"])) {
$result = self::extractItemWithID($item["children"], $item_id, $item_type);
$result = self::extractItemWithID($item["children"], $item_id, $item_type, $strictACL);
// Item found on children
if ($result !== false)
@ -1675,7 +1722,7 @@ class Tree {
public function getData() {
if (! $this->strictACL) {
if (! defined('METACONSOLE')) {
switch ($this->type) {
case 'os':
$this->getDataOS();
@ -1699,7 +1746,7 @@ class Tree {
$this->getDataExtended();
}
}
else {
else if ($this->strictACL) {
switch ($this->type) {
case 'group':
case 'tag':
@ -1710,6 +1757,14 @@ class Tree {
break;
}
}
else {
if ($this->type == 'agent') {
$this->getDataAgent();
}
else {
$this->getDataGroup();
}
}
}
protected function getDataExtended () {
@ -1721,7 +1776,7 @@ class Tree {
// Module names
if ($this->id == -1) {
}
// Agents
else {
@ -1737,19 +1792,13 @@ class Tree {
$server = metaconsole_get_servers($this->serverID);
if (metaconsole_connect($server) == NOERR) {
db_clean_cache();
$newItems = $this->getItems();
$this->processModules($newItems, $server);
$items = array_merge($items, $newItems);
$items = $this->getItems();
$this->processModules($items, $server);
metaconsole_restore_db();
}
}
if (!empty($items))
usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items;
}
}
@ -1897,56 +1946,27 @@ class Tree {
// Groups
if ($this->id == -1) {
if (! defined ('METACONSOLE')) {
$items = $this->getItems();
// Build the group hierarchy
foreach ($items as $key => $item) {
if (empty($item['parent'])) {
unset($items[$key]);
$items_tmp = array();
$processed_item = $this->getProcessedItem($item, false, $items, $items_tmp, true);
if (!empty($processed_item)
&& isset($processed_item['counters'])
&& isset($processed_item['counters']['total'])
&& !empty($processed_item['counters']['total']))
$processed_items[] = $processed_item;
}
$items = $this->getItems();
// Build the group hierarchy
foreach ($items as $key => $item) {
if (empty($item['parent'])) {
unset($items[$key]);
$items_tmp = array();
$processed_item = $this->getProcessedItem($item, false, $items, $items_tmp, true);
if (!empty($processed_item)
&& isset($processed_item['counters'])
&& isset($processed_item['counters']['total'])
&& !empty($processed_item['counters']['total']))
$processed_items[] = $processed_item;
}
}
else {
$servers = metaconsole_get_servers();
$item_list = array();
foreach ($servers as $server) {
if (metaconsole_connect($server) != NOERR)
continue;
db_clean_cache();
$items = $this->getItems();
// Build the group hierarchy
$processed_items = array();
foreach ($items as $key => $item) {
if (empty($item['parent'])) {
unset($items[$key]);
$processed_items[] = $this->getProcessedItem($item, $server, $items);
}
}
$item_list = array_merge($item_list, $processed_items);
metaconsole_restore_db();
}
$processed_items = $this->getMergedItems($item_list);
}
// groupID filter. To access the view from tactical views f.e.
if (!empty($processed_items) && !empty($this->filter['groupID'])) {
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group");
$result = self::extractItemWithID($processed_items, $this->filter['groupID'], "group", $this->strictACL);
if ($result === false)
$processed_items = array();
@ -1956,35 +1976,9 @@ class Tree {
}
// Agents
else {
if (! defined ('METACONSOLE')) {
$items = $this->getItems();
$this->processAgents($items);
$processed_items = $items;
}
else {
$rootIDs = $this->rootID;
$items = array();
foreach ($rootIDs as $serverID => $rootID) {
$server = metaconsole_get_servers($serverID);
if (metaconsole_connect($server) != NOERR)
continue;
db_clean_cache();
$this->rootID = $rootID;
$newItems = $this->getItems();
$this->processAgents($newItems, $server);
$items = array_merge($items, $newItems);
metaconsole_restore_db();
}
$this->rootID = $rootIDs;
if (!empty($items))
usort($items, array("Tree", "cmpSortNames"));
$processed_items = $items;
}
$items = $this->getItems();
$this->processAgents($items);
$processed_items = $items;
}
$this->tree = $processed_items;

View File

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

View File

@ -19,8 +19,10 @@
* @subpackage Agents
*/
require_once($config['homedir'] . '/include/functions.php');
require_once($config['homedir'] . "/include/functions_modules.php");
require_once($config['homedir'] . '/include/functions_users.php');
enterprise_include_once('/include/functions_agents.php');
/**
* Check the agent exists in the DB.
@ -755,13 +757,14 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge
* @param string $case Which case to return the agentname as (lower, upper, none)
* @param boolean $noACL jump the ACL test.
* @param boolean $childGroups The flag to get agents in the child group of group parent passed. By default false.
* @param boolean $extra_access The flag to get agents of extra access policies.
*
* @return array An array with all agents in the group or an empty array
*/
function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower", $noACL = false, $childGroups = false, $extra_access = true) {
function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower", $noACL = false, $childGroups = false) {
global $config;
$filter = array();
if (!$noACL) {
$id_group = groups_safe_acl($config["id_user"], $id_group, "AR");
@ -783,43 +786,30 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
$id_group = array_keys(users_get_groups(false, "AR", true, false, (array)$id_group));
}
if (is_array($id_group)) {
$all_groups = false;
$search_group_sql = sprintf ('id_grupo IN (%s)', implode (",", $id_group));
if (!empty($id_group)) {
$filter['id_grupo'] = $id_group;
}
else if ($id_group == 0) { //All group
$all_groups = true;
$search_group_sql = '1 = 1';
}
else {
$all_groups = false;
$search_group_sql = sprintf ('id_grupo = %d', $id_group);
}
$search_sql = '1 = 1';
if ($search === true) {
//No added search. Show both disabled and non-disabled
}
elseif (is_array ($search)) {
else if (is_array ($search)) {
$filter['disabled'] = 0;
if (isset ($search["disabled"])) {
$search_sql .= ' AND disabled = '.($search["disabled"] ? 1 : 0); //Bool, no cleanup necessary
$filter['disabled'] = (int) $search["disabled"];
unset ($search["disabled"]);
}
else {
$search_sql .= ' AND disabled = 0';
}
unset ($search["disabled"]);
if (isset ($search["string"])) {
$string = io_safe_input ($search["string"]);
switch ($config["dbtype"]) {
case "mysql":
$search_sql .= ' AND (nombre COLLATE utf8_general_ci LIKE "%'.$string.'%" OR direccion LIKE "%'.$string.'%")';
break;
case "postgresql":
$search_sql .= ' AND (nombre COLLATE utf8_general_ci LIKE \'%'.$string.'%\' OR direccion LIKE \'%'.$string.'%\')';
$filter[] = "(nombre COLLATE utf8_general_ci LIKE '%$string%' OR direccion LIKE '%$string%')";
break;
case "oracle":
$search_sql .= ' AND (UPPER(nombre) LIKE UPPER(\'%'.$string.'%\') OR direccion LIKE upper(\'%'.$string.'%\'))';
$filter[] = "(UPPER(nombre) LIKE UPPER('%$string%') OR direccion LIKE upper('%$string%'))";
break;
}
@ -830,13 +820,11 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
$name = io_safe_input ($search["name"]);
switch ($config["dbtype"]) {
case "mysql":
$search_sql .= ' AND nombre COLLATE utf8_general_ci LIKE "' . $name . '" ';
break;
case "postgresql":
$search_sql .= ' AND nombre COLLATE utf8_general_ci LIKE \'' . $name . '\' ';
$filter[] = "nombre COLLATE utf8_general_ci LIKE '$name'";
break;
case "oracle":
$search_sql .= ' AND UPPER(nombre) LIKE UPPER(\'' . $name . '\') ';
$filter[] = "UPPER(nombre) LIKE UPPER('$name')";
break;
}
@ -846,65 +834,60 @@ function agents_get_group_agents ($id_group = 0, $search = false, $case = "lower
if (isset($search['status'])) {
switch ($search['status']) {
case AGENT_STATUS_NORMAL:
$search_sql .=
" AND normal_count = total_count";
$filter[] = "normal_count = total_count";
break;
case AGENT_STATUS_WARNING:
$search_sql .=
" AND critical_count = 0 AND warning_count > 0";
$filter[] = "(critical_count = 0 AND warning_count > 0)";
break;
case AGENT_STATUS_CRITICAL:
$search_sql .=
" AND critical_count > 0";
$filter[] = "critical_count > 0";
break;
case AGENT_STATUS_UNKNOWN:
$search_sql .=
" AND critical_count = 0 AND warning_count = 0
AND unknown_count > 0";
$filter[] = "(critical_count = 0 AND warning_count = 0 AND unknown_count > 0)";
break;
case AGENT_STATUS_NOT_NORMAL:
$search_sql .= " AND normal_count <> total_count";
$filter[] = "normal_count <> total_count";
break;
case AGENT_STATUS_NOT_INIT:
$search_sql .= " AND notinit_count = total_count";
$filter[] = "notinit_count = total_count";
break;
}
unset($search['status']);
}
if (defined('METACONSOLE') && isset($search['id_server'])) {
$filter['id_tmetaconsole_setup'] = $search['id_server'];
unset ($search["id_server"]);
}
if (! empty ($search)) {
$search_sql .= ' AND '.db_format_array_where_clause_sql ($search);
// Add the rest of the filter from the search array
foreach ($search as $key => $value) {
$filter[] = $value;
}
}
else {
$search_sql .= ' AND disabled = 0';
$filter['disabled'] = 0;
}
enterprise_include_once ('include/functions_policies.php');
$filter['order'] = 'nombre';
// TODO: CLEAN extra_sql
$extra_sql = '';
switch ($config["dbtype"]) {
case "mysql":
case "postgresql":
$sql = sprintf ("SELECT id_agente, nombre
FROM tagente
WHERE (%s %s) AND (%s)
ORDER BY nombre",
$extra_sql, $search_group_sql, $search_sql);
break;
case "oracle":
$sql = sprintf ("SELECT id_agente, nombre
FROM tagente
WHERE (%s %s) AND (%s)
ORDER BY dbms_lob.substr(nombre,4000,1)",
$extra_sql, $search_group_sql, $search_sql);
break;
if (defined('METACONSOLE')) {
$table_name = 'tmetaconsole_agent';
$fields = array(
'id_tagente AS id_agente', 'nombre'
);
}
else {
$table_name = 'tagente';
$fields = array(
'id_agente', 'nombre'
);
}
$result = db_get_all_rows_sql ($sql);
$result = db_get_all_rows_filter($table_name, $filter, $fields);
if ($result === false)
return array (); //Return an empty array
@ -1831,7 +1814,9 @@ function agents_delete_agent ($id_agents, $disableACL = false) {
db_pandora_audit( "Agent management",
"Deleted agent '$agent_name'");
// Delete the agent from the metaconsole cache
enterprise_hook('agent_delete_from_cache', array($id_agent));
/* Break the loop on error */
if ($error)
break;

View File

@ -204,21 +204,23 @@ function config_update_config () {
if ((int)get_parameter('event_replication') == 1) {
if (!config_update_value ('replication_interval', (int)get_parameter('replication_interval')))
$error_update[] = __('Replication interval');
if (!config_update_value ('replication_dbhost', (string)get_parameter('replication_dbhost')))
$error_update[] = __('Replication DB host');
if (!config_update_value ('replication_dbname', (string)get_parameter('replication_dbname')))
$error_update[] = __('Replication DB database');
if (!config_update_value ('replication_dbuser', (string)get_parameter('replication_dbuser')))
$error_update[] = __('Replication DB user');
if (!config_update_value ('replication_dbpass', io_input_password((string)get_parameter('replication_dbpass'))))
$error_update[] = __('Replication DB password');
if (!config_update_value ('replication_dbport', (string)get_parameter('replication_dbport')))
$error_update[] = __('Replication DB port');
if (!config_update_value ('replication_mode', (string)get_parameter('replication_mode')))
$error_update[] = __('Replication mode');
if (!config_update_value ('show_events_in_local', (string)get_parameter('show_events_in_local')))
$error_update[] = __('Show events list in local console (read only)');
}
if (!config_update_value ('replication_dbhost', (string)get_parameter('replication_dbhost')))
$error_update[] = __('Replication DB host');
if (!config_update_value ('replication_dbname', (string)get_parameter('replication_dbname')))
$error_update[] = __('Replication DB database');
if (!config_update_value ('replication_dbuser', (string)get_parameter('replication_dbuser')))
$error_update[] = __('Replication DB user');
if (!config_update_value ('replication_dbpass', io_input_password((string)get_parameter('replication_dbpass'))))
$error_update[] = __('Replication DB password');
if (!config_update_value ('replication_dbport', (string)get_parameter('replication_dbport')))
$error_update[] = __('Replication DB port');
if (!config_update_value ('metaconsole_agent_cache', (int)get_parameter('metaconsole_agent_cache')))
$error_update[] = __('Metaconsole agent cache');
if (!config_update_value ('log_collector', (bool)get_parameter('log_collector')))
$error_update[] = __('Activate Log Collector');
@ -798,6 +800,10 @@ function config_process_config () {
config_update_value ('replication_mode', "only_validated");
}
if (!isset ($config["metaconsole_agent_cache"])) {
config_update_value ('metaconsole_agent_cache', 0);
}
if (!isset ($config["show_events_in_local"])) {
config_update_value ('show_events_in_local', 0);
}

View File

@ -2278,10 +2278,10 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
}
if ($user_strict) {
$user_groups_ids = implode(',',array_keys($groups_without_tags));
$user_groups_ids = implode(',', array_keys($groups_without_tags));
}
else {
$user_groups_ids = implode(',',array_keys($acltags));
$user_groups_ids = implode(',', array_keys($acltags));
}
if (!empty($user_groups_ids)) {
@ -2341,10 +2341,251 @@ function group_get_data ($id_user = false, $user_strict = false, $acltags, $retu
else {
$i = 0;
}
/*
* Agent cache for metaconsole.
* Retrieve the statistic data from the cache table.
*/
if (!$user_strict && defined('METACONSOLE') && !empty($list_groups)) {
$cache_table = 'tmetaconsole_agent';
$sql_stats = "SELECT id_grupo, COUNT(id_agente) AS agents_total,
SUM(total_count) AS monitors_total,
SUM(normal_count) AS monitors_ok,
SUM(warning_count) AS monitors_warning,
SUM(critical_count) AS monitors_critical,
SUM(unknown_count) AS monitors_unknown,
SUM(notinit_count) AS monitors_not_init,
SUM(fired_count) AS alerts_fired
FROM $cache_table
WHERE disabled = 0
AND id_grupo IN ($user_groups_ids)
GROUP BY id_grupo";
$data_stats = db_get_all_rows_sql($sql_stats);
$sql_stats_unknown = "SELECT id_grupo, COUNT(id_agente) AS agents_unknown
FROM $cache_table
WHERE disabled = 0
AND id_grupo IN ($user_groups_ids)
AND critical_count = 0
AND warning_count = 0
AND unknown_count > 0
GROUP BY id_grupo";
$data_stats_unknown = db_get_all_rows_sql($sql_stats_unknown);
$sql_stats_not_init = "SELECT id_grupo, COUNT(id_agente) AS agents_not_init
FROM $cache_table
WHERE disabled = 0
AND id_grupo IN ($user_groups_ids)
AND (total_count = 0 OR total_count = notinit_count)
GROUP BY id_grupo";
$data_stats_not_init = db_get_all_rows_sql($sql_stats_not_init);
if ($mode == 'tactical' || $mode == 'tree') {
$sql_stats_ok = "SELECT id_grupo, COUNT(id_agente) AS agents_ok
FROM $cache_table
WHERE disabled = 0
AND id_grupo IN ($user_groups_ids)
AND critical_count = 0
AND warning_count = 0
AND unknown_count = 0
AND normal_count > 0
GROUP BY id_grupo";
$data_stats_ok = db_get_all_rows_sql($sql_stats_ok);
$sql_stats_warning = "SELECT id_grupo, COUNT(id_agente) AS agents_warning
FROM $cache_table
WHERE disabled = 0
AND id_grupo IN ($user_groups_ids)
AND critical_count = 0
AND warning_count > 0
GROUP BY id_grupo";
$data_stats_warning = db_get_all_rows_sql($sql_stats_warning);
$sql_stats_critical = "SELECT id_grupo, COUNT(id_agente) AS agents_critical
FROM $cache_table
WHERE disabled = 0
AND id_grupo IN ($user_groups_ids)
AND critical_count = 0
AND warning_count > 0
GROUP BY id_grupo";
$data_stats_critical = db_get_all_rows_sql($sql_stats_critical);
}
$stats_by_group = array();
if (!empty($data_stats)) {
foreach ($data_stats as $value) {
$group_id = (int) $value['id_grupo'];
$stats = array();
$stats['agents_total'] = (int) $value['agents_total'];
$stats['monitors_total'] = (int) $value['monitors_total'];
$stats['monitors_ok'] = (int) $value['monitors_ok'];
$stats['monitors_warning'] = (int) $value['monitors_warning'];
$stats['monitors_critical'] = (int) $value['monitors_critical'];
$stats['monitors_unknown'] = (int) $value['monitors_unknown'];
$stats['monitors_not_init'] = (int) $value['monitors_not_init'];
$stats['alerts_fired'] = (int) $value['alerts_fired'];
$stats_by_group[$group_id] = $stats;
}
if (!empty($stats_by_group)) {
if (!empty($data_stats_unknown)) {
foreach ($data_stats_unknown as $value) {
$group_id = (int) $value['id_grupo'];
if (isset($stats_by_group[$group_id])) {
$stats_by_group[$group_id]['agents_unknown'] = (int) $value['agents_unknown'];
}
}
}
if (!empty($data_stats_not_init)) {
foreach ($data_stats_not_init as $value) {
$group_id = (int) $value['id_grupo'];
if (isset($stats_by_group[$group_id])) {
$stats_by_group[$group_id]['agents_not_init'] = (int) $value['agents_not_init'];
}
}
}
if (!empty($data_stats_ok)) {
foreach ($data_stats_ok as $value) {
$group_id = (int) $value['id_grupo'];
if (isset($stats_by_group[$group_id])) {
$stats_by_group[$group_id]['agents_ok'] = (int) $value['agents_ok'];
}
}
}
if (!empty($data_stats_warning)) {
foreach ($data_stats_warning as $value) {
$group_id = (int) $value['id_grupo'];
if (isset($stats_by_group[$group_id])) {
$stats_by_group[$group_id]['agents_warning'] = (int) $value['agents_warning'];
}
}
}
if (!empty($data_stats_critical)) {
foreach ($data_stats_critical as $value) {
$group_id = (int) $value['id_grupo'];
if (isset($stats_by_group[$group_id])) {
$stats_by_group[$group_id]['agents_critical'] = (int) $value['agents_critical'];
}
}
}
}
}
}
foreach ($list_groups as $key => $item) {
$id = $item['id_grupo'];
if (($config["realtimestats"] == 0) && !$user_strict) {
if (!$user_strict && defined('METACONSOLE')) { // Agent cache
$group_stat = array();
if (isset($stats_by_group[$id]))
$group_stat = $stats_by_group[$id];
$list[$i]['_id_'] = $id;
$list[$i]['_name_'] = $item['nombre'];
$list[$i]['_iconImg_'] = html_print_image ("images/groups_small/" . groups_get_icon($item['id_grupo']).".png", true, array ("style" => 'vertical-align: middle;'));
if ($mode == 'tree' && !empty($item['parent']))
$list[$i]['_parent_id_'] = $item['parent'];
$list[$i]['_agents_unknown_'] = isset($group_stat['agents_unknown']) ? $group_stat['agents_unknown'] : 0;
$list[$i]['_monitors_alerts_fired_'] = isset($group_stat['alerts_fired']) ? $group_stat['alerts_fired'] : 0;
$list[$i]['_total_agents_'] = isset($group_stat['agents_total']) ? $group_stat['agents_total'] : 0;
// This fields are not in database
$list[$i]['_monitors_ok_'] = isset($group_stat['monitors_ok']) ? $group_stat['monitors_ok'] : 0;
$list[$i]['_monitors_critical_'] = isset($group_stat['monitors_critical']) ? $group_stat['monitors_critical'] : 0;
$list[$i]['_monitors_warning_'] = isset($group_stat['monitors_warning']) ? $group_stat['monitors_warning'] : 0;
$list[$i]['_monitors_unknown_'] = isset($group_stat['monitors_unknown']) ? $group_stat['monitors_unknown'] : 0;
$list[$i]['_monitors_not_init_'] = isset($group_stat['monitors_not_init']) ? $group_stat['monitors_not_init'] : 0;
$list[$i]['_agents_not_init_'] = isset($group_stat['agents_not_init']) ? $group_stat['agents_not_init'] : 0;
if ($mode == 'tactical' || $mode == 'tree') {
$list[$i]['_agents_ok_'] = isset($group_stat['agents_ok']) ? $group_stat['agents_ok'] : 0;
$list[$i]['_agents_warning_'] = isset($group_stat['agents_warning']) ? $group_stat['agents_warning'] : 0;
$list[$i]['_agents_critical_'] = isset($group_stat['agents_critical']) ? $group_stat['agents_critical'] : 0;
$list[$i]['_monitors_alerts_'] = isset($group_stat['alerts']) ? $group_stat['alerts'] : 0;;
$list[$i]["_monitor_alerts_fire_count_"] = $group_stat[0]["alerts_fired"];
$list[$i]["_total_checks_"] = $group_stat[0]["modules"];
$list[$i]["_total_alerts_"] = $group_stat[0]["alerts"];
}
if ($mode == 'tactical') {
// Get total count of monitors for this group, except disabled.
$list[$i]["_monitor_checks_"] = $list[$i]["_monitors_not_init_"] + $list[$i]["_monitors_unknown_"] + $list[$i]["_monitors_warning_"] + $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_ok_"];
// Calculate not_normal monitors
$list[$i]["_monitor_not_normal_"] = $list[$i]["_monitor_checks_"] - $list[$i]["_monitors_ok_"];
if ($list[$i]["_monitor_not_normal_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_monitor_health_"] = format_numeric (100 - ($list[$i]["_monitor_not_normal_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_monitor_health_"] = 100;
}
if ($list[$i]["_monitors_not_init_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_module_sanity_"] = format_numeric (100 - ($list[$i]["_monitors_not_init_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_module_sanity_"] = 100;
}
if (isset($list[$i]["_alerts_"])) {
if ($list[$i]["_monitors_alerts_fired_"] > 0 && $list[$i]["_alerts_"] > 0) {
$list[$i]["_alert_level_"] = format_numeric (100 - ($list[$i]["_monitors_alerts_fired_"] / ($list[$i]["_alerts_"] / 100)), 1);
}
else {
$list[$i]["_alert_level_"] = 100;
}
}
else {
$list[$i]["_alert_level_"] = 100;
$list[$i]["_alerts_"] = 0;
}
$list[$i]["_monitor_bad_"] = $list[$i]["_monitors_critical_"] + $list[$i]["_monitors_warning_"];
if ($list[$i]["_monitor_bad_"] > 0 && $list[$i]["_monitor_checks_"] > 0) {
$list[$i]["_global_health_"] = format_numeric (100 - ($list[$i]["_monitor_bad_"] / ($list[$i]["_monitor_checks_"] / 100)), 1);
}
else {
$list[$i]["_global_health_"] = 100;
}
$list[$i]["_server_sanity_"] = format_numeric (100 - $list[$i]["_module_sanity_"], 1);
}
if ($returnAllGroup) {
$list[0]['_agents_unknown_'] += $list[$i]['_agents_unknown_'];
$list[0]['_monitors_alerts_fired_'] += $list[$i]['_monitors_alerts_fired_'];
$list[0]['_total_agents_'] += $list[$i]['_total_agents_'];
$list[0]['_monitors_ok_'] += $list[$i]['_monitors_ok_'];
$list[0]['_monitors_critical_'] += $list[$i]['_monitors_critical_'];
$list[0]['_monitors_warning_'] += $list[$i]['_monitors_warning_'];
$list[0]['_monitors_unknown_'] += $list[$i]['_monitors_unknown_'];
$list[0]['_monitors_not_init_'] += $list[$i]['_monitors_not_init_'];
$list[0]['_agents_not_init_'] += $list[$i]['_agents_not_init_'];
if ($mode == 'tactical' || $mode == 'tree') {
$list[0]['_agents_ok_'] += $list[$i]['_agents_ok_'];
$list[0]['_agents_warning_'] += $list[$i]['_agents_warning_'];
$list[0]['_agents_critical_'] += $list[$i]['_agents_critical_'];
$list[0]['_monitors_alerts_'] += $list[$i]['_monitors_alerts_'];
}
}
if ($mode == 'group') {
if (($list[$i]['_agents_unknown_'] == 0) && ($list[$i]['_monitors_alerts_fired_'] == 0)
&& ($list[$i]['_total_agents_'] == 0) && ($list[$i]['_monitors_ok_'] == 0)
&& ($list[$i]['_monitors_critical_'] == 0) && ($list[$i]['_monitors_warning_'] == 0)) {
unset($list[$i]);
}
}
}
else if (($config["realtimestats"] == 0) && !$user_strict) {
$group_stat = db_get_all_rows_sql ("SELECT *
FROM tgroup_stat, tgrupo
WHERE tgrupo.id_grupo = tgroup_stat.id_group
@ -2684,7 +2925,7 @@ function group_get_groups_list($id_user = false, $user_strict = false, $access =
$acltags = tags_get_user_module_and_tags ($id_user, $access, $user_strict);
if (! defined ('METACONSOLE')) {
if (! $user_strict) {
$result_list = group_get_data ($id_user, $user_strict, $acltags,
$returnAllGroup, $mode);

View File

@ -1847,18 +1847,22 @@ function reporting_get_stats_alerts($data, $links = false) {
$table_al->rowclass[] = '';
$table_al->data[] = $tdata;
if(!defined('METACONSOLE')){
if (!defined('METACONSOLE')) {
$output = '<fieldset class="databox tactical_set">
<legend>' .
__('Defined and fired alerts') .
'</legend>' .
html_print_table($table_al, true) . '</fieldset>';
}else{
}
else {
// Remove the defined alerts cause with the new cache table is difficult to retrieve them
unset($table_al->data[0][0], $table_al->data[0][1]);
$table_al->class = "tactical_view";
$table_al->style = array();
$output = '<fieldset class="tactical_set">
<legend>' .
__('Defined and fired alerts') .
__('Fired alerts') .
'</legend>' .
html_print_table($table_al, true) . '</fieldset>';
}

View File

@ -3157,7 +3157,6 @@ function ui_print_agent_autocomplete_input($parameters) {
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="' . $javascript_ajax_page . '",
timeout: 10000,
@ -3371,15 +3370,12 @@ function ui_print_agent_autocomplete_input($parameters) {
jQuery.ajax ({
data: data_params,
async: false,
type: "POST",
url: action="' . $javascript_ajax_page . '",
timeout: 10000,
dataType: "json",
success: function (data) {
if (data.length == 0) {
alert("' . __('Does not exist agent with this name.') . '");
//Set icon
$("#' . $input_id . '")
.css("background",

View File

@ -159,7 +159,6 @@ function show_response_dialog(event_id, response_id, response) {
data: params.join ("&"),
type: 'POST',
url: action=ajax_file,
async: false,
timeout: 10000,
dataType: 'html',
success: function (data) {

View File

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

View File

@ -423,6 +423,9 @@ if (is_ajax ()) {
($filter != '' ? $filter : false), $indexed);
}
if (empty($agent_modules))
$agent_modules = array();
foreach ($agent_modules as $key => $module) {
$agent_modules[$key]['nombre'] = io_safe_output($module['nombre']);
}
@ -438,28 +441,24 @@ if (is_ajax ()) {
if ($get_agent_status_tooltip) {
$id_agent = (int) get_parameter ('id_agent');
$metaconsole = (bool)get_parameter('metaconsole', false);
$id_server = (int)get_parameter('id_server', 0); //Metaconsole
$metaconsole = (bool) get_parameter('metaconsole', false);
$id_server = (int) get_parameter('id_server', 0); //Metaconsole
$server = null;
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);
$filter = array();
if (!empty($id_agent))
$filter['id_tagente'] = $id_agent;
if (!empty($id_server))
$filter['id_tmetaconsole_setup'] = $id_server;
if (metaconsole_connect($server) != NOERR) {
return;
}
$agent = db_get_row ('tagente', 'id_agente', $id_agent);
metaconsole_restore_db();
$agent = db_get_row_filter('tmetaconsole_agent', $filter);
}
else {
$agent = db_get_row ('tagente', 'id_agente', $id_agent);
}
if ($agent === false) { return; }
echo '<h3>'.$agent['nombre'].'</h3>';
echo '<strong>'.__('Main IP').':</strong> '.$agent['direccion'].'<br />';
@ -474,130 +473,91 @@ if (is_ajax ()) {
echo '<strong>'.__('Last contact').':</strong> '.human_time_comparation($agent['ultimo_contacto']).'<br />';
echo '<strong>'.__('Last remote contact').':</strong> '.human_time_comparation($agent['ultimo_contacto_remoto']).'<br />';
# Fix : Only show agents with module with tags of user profile
$_user_tags = tags_get_user_tags($config['id_user'], 'RR');
$_sql_post = '';
if (is_array($_user_tags) && !empty($_user_tags)) {
if (!$metaconsole) {
# Fix : Only show agents with module with tags of user profile
$_user_tags = tags_get_user_tags($config['id_user'], 'RR');
$_tags = implode(',', array_keys($_user_tags));
$_sql_post .= ' AND tagente_modulo.id_agente_modulo IN (SELECT a.id_agente_modulo FROM tagente_modulo a, ttag_module b WHERE a.id_agente_modulo=b.id_agente_modulo AND b.id_tag IN (' . $_tags . ')) ';
}
$sql = sprintf ('SELECT tagente_modulo.descripcion,
tagente_modulo.nombre
FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente = %d
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.estado = 1', $id_agent);
$sql .= $_sql_post;
if ($metaconsole) {
if (metaconsole_connect($server) != NOERR) {
return;
$_sql_post = '';
if (is_array($_user_tags) && !empty($_user_tags)) {
$_tags = implode(',', array_keys($_user_tags));
$_sql_post .= ' AND tagente_modulo.id_agente_modulo IN (SELECT a.id_agente_modulo FROM tagente_modulo a, ttag_module b WHERE a.id_agente_modulo=b.id_agente_modulo AND b.id_tag IN (' . $_tags . ')) ';
}
$sql = sprintf ('SELECT tagente_modulo.descripcion,
tagente_modulo.nombre
FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente = %d
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.disabled = 0
AND tagente_estado.estado = 1', $id_agent);
$sql .= $_sql_post;
$bad_modules = db_get_all_rows_sql ($sql);
metaconsole_restore_db();
}
else {
$bad_modules = db_get_all_rows_sql ($sql);
}
$sql = sprintf ('SELECT COUNT(*)
FROM tagente_modulo
WHERE id_agente = %d
AND disabled = 0', $id_agent);
if ($metaconsole) {
if (metaconsole_connect($server) != NOERR) {
return;
}
$sql = sprintf ('SELECT COUNT(*)
FROM tagente_modulo
WHERE id_agente = %d
AND disabled = 0', $id_agent);
$total_modules = db_get_sql ($sql);
metaconsole_restore_db();
}
else {
$total_modules = db_get_sql ($sql);
}
if ($bad_modules === false)
$size_bad_modules = 0;
else
$size_bad_modules = sizeof ($bad_modules);
// Modules down
if ($size_bad_modules > 0 && (!$metaconsole || !$strict_user)) {
echo '<strong>'.__('Monitors down').':</strong> '.$size_bad_modules.' / '.$total_modules;
echo '<ul>';
foreach ($bad_modules as $module) {
echo '<li>';
echo ui_print_truncate_text($module['nombre'], 'module_small');
echo '</li>';
}
echo '</ul>';
}
// Alerts (if present)
$sql = sprintf ('SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente
WHERE tagente.id_agente = %d
AND tagente.disabled = 0
AND tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
AND talert_template_modules.times_fired > 0 ',
$id_agent);
if ($metaconsole) {
if (metaconsole_connect($server) != NOERR) {
return;
}
if ($bad_modules === false)
$size_bad_modules = 0;
else
$size_bad_modules = sizeof ($bad_modules);
$alert_modules = db_get_sql ($sql);
metaconsole_restore_db();
}
else {
$alert_modules = db_get_sql ($sql);
}
if ($alert_modules > 0 && (!$metaconsole || !$strict_user)) {
$sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired
FROM talert_template_modules, tagente_modulo, tagente
WHERE tagente.id_agente = %d
AND tagente.disabled = 0
AND tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
AND talert_template_modules.times_fired > 0 ',
$id_agent);
if ($metaconsole) {
if (metaconsole_connect($server) != NOERR) {
return;
// Modules down
if ($size_bad_modules > 0) {
echo '<strong>'.__('Monitors down').':</strong> '.$size_bad_modules.' / '.$total_modules;
echo '<ul>';
foreach ($bad_modules as $module) {
echo '<li>';
echo ui_print_truncate_text($module['nombre'], 'module_small');
echo '</li>';
}
echo '</ul>';
}
// Alerts (if present)
$sql = sprintf ('SELECT COUNT(talert_template_modules.id)
FROM talert_template_modules, tagente_modulo, tagente
WHERE tagente.id_agente = %d
AND tagente.disabled = 0
AND tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
AND talert_template_modules.times_fired > 0 ',
$id_agent);
$alert_modules = (int) db_get_sql ($sql);
if ($alert_modules > 0) {
$sql = sprintf ('SELECT tagente_modulo.nombre, talert_template_modules.last_fired
FROM talert_template_modules, tagente_modulo, tagente
WHERE tagente.id_agente = %d
AND tagente.disabled = 0
AND tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.disabled = 0
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
AND talert_template_modules.times_fired > 0 ',
$id_agent);
$alerts = db_get_all_rows_sql ($sql);
metaconsole_restore_db();
echo '<strong>'.__('Alerts fired').':</strong>';
echo "<ul>";
foreach ($alerts as $alert_item) {
echo '<li>';
echo ui_print_truncate_text($alert_item['nombre']).' -> ';
echo human_time_comparation($alert_item['last_fired']);
echo '</li>';
}
echo '</ul>';
}
else {
$alerts = db_get_all_rows_sql ($sql);
}
echo '<strong>'.__('Alerts fired').':</strong>';
echo "<ul>";
foreach ($alerts as $alert_item) {
echo '<li>';
echo ui_print_truncate_text($alert_item['nombre']).' -> ';
echo human_time_comparation($alert_item['last_fired']);
echo '</li>';
}
echo '</ul>';
}
return;

View File

@ -223,7 +223,7 @@ $date_from = (string)get_parameter('date_from', '');
$date_to = (string)get_parameter('date_to', '');
$server_id = (int)get_parameter('server_id', 0);
$text_agent = (string) get_parameter("text_agent", __("All"));
$text_agent = (string) get_parameter("text_agent");
$id_agent = get_parameter('id_agent', 0);
if ($id_agent != 0) {
$text_agent = db_get_value('nombre', 'tagente', 'id_agente', $id_agent);

View File

@ -17,15 +17,14 @@
// Load global vars
global $config;
require_once ($config['homedir']. "/include/functions_events.php"); //Event processing functions
require_once ($config['homedir']. "/include/functions_alerts.php"); //Alerts processing functions
require_once ($config['homedir']. "/include/functions.php");
require_once($config['homedir'] . "/include/functions_agents.php"); //Agents funtions
require_once($config['homedir'] . "/include/functions_users.php"); //Users functions
require_once ($config['homedir'] . '/include/functions_groups.php');
require_once ($config["homedir"] . '/include/functions_graph.php');
require_once ($config["homedir"] . '/include/functions_tags.php');
require_once ($config['homedir'] . "/include/functions.php");
require_once ($config['homedir'] . "/include/functions_events.php"); //Event processing functions
require_once ($config['homedir'] . "/include/functions_alerts.php"); //Alerts processing functions
require_once ($config['homedir'] . "/include/functions_agents.php"); //Agents funtions
require_once ($config['homedir'] . "/include/functions_users.php"); //Users functions
require_once ($config['homedir'] . "/include/functions_groups.php");
require_once ($config["homedir"] . "/include/functions_graph.php");
require_once ($config["homedir"] . "/include/functions_tags.php");
check_login ();
@ -36,8 +35,6 @@ if (! check_acl ($config["id_user"], 0, "ER")) {
return;
}
$strict_user = db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
if(defined('METACONSOLE')){
$jump = '&nbsp;&nbsp;';
}
@ -162,7 +159,7 @@ require('events.build_query.php');
$id_name = get_parameter('id_name', '');
if(!defined("METACONSOLE"))
if (!defined("METACONSOLE"))
echo "<br>";
@ -174,7 +171,7 @@ $update_pressed = (int) !empty($update_pressed);
if ($update_pressed || $open_filter) {
$open_filter = true;
}
if(!defined("METACONSOLE")){
if (!defined("METACONSOLE")) {
$table = html_get_predefined_table('transparent', 2);
$table->styleTable = 'width: 23px; float: right; background: #ECECEC;';
$table->width = '98%';
@ -275,7 +272,7 @@ $table->width = '98%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->class = 'databox';
if(defined('METACONSOLE')){
if (defined('METACONSOLE')) {
$table->width = '100%';
$table->cellspacing = 0;
$table->cellpadding = 0;
@ -283,7 +280,7 @@ if(defined('METACONSOLE')){
}
$table->styleTable = 'font-weight: bold; color: #555; text-align:left;';
if(!defined("METACONSOLE"))
if (!defined("METACONSOLE"))
$table->style[0] = 'width: 50%; width:50%;';
$data = array();
$table->rowid[3] = 'update_filter_row1';
@ -330,7 +327,7 @@ $tabletags_with->cellspacing = 4;
$tabletags_with->cellpadding = 4;
$tabletags_with->class = 'noshadow';
$tabletags_with->styleTable = 'border: 0px;';
if(defined('METACONSOLE')){
if (defined('METACONSOLE')) {
$tabletags_with->width = '100%';
$tabletags_with->class = 'nobady';
$tabletags_with->cellspacing = 0;
@ -340,7 +337,7 @@ if(defined('METACONSOLE')){
$data = array();
if(!defined("METACONSOLE"))
if (!defined("METACONSOLE"))
$data[0] = html_print_select ($tags_select_with, 'select_with', '', '', '', 0,
true, true, true, '', false, 'width: 120px; height: 70px;') . '<br>';
else
@ -365,7 +362,7 @@ $tabletags_without->width = '100%';
$tabletags_without->cellspacing = 4;
$tabletags_without->cellpadding = 4;
$tabletags_without->class = 'noshadow';
if(defined('METACONSOLE')){
if (defined('METACONSOLE')) {
$tabletags_without->width = '100%';
$tabletags_without->class = 'nobady';
$tabletags_without->cellspacing = 0;
@ -374,7 +371,7 @@ if(defined('METACONSOLE')){
$tabletags_without->styleTable = 'border: 0px;';
$data = array();
if(!defined("METACONSOLE"))
if (!defined("METACONSOLE"))
$data[0] = html_print_select ($tags_select_without, 'select_without', '', '', '', 0,
true, true, true, '', false, 'width: 120px; height: 70px;') . '<br>';
else
@ -385,7 +382,7 @@ $data[1] = html_print_image('images/darrowright.png', true, array('id' => 'butto
$data[1] .= html_print_input_hidden('tag_without', $tag_without_base64, true);
$data[1] .= '<br><br>' . html_print_image('images/darrowleft.png', true, array('id' => 'button-remove_without', 'style' => 'cursor: pointer;', 'title' => __('Remove')));
if(!defined("METACONSOLE"))
if (!defined("METACONSOLE"))
$data[2] = html_print_select ($tag_without_temp, 'tag_without_temp', array(), '', '',
0, true, true, true, '', false, "width: 120px; height: 70px;");
else
@ -399,11 +396,11 @@ $tabletags_without->rowclass[] = '';
// EVENTS FILTER
// Table for filter controls
if(defined('METACONSOLE')){
if (defined('METACONSOLE')) {
$events_filter = '<form id="form_filter" class="filters_form" method="post" action="index.php?sec=eventos&amp;sec2=operation/events/events&amp;refr='.
(int)get_parameter("refr", 0) .'&amp;pure='.$config["pure"].'&amp;section=' . $section . '&amp;history='.(int)$history.'">';
}
else{
else {
$events_filter = '<form id="form_filter" method="post" action="index.php?sec=eventos&amp;sec2=operation/events/events&amp;refr='.
(int)get_parameter("refr", 0) .'&amp;pure='.$config["pure"].'&amp;section=' . $section . '&amp;history='.(int)$history.'">';
}
@ -511,7 +508,7 @@ $table_advanced->data[] = $data;
$table_advanced->rowclass[] = '';
$data = array();
if(defined('METACONSOLE'))
if (defined('METACONSOLE'))
{
$data[0] = '<fieldset class="" style="width: 310px;">' .
'<legend>' .
@ -526,7 +523,7 @@ if(defined('METACONSOLE'))
html_print_table($tabletags_without, true) .
'</fieldset>';
}
else{
else {
$data[0] = '<fieldset class="databox" style="width: 310px;">' .
'<legend>' .
__('Events with following tags') .
@ -550,7 +547,7 @@ $table->width = '100%';
$table->cellspacing = 4;
$table->cellpadding = 4;
$table->class = 'databox';
if (defined('METACONSOLE')){
if (defined('METACONSOLE')) {
$table->width = '96%';
$table->class = 'databox_filters';
}
@ -617,7 +614,7 @@ if (check_acl ($config["id_user"], 0, "EW")) {
$data[0] .= '<a href="javascript:" onclick="show_save_filter_dialog();">' .
html_print_image("images/disk.png", true, array("border" => '0', "title" => __('Save filter'), "alt" => __('Save filter'))) . '</a> &nbsp;';
}
if(defined("METACONSOLE")){
if (defined("METACONSOLE")) {
$data[0] .= '<a href="javascript:" onclick="show_load_filter_dialog();">' .
html_print_image("images/load.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . '</a> &nbsp;';
$data[0] .= '<a id="events_graph_link" href="javascript: show_events_graph_dialog()">' .
@ -626,7 +623,7 @@ if(defined("METACONSOLE")){
else
$data[0] .= '<a href="javascript:" onclick="show_load_filter_dialog();">' .
html_print_image("images/load.png", true, array("border" => '0', "title" => __('Load filter'), "alt" => __('Load filter'))) . '</a> <br />';
if(defined("METACONSOLE")){
if (defined("METACONSOLE")) {
if (empty($id_name)) {
$data[0] .= '<div id="filter_loaded_span" style="font-weight: normal">[' .
__('No filter loaded') .
@ -638,7 +635,7 @@ if(defined("METACONSOLE")){
']</div>';
}
}
else{
else {
if (empty($id_name)) {
$data[0] .= '<span id="filter_loaded_span" style="font-weight: normal">[' .
__('No filter loaded') .

View File

@ -108,13 +108,7 @@ switch ($tab) {
break;
}
if (defined('METACONSOLE')) {
if ($strict_acl)
$header_sub_title = '';
ui_meta_print_header($header_title, $header_sub_title, $tabs);
}
else{
if (!defined('METACONSOLE')) {
if (!$strict_acl)
$header_title = $header_title ." - ". $header_sub_title;
@ -154,25 +148,24 @@ $table->rowspan[][count($row)-1] = 2;
$table->data[] = $row;
// Module filter
$module_status_arr = array();
$module_status_arr[-1] = __('All'); //default
$module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal');
$module_status_arr[AGENT_MODULE_STATUS_WARNING] = __('Warning');
$module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical');
$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
if (!defined('METACONSOLE')) {
// Module filter
$module_status_arr = array();
$module_status_arr[-1] = __('All'); //default
$module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal');
$module_status_arr[AGENT_MODULE_STATUS_WARNING] = __('Warning');
$module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical');
$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown');
$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init');
$row = array();
$row[] = __('Module status');
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
$row[] = __('Search module');
if (defined('METACONSOLE'))
$row[] = html_print_input_text("search_module", $search_module, '', 70, 30, true);
else
$row = array();
$row[] = __('Module status');
$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true);
$row[] = __('Search module');
$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true);
$table->data[] = $row;
$table->data[] = $row;
}
if (defined('METACONSOLE')) {
$table->width = "96%";

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 6.0dev
%define release 150424
%define release 150427
# 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 150424
%define release 150427
%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','PD150424'),
('db_scheme_build','PD150427'),
('show_unknown','0'),
('show_lastalerts','1'),
('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 6.0dev-150424
Version: 6.0dev-150427
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-150424"
pandora_version="6.0dev-150427"
package_cpan=0
package_pandora=1

View File

@ -101,6 +101,9 @@ sub pandora_startup () {
# Generate the encryption key after reading the passphrase.
$Config{"encryption_key"} = enterprise_hook('pandora_get_encryption_key', [\%Config, $Config{"encryption_passphrase"}]);
# Update the agent cache.
enterprise_hook('update_agent_cache', [\%Config, $DBH]) if ($Config{'metaconsole_agent_cache'} == 1);
pandora_audit (\%Config, 'Pandora FMS Server Daemon starting', 'SYSTEM', 'System', $DBH);
# Load servers
@ -297,7 +300,7 @@ sub pandora_server_tasks ($) {
logger ($pa_config, "Updating module status and fired alert counts for agent " . $agent->{'nombre'}, 10);
if ($agent->{'update_module_count'} == 1) {
pandora_update_agent_module_count ($dbh, $agent->{'id_agente'});
pandora_update_agent_module_count ($pa_config, $dbh, $agent->{'id_agente'});
}
if ($agent->{'update_alert_count'} == 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 = "150424";
my $pandora_build = "150427";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash
@ -159,6 +159,9 @@ sub pandora_get_sharedconfig ($$) {
# Pandora FMS Console's attachment directory
$pa_config->{"attachment_dir"} = pandora_get_tconfig_token ($dbh, 'attachment_store', '/var/www/pandora_console/attachment');
# Metaconsole agent cache.
$pa_config->{"metaconsole_agent_cache"} = pandora_get_tconfig_token ($dbh, 'metaconsole_agent_cache', 0);
}
##########################################################################

View File

@ -2608,7 +2608,7 @@ sub pandora_create_module_from_hash ($$$) {
sub pandora_update_module_from_hash ($$$$$) {
my ($pa_config, $parameters, $where_column, $where_value, $dbh) = @_;
my $module_id = db_process_update($dbh, 'tagente_modulo', $parameters, $where_column, $where_value);
my $module_id = db_process_update($dbh, 'tagente_modulo', $parameters, {$where_column => $where_value});
return $module_id;
}
@ -2618,7 +2618,7 @@ sub pandora_update_module_from_hash ($$$$$) {
sub pandora_update_table_from_hash ($$$$$$) {
my ($pa_config, $parameters, $where_column, $where_value, $table, $dbh) = @_;
my $module_id = db_process_update($dbh, $table, $parameters, $where_column, $where_value);
my $module_id = db_process_update($dbh, $table, $parameters, {$where_column => $where_value});
return $module_id;
}
@ -4663,24 +4663,8 @@ sub pandora_set_event_storm_protection ($) {
##########################################################################
# Update the module status count of an agent.
##########################################################################
sub pandora_update_agent_count ($$) {
my ($dbh, $agent_id) = @_;
db_do ($dbh, 'UPDATE tagente SET update_module_count=0,
normal_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id . ' AND estado=0),
critical_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id . ' AND estado=1),
warning_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id . ' AND estado=2),
unknown_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id . ' AND estado=3),
notinit_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id . ' AND estado=4),
total_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id .
') WHERE id_agente = ' . $agent_id);
}
##########################################################################
# Update the module status count of an agent.
##########################################################################
sub pandora_update_agent_module_count ($$) {
my ($dbh, $agent_id) = @_;
sub pandora_update_agent_module_count ($$$) {
my ($pa_config, $dbh, $agent_id) = @_;
db_do ($dbh, 'UPDATE tagente SET update_module_count=0,
normal_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.disabled=0 AND tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id . ' AND estado=0),
@ -4690,6 +4674,9 @@ sub pandora_update_agent_module_count ($$) {
notinit_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.disabled=0 AND tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id . ' AND estado=4),
total_count=(SELECT COUNT(*) FROM tagente_modulo, tagente_estado WHERE tagente_modulo.disabled=0 AND tagente_modulo.id_agente_modulo=tagente_estado.id_agente_modulo AND tagente_modulo.id_agente=' . $agent_id .
') WHERE id_agente = ' . $agent_id);
# Sync the agent cache every time the module count is updated.
enterprise_hook('update_agent_cache', [$pa_config, $dbh, $agent_id]) if ($pa_config->{'metaconsole_agent_cache'} == 1);
}
##########################################################################

View File

@ -765,17 +765,20 @@ sub db_process_insert($$$$;@) {
########################################################################
## SQL update.
########################################################################
sub db_process_update($$$$$;@) {
my ($dbh, $table, $parameters, $where_column, $where_value, @values) = @_;
sub db_process_update($$$$) {
my ($dbh, $table, $parameters, $conditions) = @_;
my @columns_array = keys %$parameters;
my @values_array = values %$parameters;
my @where_columns = keys %$conditions;
my @where_values = values %$conditions;
if (!defined($table) || $#columns_array == -1) {
if (!defined($table) || $#columns_array == -1 || $#where_columns == -1) {
return -1;
exit;
}
# VALUES...
my $fields = '';
for (my $i = 0; $i <= $#values_array; $i++) {
if (!defined($values_array[$i])) {
@ -787,12 +790,23 @@ sub db_process_update($$$$$;@) {
$fields = $fields .
" " . $RDBMS_QUOTE . "$columns_array[$i]" . $RDBMS_QUOTE . " = ?";
}
push(@values_array, $where_value);
# WHERE...
my $where = '';
for (my $i = 0; $i <= $#where_columns; $i++) {
if (!defined($where_values[$i])) {
$where_values[$i] = '';
}
if ($i > 0 && $i <= $#where_values) {
$where = $where.' AND ';
}
$where = $where .
" " . $RDBMS_QUOTE . "$where_columns[$i]" . $RDBMS_QUOTE . " = ?";
}
my $res = db_update ($dbh, "UPDATE $table
SET $fields
WHERE $where_column = ?", @values_array);
WHERE $where", @values_array, @where_values);
return $res;
}

View File

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

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 6.0dev
%define release 150424
%define release 150427
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 PS150424";
my $version = "6.0dev PS150427";
# Pandora server configuration
my %conf;

View File

@ -35,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "6.0dev PS150424";
my $version = "6.0dev PS150427";
# save program name for logging
my $progname = basename($0);
@ -538,7 +538,7 @@ sub pandora_validate_event_id ($$$) {
sub pandora_update_user_from_hash ($$$$) {
my ($parameters, $where_column, $where_value, $dbh) = @_;
my $user_id = db_process_update($dbh, 'tusuario', $parameters, $where_column, $where_value);
my $user_id = db_process_update($dbh, 'tusuario', $parameters, {$where_column => $where_value});
return $user_id;
}
@ -548,7 +548,7 @@ sub pandora_update_user_from_hash ($$$$) {
sub pandora_update_alert_template_from_hash ($$$$) {
my ($parameters, $where_column, $where_value, $dbh) = @_;
my $template_id = db_process_update($dbh, 'talert_templates', $parameters, $where_column, $where_value);
my $template_id = db_process_update($dbh, 'talert_templates', $parameters, {$where_column => $where_value});
return $template_id;
}
@ -662,7 +662,7 @@ sub pandora_create_special_day_from_hash ($$$) {
sub pandora_update_special_day_from_hash ($$$$) {
my ($parameters, $where_column, $where_value, $dbh) = @_;
my $special_day_id = db_process_update($dbh, 'talert_special_days', $parameters, $where_column, $where_value);
my $special_day_id = db_process_update($dbh, 'talert_special_days', $parameters, {$where_column => $where_value});
return $special_day_id;
}
@ -3521,7 +3521,7 @@ sub cli_stop_downtime () {
my $parameters->{'date_to'} = time;
db_process_update($dbh, 'tplanned_downtime', $parameters, 'id', $downtime_id);
db_process_update($dbh, 'tplanned_downtime', $parameters, {'id' => $downtime_id});
}
###############################################################################
@ -3634,7 +3634,7 @@ sub pandora_get_event_name($$) {
sub pandora_update_event_from_hash ($$$$) {
my ($parameters, $where_column, $where_value, $dbh) = @_;
my $event_id = db_process_update($dbh, 'tevento', $parameters, $where_column, $where_value);
my $event_id = db_process_update($dbh, 'tevento', $parameters, {$where_column => $where_value});
return $event_id;
}