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

This commit is contained in:
mdtrooper 2014-10-01 11:18:25 +02:00
commit 6fa2cab7c6
69 changed files with 63009 additions and 50723 deletions

View File

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

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 5.1SP1
%define release 140930
%define release 141001
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{140930}
{141001}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("5.1SP1(Build 140930)")
#define PANDORA_VERSION ("5.1SP1(Build 141001)")
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", "(5.1SP1(Build 140930))"
VALUE "ProductVersion", "(5.1SP1(Build 141001))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 5.1SP1-140930
Version: 5.1SP1-141001
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="5.1SP1-140930"
pandora_version="5.1SP1-141001"
package_pear=0
package_pandora=1

View File

@ -125,6 +125,7 @@ switch ($action) {
case 'top_n':
case 'exception':
case 'general':
case 'network_interfaces_report':
$get_data_editor = true;
break;
default:
@ -420,6 +421,11 @@ switch ($action) {
$description = $item['description'];
$group = $item['id_group'];
break;
case 'network_interfaces_report':
$description = $item['description'];
$group = $item['id_group'];
$period = $item['period'];
break;
case 'top_n':
$description = $item['description'];
$period = $item['period'];
@ -2147,6 +2153,11 @@ function chooseType() {
$("#row_servers").show();
$("#row_description").show();
break;
case 'network_interfaces_report':
$("#row_group").show();
$("#row_description").show();
$("#row_period").show();
break;
case 'top_n':
$("#row_description").show();
$("#row_period").show();

View File

@ -22,7 +22,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC140930';
$build_version = 'PC141001';
$pandora_version = 'v5.1SP1';
// Do not overwrite default timezone set if defined.

View File

@ -2144,4 +2144,157 @@ function agents_update_gis($idAgente, $latitude, $longitude, $altitude,
return (bool)$return;
}
/**
* Returns a list with network interfaces data by agent
*
* @param array Agents with the columns 'id_agente', 'nombre' and 'id_grupo'.
* @param mixed A filter to search the agents if the first parameter is false.
*
* @return array A list of network interfaces information by agents.
*/
function agents_get_network_interfaces ($agents = false, $agents_filter = false) {
if ($agents === false) {
$filter = false;
if ($agents_filter !== false) {
$filter = $agents_filter;
}
$fields = array(
'id_agente',
'nombre',
'id_grupo'
);
$agents = agents_get_agents($filter, $fields);
}
$ni_by_agents = array();
foreach ($agents as $agent) {
$agent_id = $agent['id_agente'];
$agent_group_id = $agent['id_grupo'];
$agent_name = $agent['nombre'];
$agent_interfaces = array();
$columns = array(
"id_agente_modulo",
"nombre",
"descripcion",
"ip_target"
);
$filter = array(
"id_agente" => $agent_id,
"id_tipo_modulo" => (int) db_get_value("id_tipo", "ttipo_modulo", "nombre", "remote_snmp_proc"),
"disabled" => 0
);
$modules = agents_get_modules($agent_id, $columns, $filter, true, false);
if (!empty($modules)) {
$interfaces = array();
foreach ($modules as $module) {
$module_name = (string) $module['nombre'];
// Trying to get the interface name from the module name
if (preg_match ("/_(.+)$/", $module_name, $matches)) {
if ($matches[1]) {
$interface_name = $matches[1];
$interface_name_escaped = str_replace("/", "\/", $interface_name);
if (!isset($interfaces[$interface_name])
|| (isset($interfaces[$interface_name])
&& preg_match ("/^ifOperStatus_$interface_name_escaped$/i", $module_name, $matches))) {
$interfaces[$interface_name] = $module;
}
}
}
}
unset($modules);
foreach ($interfaces as $interface_name => $module) {
$interface_name_escaped = str_replace("/", "\/", $interface_name);
$module_id = $module['id_agente_modulo'];
$module_name = $module['nombre'];
$module_description = $module['descripcion'];
$db_status = modules_get_agentmodule_status($module_id);
$module_value = modules_get_last_value ($module_id);
modules_get_status($module_id, $db_status, $module_value, $status, $title);
$status_image = ui_print_status_image($status, $title, true);
$ip_target = "";
if (isset($module['ip_target']) && !empty($module['ip_target'])) {
$ip_target = $module['ip_target'];
}
// Trying to get something like an IP from the description
else if (preg_match ("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $module_description, $matches)
|| preg_match ("/(((?=(?>.*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:?)|\2))(?4){5}((?4){2}|(25[0-5]|
(2[0-4]|1\d|[1-9])?\d)(\.(?7)){3})/i", $module_description, $matches)) {
if ($matches[0]) {
$ip_target = $matches[0];
}
}
$mac = "";
// Trying to get something like a mac from the description
if (preg_match ("/([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})/i", $module_description, $matches)) {
if ($matches[0]) {
$mac = $matches[0];
}
}
// Get the ifInOctets and ifOutOctets modules of the interface
$columns = array(
"id_agente_modulo",
"nombre"
);
$interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE 'if%Octets_$interface_name'");
if (!empty($interface_traffic_modules) && count($interface_traffic_modules) >= 2) {
$interface_traffic_modules_aux = array('in' => '', 'out' => '');
foreach ($interface_traffic_modules as $interface_traffic_module) {
$interface_name_escaped = str_replace("/", "\/", $interface_name);
if (preg_match ("/^if(.+)Octets_$interface_name_escaped$/i", $interface_traffic_module['nombre'], $matches)) {
if (strtolower($matches[1]) == 'in') {
$interface_traffic_modules_aux['in'] = $interface_traffic_module['id_agente_modulo'];
}
elseif (strtolower($matches[1]) == 'out') {
$interface_traffic_modules_aux['out'] = $interface_traffic_module['id_agente_modulo'];
}
}
}
if (!empty($interface_traffic_modules_aux['in']) && !empty($interface_traffic_modules_aux['out'])) {
$interface_traffic_modules = $interface_traffic_modules_aux;
}
else {
$interface_traffic_modules = false;
}
}
else {
$interface_traffic_modules = false;
}
$agent_interfaces[$interface_name] = array();
$agent_interfaces[$interface_name]['status_image'] = $status_image;
$agent_interfaces[$interface_name]['status_module_id'] = $module_id;
$agent_interfaces[$interface_name]['status_module_name'] = $module_name;
$agent_interfaces[$interface_name]['ip'] = $ip_target;
$agent_interfaces[$interface_name]['mac'] = $mac;
if ($interface_traffic_modules !== false) {
$agent_interfaces[$interface_name]['traffic'] = array();
$agent_interfaces[$interface_name]['traffic']['in'] = $interface_traffic_modules['in'];
$agent_interfaces[$interface_name]['traffic']['out'] = $interface_traffic_modules['out'];
}
}
}
if (!empty($agent_interfaces)) {
$ni_by_agents[$agent_id] = array();
$ni_by_agents[$agent_id]['name'] = $agent_name;
$ni_by_agents[$agent_id]['group'] = $agent_group_id;
$ni_by_agents[$agent_id]['interfaces'] = $agent_interfaces;
}
}
return $ni_by_agents;
}
?>

View File

@ -30,6 +30,7 @@ include_once($config['homedir'] . "/include/functions_network_components.php");
include_once($config['homedir'] . "/include/functions_netflow.php");
include_once($config['homedir'] . "/include/functions_servers.php");
enterprise_include_once ('include/functions_local_components.php');
enterprise_include_once ('include/functions_events.php');
/**
* Parse the "other" parameter.
@ -206,6 +207,16 @@ function api_get_test() {
echo "OK,$pandora_version,$build_version";
}
// Returs the string OK if a connection to the event replication DB can be established.
function api_get_test_event_replication_db() {
$status = enterprise_hook('events_test_replication_db', array());
if ($status === ENTERPRISE_NOT_HOOK) {
echo 'ERR';
return;
}
echo $status;
}
//-------------------------DEFINED OPERATIONS FUNCTIONS-----------------
function api_get_groups($thrash1, $thrash2, $other, $returnType, $user_in_db) {
if ($other['type'] == 'string') {
@ -4755,7 +4766,7 @@ function otherParameter2Filter($other, $return_as_array = false) {
$filter['tag'] = $other['data'][14];
}
else {
$filterString .= " AND tags LIKE '%" . $other['data'][14]."%'";
$filterString .= " AND tags LIKE '" . $other['data'][14]."'";
}
}
@ -5667,7 +5678,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db
//Search by tag
if ($tag != "") {
$sql_post .= " AND tags LIKE '%" . io_safe_input($tag) . "%'";
$sql_post .= " AND tags LIKE '" . io_safe_input($tag) . "'";
}
//Inject the raw sql

View File

@ -163,7 +163,7 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$stacked = null, $return = false, $date = 0, $only_image = false,
$background_color = 'white', $modules_param = array(), $homeurl = '',
$name_list = array(), $unit_list = array(), $show_last = true,
$show_max = true, $show_min = true, $show_avg = true) {
$show_max = true, $show_min = true, $show_avg = true, $ttl = 1) {
global $config;
@ -222,7 +222,7 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$date,
$only_image,
$homeurl,
1,
$ttl,
false,
false,
$background_color,

View File

@ -5051,6 +5051,9 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
</tr>
</table>";
break;
case 'network_interfaces_report':
reporting_network_interfaces_table($content, $report, $mini, $item_title, $table);
break;
case 'general':
if (empty($item_title)) {
@ -7567,4 +7570,155 @@ function reporting_tiny_stats ($counts_info, $return = false, $type = 'agent', $
echo $out;
}
}
function reporting_network_interfaces_table ($content, $report, $mini, $item_title = "", &$table = null, &$pdf = null) {
global $config;
include_once($config['homedir'] . "/include/functions_custom_graphs.php");
if (empty($item_title)) {
$group_name = groups_get_name($content['id_group']);
$item_title = __('Network interfaces') . " - " . sprintf(__('Group "%s"'), $group_name);
}
$is_html = $table !== null;
$is_pdf = $pdf !== null;
$ttl = $is_pdf ? 2 : 1;
$graph_width = 600;
$graph_height = 200;
$datetime = $report['datetime'];
$period = $content['period'];
if ($is_pdf) {
pdf_header_content($pdf, $content, $report, $item_title, false, $content["description"]);
}
else if ($is_html) {
reporting_header_content($mini, $content, $report, $table, $item_title);
//RUNNING
$table->style[1] = 'text-align: right';
// Put description at the end of the module (if exists)
$table->colspan[0][1] = 2;
$next_row = 1;
if ($content["description"] != "") {
$table->colspan[$next_row][0] = 3;
$next_row++;
$data_desc = array();
$data_desc[0] = $content["description"];
array_push ($table->data, $data_desc);
}
}
$network_interfaces_by_agents = agents_get_network_interfaces(false, array('id_grupo' => $content['id_group']));
if (empty($network_interfaces_by_agents)) {
$data = array();
$table->colspan[$next_row][0] = 3;
$next_row++;
$data[0] = __('The group has no agents or none of the agents has any network interface');
array_push ($table->data, $data);
$slas = array();
return;
}
else {
foreach ($network_interfaces_by_agents as $agent_id => $agent) {
$table_agent = new StdCLass();
$table_agent->width = '100%';
$table_agent->data = array();
$table_agent->head = array();
$table_agent->head[0] = sprintf(__("Agent '%s'"), $agent['name']);
$table_agent->headstyle = array();
$table_agent->headstyle[0] = 'font-size: 16px;';
$table_agent->style[0] = 'text-align: center';
if ($is_pdf) {
$table_agent->class = 'table_sla table_beauty';
$table_agent->headstyle[0] = 'background: #373737; color: #FFF; display: table-cell; font-size: 16px; border: 1px solid grey';
}
$table_agent->data['interfaces'] = "";
foreach ($agent['interfaces'] as $interface_name => $interface) {
$table_interface = new StdClass();
$table_interface->width = '100%';
$table_interface->data = array();
$table_interface->rowstyle = array();
$table_interface->head = array();
$table_interface->cellstyle = array();
$table_interface->title = sprintf(__("Interface '%s' throughput graph"), $interface_name);
$table_interface->head['ip'] = __('IP');
$table_interface->head['mac'] = __('Mac');
$table_interface->head['status'] = __('Actual status');
$table_interface->style['ip'] = 'text-align: left';
$table_interface->style['mac'] = 'text-align: left';
$table_interface->style['status'] = 'width: 150px; text-align: center';
if ($is_pdf) {
$table_interface->class = 'table_sla table_beauty';
$table_interface->titlestyle = 'background: #373737; color: #FFF; display: table-cell; font-size: 12px; border: 1px solid grey';
$table_interface->headstyle['ip'] = 'text-align: left; background: #666; color: #FFF; display: table-cell; font-size: 11px; border: 1px solid grey';
$table_interface->headstyle['mac'] = 'text-align: left; background: #666; color: #FFF; display: table-cell; font-size: 11px; border: 1px solid grey';
$table_interface->headstyle['status'] = 'background: #666; color: #FFF; display: table-cell; font-size: 11px; border: 1px solid grey';
$table_interface->style['ip'] = 'text-align: left; display: table-cell; font-size: 10px;';
$table_interface->style['mac'] = 'text-align: left; display: table-cell; font-size: 10px;';
$table_interface->style['status'] = 'text-align: center; display: table-cell; font-size: 10px;';
}
$data = array();
$data['ip'] = !empty($interface['ip']) ? $interface['ip'] : "--";
$data['mac'] = !empty($interface['mac']) ? $interface['mac'] : "--";
$data['status'] = $interface['status_image'];
$table_interface->data['data'] = $data;
if (!empty($interface['traffic'])) {
$only_image = !(bool)$config['flash_charts'] || $is_pdf ? true : false;
$graph = custom_graphs_print(0,
$graph_height,
$graph_width,
$period,
null,
true,
$date,
$only_image,
'white',
array_values($interface['traffic']),
$config['homeurl'],
array_keys($interface['traffic']),
array_fill(0, count($interface['traffic']),"bytes/s"),
false,
true,
true,
true,
$ttl);
$table_interface->data['graph'] = $graph;
$table_interface->colspan['graph'][0] = count($table_interface->head);
$table_interface->cellstyle['graph'][0] = 'text-align: center;';
}
$table_agent->data['interfaces'] .= html_print_table($table_interface, true);
$table_agent->colspan[$interface_name][0] = 3;
}
if ($is_html) {
$table->data[$agent_id] = html_print_table($table_agent, true);
$table->colspan[$agent_id][0] = 3;
}
else if ($is_pdf) {
$html = html_print_table($table_agent, true);
$pdf->addHTML($html);
}
}
}
}
?>

View File

@ -574,6 +574,8 @@ function reports_get_report_types ($template = false, $not_editor = false) {
}
$types['top_n'] = array('optgroup' => __('Grouped'),
'name' => __('Top n'));
$types['network_interfaces_report'] = array('optgroup' => __('Grouped'),
'name' => __('Network interfaces'));

View File

@ -867,7 +867,7 @@ function tags_get_acl_tags_event_condition($acltags) {
//~ $tags_condition .= sprintf(' OR tags LIKE "%s %%"',io_safe_input($all_tags[$tag]));
//~ $tags_condition .= sprintf(' OR tags LIKE "%%,%s %%"',io_safe_input($all_tags[$tag]));
$tags_condition .= sprintf('tags LIKE "%%%s%%"',io_safe_input($all_tags[$tag]));
$tags_condition .= sprintf('tags LIKE "%s"',io_safe_input($all_tags[$tag]));
}
// If there is not tag condition ignore

View File

@ -112,7 +112,12 @@ function treeview_printModuleTable($id_module, $server_data = false) {
$tags = array();
}
$user_tags = tags_get_user_tags($config["id_user"]);
foreach ($tags as $k => $v) {
if (!array_key_exists($v, $user_tags)) { //only show user's tags.
unset($tags[$k]);
} else {
$tag_name = tags_get_name($v);
if (empty($tag_name)) {
unset($tags[$k]);
@ -121,6 +126,7 @@ function treeview_printModuleTable($id_module, $server_data = false) {
$tags[$k] = $tag_name;
}
}
}
if (empty($tags)) {
$tags = '<i>' . __('N/A') . '</i>';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,7 +63,7 @@
<div style='height: 10px'>
<?php
$version = '5.1SP1';
$build = '140930';
$build = '141001';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -187,7 +187,7 @@ if (!empty($tag_with)) {
foreach ($tag_with as $id_tag) {
if ($first) $first = false;
else $sql_post .= " OR ";
$sql_post .= "tags LIKE '%" . tags_get_name($id_tag) . "%'";
$sql_post .= "tags LIKE '" . tags_get_name($id_tag) . "'";
}
$sql_post .= ' ) ';
}
@ -198,7 +198,7 @@ if (!empty($tag_without)) {
if ($first) $first = false;
else $sql_post .= " AND ";
$sql_post .= "tags NOT LIKE '%" . tags_get_name($id_tag) . "%'";
$sql_post .= "tags NOT LIKE '" . tags_get_name($id_tag) . "'";
}
$sql_post .= ' ) ';
}

View File

@ -567,7 +567,7 @@ else {
if (!empty($result)) {
$graph = '<div style="width: 350px; margin: 0 auto;">' .
grafico_eventos_grupo(400, 250,
grafico_eventos_grupo(350, 185,
rawurlencode ($sql_post), $meta, $history) .
'</div>';
html_print_div(array('id' => 'events_graph',

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 5.1SP1
%define release 140930
%define release 141001
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 5.1SP1
%define release 140930
%define release 141001
%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','5.1SP1'),
('db_scheme_build','PD140930'),
('db_scheme_build','PD141001'),
('show_unknown','0'),
('show_lastalerts','1'),
('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 5.1SP1-140930
Version: 5.1SP1-141001
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="5.1SP1-140930"
pandora_version="5.1SP1-141001"
package_cpan=0
package_pandora=1

View File

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

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 5.1SP1
%define release 140930
%define release 141001
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 5.1SP1
%define release 140930
%define release 141001
Summary: Pandora FMS Server
Name: %{name}

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB;
# version: define current version
my $version = "5.1SP1 PS140930";
my $version = "5.1SP1 PS141001";
# Pandora server configuration
my %conf;

View File

@ -34,7 +34,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "5.1SP1 PS140930";
my $version = "5.1SP1 PS141001";
# save program name for logging
my $progname = basename($0);