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

This commit is contained in:
mdtrooper 2014-09-24 14:36:31 +02:00
commit 146e693285
32 changed files with 772 additions and 514 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 5.1-140923 Version: 5.1-140924
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{140923} {140924}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("5.1(Build 140923)") #define PANDORA_VERSION ("5.1(Build 140924)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

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

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 5.1-140923 Version: 5.1-140924
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

@ -400,12 +400,33 @@ $table->data[$row][1] = html_print_input_text ('networkmap_max_width', $config["
$row++; $row++;
$table->data[$row][0] = __('Fixed header'); $table->data[$row][0] = __('Fixed header');
$table->data[$row][1] = html_print_checkbox('fixed_header', 1, $config['fixed_header'], true); $table->data[$row][1] = __('Yes') . ' ' .
html_print_radio_button ('fixed_header', 1, '', $config["fixed_header"], true) .
'  ';
$table->data[$row][1] .= __('No') . ' ' .
html_print_radio_button ('fixed_header', 0, '', $config["fixed_header"], true);
$row++; $row++;
$table->data[$row][0] = __('Fixed menu'); $table->data[$row][0] = __('Fixed menu');
$table->data[$row][1] = html_print_checkbox('fixed_menu', 1, $config['fixed_menu'], true); $table->data[$row][1] = __('Yes') . ' ' .
html_print_radio_button ('fixed_menu', 1, '', $config["fixed_menu"], true) .
'  ';
$table->data[$row][1] .= __('No') . ' ' .
html_print_radio_button ('fixed_menu', 0, '', $config["fixed_menu"], true);
$row++;
if (!isset($config["short_module_graph_data"]))
$config["short_module_graph_data"] = true;
$table->data[$row][0] = __('Shortened module graph data');
$table->data[$row][0] .= ui_print_help_tip(__('The data number of the module graphs will be rounded and shortened'), true);
$table->data[$row][1] = __('Yes') . ' ' .
html_print_radio_button ('short_module_graph_data', 1, '', $config["short_module_graph_data"], true) .
'  ';
$table->data[$row][1] .= __('No') . ' ' .
html_print_radio_button ('short_module_graph_data', 0, '', $config["short_module_graph_data"], true);
$row++; $row++;

View File

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

View File

@ -447,6 +447,8 @@ function config_update_config () {
$error_update[] = __('Custom graphviz directory'); $error_update[] = __('Custom graphviz directory');
if (!config_update_value ('networkmap_max_width', get_parameter('networkmap_max_width'))) if (!config_update_value ('networkmap_max_width', get_parameter('networkmap_max_width')))
$error_update[] = __('Networkmap max width'); $error_update[] = __('Networkmap max width');
if (!config_update_value ('short_module_graph_data', get_parameter('short_module_graph_data')))
$error_update[] = __('Shortened module graph data');
$interval_values = get_parameter ('interval_values'); $interval_values = get_parameter ('interval_values');

View File

@ -145,14 +145,25 @@ function custom_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGr
* @param $height Height of the returning image. * @param $height Height of the returning image.
* @param $width Width of the returning image. * @param $width Width of the returning image.
* @param $period Period of time to get data in seconds. * @param $period Period of time to get data in seconds.
* @param $stacked Wheter the graph is stacked or not. * @param $stacked Whether the graph is stacked or not.
* @param $return Whether to return an output string or echo now (optional, echo by default). * @param $return Whether to return an output string or echo now (optional, echo by default).
* @param $date Date to start printing the graph * @param $date Date to start printing the graph
* @param bool Wether to show an image instead a interactive chart or not
* @param string Background color
* @param array List of names for the items. Should have the same size as the module list.
* @param bool Show the last value of the item on the list.
* @param bool Show the max value of the item on the list.
* @param bool Show the min value of the item on the list.
* @param bool Show the average value of the item on the list.
*
* @return Mixed
*/ */
function custom_graphs_print($id_graph, $height, $width, $period, function custom_graphs_print($id_graph, $height, $width, $period,
$stacked = null, $return = false, $date = 0, $only_image = false, $stacked = null, $return = false, $date = 0, $only_image = false,
$background_color = 'white', $modules_param = array(), $homeurl = '') { $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) {
global $config; global $config;
@ -214,7 +225,13 @@ function custom_graphs_print($id_graph, $height, $width, $period,
1, 1,
false, false,
false, false,
$background_color); $background_color,
$name_list,
$unit_list,
$show_last,
$show_max,
$show_min,
$show_avg);
if ($return) if ($return)
return $output; return $output;

View File

@ -854,6 +854,12 @@ function graph_get_formatted_date($timestamp, $format1, $format2) {
* @param int Date to start of getting info. * @param int Date to start of getting info.
* @param mixed If is a projection graph this parameter will be module data with prediction data (the projection) * @param mixed If is a projection graph this parameter will be module data with prediction data (the projection)
* or false in other case. * or false in other case.
* @param array List of names for the items. Should have the same size as the module list.
* @param array List of units for the items. Should have the same size as the module list.
* @param bool Show the last value of the item on the list.
* @param bool Show the max value of the item on the list.
* @param bool Show the min value of the item on the list.
* @param bool Show the average value of the item on the list.
* *
* @return Mixed * @return Mixed
*/ */
@ -861,7 +867,9 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$width, $height, $title, $unit_name, $show_events = 0, $width, $height, $title, $unit_name, $show_events = 0,
$show_alerts = 0, $pure = 0, $stacked = 0, $date = 0, $show_alerts = 0, $pure = 0, $stacked = 0, $date = 0,
$only_image = false, $homeurl = '', $ttl = 1, $projection = false, $only_image = false, $homeurl = '', $ttl = 1, $projection = false,
$prediction_period = false, $background_color = 'white') { $prediction_period = false, $background_color = 'white',
$name_list = array(), $unit_list = array(), $show_last = true, $show_max = true,
$show_min = true, $show_avg = true) {
global $config; global $config;
global $graphic_type; global $graphic_type;
@ -928,6 +936,9 @@ function graphic_combined_module ($module_list, $weight_list, $period,
else { else {
$module_number = count ($module_list); $module_number = count ($module_list);
} }
$names_number = count($name_list);
$units_number = count($unit_list);
// interval - This is the number of "rows" we are divided the time to fill data. // interval - This is the number of "rows" we are divided the time to fill data.
// more interval, more resolution, and slower. // more interval, more resolution, and slower.
@ -971,23 +982,28 @@ function graphic_combined_module ($module_list, $weight_list, $period,
if ($projection != false && $i != 0) { if ($projection != false && $i != 0) {
$agent_module_id = $module_list[0]; $agent_module_id = $module_list[0];
//Get and process agent name if (!empty($name_list) && $names_number == $module_number && isset($name_list[$i])) {
$agent_name = io_safe_output( $module_name_list[$i] = $name_list[$i];
modules_get_agentmodule_agent_name ($agent_module_id)); }
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false); else {
//Get and process agent name
$agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($agent_module_id));
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
$agent_id = agents_get_agent_id ($agent_name);
//Get and process module name
$module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id));
$module_name = sprintf(__("projection for %s"), $module_name);
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
$module_name_list[$i] = $agent_name ." / ". $module_name;
}
$agent_id = agents_get_agent_id ($agent_name);
//Get and process module name
$module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id));
$module_name = sprintf(__("projection for %s"), $module_name);
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
$module_name_list[$i] = $agent_name ." / ". $module_name;
$id_module_type = modules_get_agentmodule_type ($agent_module_id); $id_module_type = modules_get_agentmodule_type ($agent_module_id);
$module_type = modules_get_moduletype_name ($id_module_type); $module_type = modules_get_moduletype_name ($id_module_type);
$uncompressed_module = is_module_uncompressed ($module_type); $uncompressed_module = is_module_uncompressed ($module_type);
@ -995,20 +1011,26 @@ function graphic_combined_module ($module_list, $weight_list, $period,
else { else {
$agent_module_id = $module_list[$i]; $agent_module_id = $module_list[$i];
//Get and process agent name if (!empty($name_list) && $names_number == $module_number && isset($name_list[$i])) {
$agent_name = io_safe_output( $module_name_list[$i] = $name_list[$i];
modules_get_agentmodule_agent_name ($agent_module_id)); }
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false); else {
//Get and process agent name
$agent_name = io_safe_output(
$agent_id = agents_get_agent_id ($agent_name); modules_get_agentmodule_agent_name ($agent_module_id));
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
//Get and process module name
$module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id)); $agent_id = agents_get_agent_id ($agent_name);
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
//Get and process module name
$module_name_list[$i] = $agent_name . " / " . $module_name; $module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id));
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
$module_name_list[$i] = $agent_name . " / " . $module_name;
}
$id_module_type = modules_get_agentmodule_type ($agent_module_id); $id_module_type = modules_get_agentmodule_type ($agent_module_id);
$module_type = modules_get_moduletype_name ($id_module_type); $module_type = modules_get_moduletype_name ($id_module_type);
$uncompressed_module = is_module_uncompressed ($module_type); $uncompressed_module = is_module_uncompressed ($module_type);
@ -1198,19 +1220,61 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$avg = round($avg / $countAvg, 1); $avg = round($avg / $countAvg, 1);
$graph_stats = get_graph_statistics($graph_values[$i]); $graph_stats = get_graph_statistics($graph_values[$i]);
if (!isset($config["short_module_graph_data"]))
$config["short_module_graph_data"] = true;
$min = $graph_stats['min']; if ($config["short_module_graph_data"]) {
$max = $graph_stats['max']; $min = $graph_stats['min'];
$avg = $graph_stats['avg']; $max = $graph_stats['max'];
$last = $graph_stats['last']; $avg = $graph_stats['avg'];
$units = modules_get_unit($agent_module_id); $last = $graph_stats['last'];
if ($min > 1000000)
$min = sprintf("%sM", number_format($min / 1000000, 2));
else if ($min > 1000)
$min = sprintf("%sK", number_format($min / 1000, 2));
if ($max > 1000000)
$max = sprintf("%sM", number_format($max / 1000000, 2));
else if ($max > 1000)
$max = sprintf("%sK", number_format($max / 1000, 2));
if ($avg > 1000000)
$avg = sprintf("%sM", number_format($avg / 1000000, 2));
else if ($avg > 1000)
$avg = sprintf("%sK", number_format($avg / 1000, 2));
if ($last > 1000000)
$last = sprintf("%sM", number_format($last / 1000000, 2));
else if ($last > 1000)
$last = sprintf("%sK", number_format($last / 1000, 2));
}
else {
$min = number_format($graph_stats['min'], 2);
$max = number_format($graph_stats['max'], 2);
$avg = number_format($graph_stats['avg'], 2);
$last = number_format($graph_stats['last'], 2);
}
if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) {
$unit = $unit_list[$i];
}
else {
$unit = modules_get_unit($agent_module_id);
}
if ($projection == false or ($projection != false and $i == 0)) { if ($projection == false or ($projection != false and $i == 0)) {
$module_name_list[$i] .= ": " . $module_name_list[$i] .= ": ";
__('Last') . ": $last $units; " . if ($show_last)
__("Max") . ": $max $units; " . $module_name_list[$i] .= __('Last') . ": $last $unit; ";
__("Min") . ": $min $units; " . if ($show_max)
__("Avg") . ": $avg"; $module_name_list[$i] .= __("Max") . ": $max $unit; ";
if ($show_min)
$module_name_list[$i] .= __("Min") . ": $min $unit; ";
if ($show_avg)
$module_name_list[$i] .= __("Avg") . ": $avg $unit";
} }
if ($weight_list[$i] != 1) { if ($weight_list[$i] != 1) {

View File

@ -250,7 +250,7 @@ function groups_get_childrens($parent, $groups = null, $onlyPropagate = false) {
if ($group['propagate'] || $onlyPropagate) { if ($group['propagate'] || $onlyPropagate) {
if ($group['parent'] == $parent) { if ($group['parent'] == $parent) {
$return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups); $return = $return + array($group['id_grupo'] => $group) + groups_get_childrens($group['id_grupo'], $groups, $onlyPropagate);
} }
} }
@ -869,8 +869,19 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) {
// Get stats for this group // Get stats for this group
$data = reporting_get_group_stats($id_group); $data = reporting_get_group_stats($id_group);
if ($data["total_agents"] == 0) if ($data["total_agents"] == 0) {
return; // Skip empty groups if (!empty($group['childs'])) {
$group_childrens = groups_get_childrens($id_group, null, true);
$group_childrens_agents = groups_total_agents(array_keys($group_childrens));
if (empty($group_childrens_agents)) {
return; // Skip empty groups
}
}
else {
return; // Skip empty groups
}
}
// Calculate entire row color // Calculate entire row color
if ($data["monitor_alerts_fired"] > 0) { if ($data["monitor_alerts_fired"] > 0) {

View File

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

View File

@ -58,6 +58,7 @@ $groups_full = users_get_groups ($config['id_user'], "AR", true, true);
$groups = array(); $groups = array();
foreach ($groups_full as $group) { foreach ($groups_full as $group) {
$groups[$group['id_grupo']]['name'] = $group['nombre']; $groups[$group['id_grupo']]['name'] = $group['nombre'];
$groups[$group['id_grupo']]['parent'] = $group['parent'];
if ($group['id_grupo'] != 0) { if ($group['id_grupo'] != 0) {
$groups[$group['parent']]['childs'][] = $group['id_grupo']; $groups[$group['parent']]['childs'][] = $group['id_grupo'];

View File

@ -60,8 +60,8 @@ $params = json_decode($params_json, true);
$interface_name = (string) $params['interface_name']; $interface_name = (string) $params['interface_name'];
$agent_id = (int) $params['agent_id']; $agent_id = (int) $params['agent_id'];
$interface_traffic_modules = array( $interface_traffic_modules = array(
'in' => (int) $params['traffic_module_in'], __('In') => (int) $params['traffic_module_in'],
'out' => (int) $params['traffic_module_out'] __('Out') => (int) $params['traffic_module_out']
); );
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -69,7 +69,7 @@ $interface_traffic_modules = array(
<head> <head>
<?php <?php
// Parsing the refresh before sending any header // Parsing the refresh before sending any header
$refresh = (int) get_parameter('refresh', SECONDS_10MINUTES); $refresh = (int) get_parameter('refresh', SECONDS_5MINUTES);
if ($refresh > 0) { if ($refresh > 0) {
$query = ui_get_url_refresh(false); $query = ui_get_url_refresh(false);
@ -135,8 +135,20 @@ $interface_traffic_modules = array(
else else
echo '<div style="margin-left: 50px; padding-top: 10px;">'; echo '<div style="margin-left: 50px; padding-top: 10px;">';
$modules = array($interface_traffic_modules['in'], $interface_traffic_modules['out']); custom_graphs_print(0,
custom_graphs_print(0, $height, $width, $period, null, false, $date, false, 'white', $modules, $config['homeurl']); $height,
$width,
$period,
null,
false,
$date,
false,
'white',
array_values($interface_traffic_modules),
$config['homeurl'],
array_keys($interface_traffic_modules),
array_fill(0, count($interface_traffic_modules),"bytes/s"),
false);
echo '</div>'; echo '</div>';

View File

@ -0,0 +1,209 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Load global vars
global $config;
enterprise_include ("operation/snmpconsole/snmp_view.php");
include_once($config['homedir'] . '/include/functions_graph.php');
require_once($config['homedir'] . "/include/functions_agents.php");
require_once($config['homedir'] . "/include/functions_snmp.php");
check_login ();
// ACL
if (! check_acl ($config['id_user'], 0, "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access SNMP Console");
require ("general/noaccess.php");
exit;
}
// Read parameters
$refr = (int)get_parameter("refr", 0);
// Page header and tabs
// Fullscreen
$fullscreen = array();
if ($config["pure"]) {
$fullscreen['text'] = '<a target="_top" href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_statistics&pure=0&refr=' . $refr . '">' .
html_print_image("images/normal_screen.png", true, array("title" => __('Normal screen'))) . '</a>';
}
else {
$fullscreen['text'] = '<a target="_top" href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_statistics&pure=1&refr=' . $refr . '">' .
html_print_image("images/full_screen.png", true, array("title" => __('Full screen'))) . '</a>';
}
// List
$list = array();
$list['text'] = '<a href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_view&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
html_print_image("images/op_snmp.png", true, array ("title" => __('List'))) .'</a>';
// Statistics (This file)
$statistics = array();
$statistics['active'] = true;
$statistics['text'] = '<a href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_statistics&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
html_print_image("images/op_reporting.png", true, array ("title" => __('Statistics'))) .'</a>';
// Header
ui_print_page_header(__("SNMP Console"), "images/op_snmp.png", false,
"", false, array($fullscreen, $list, $statistics));
// Retrieving the data
$user_groups = users_get_groups($config['id_user'], "AR", false);
$user_groups_str = '0';
if (!empty($user_groups)) {
$user_groups_str = implode(",", array_keys($user_groups));
}
$last_month_timestamp = date("Y-m-d H:i:s", time() - SECONDS_1MONTH);
$sql_traps_generated = "SELECT %s, COUNT(id_trap) AS num
FROM ttrap
WHERE timestamp >= '%s'
AND (source = ''
OR source NOT IN (SELECT direccion FROM tagente)
OR source IN (SELECT direccion
FROM tagente
WHERE id_grupo IN (%s)))
GROUP BY %s
ORDER BY num DESC, timestamp DESC
LIMIT 25";
$sql_traps_generated_by_source = sprintf($sql_traps_generated, "source", $last_month_timestamp, $user_groups_str, "source");
$sql_traps_generated_by_oid = sprintf($sql_traps_generated, "oid", $last_month_timestamp, $user_groups_str, "oid");
$traps_generated_by_source = db_get_all_rows_sql($sql_traps_generated_by_source);
$traps_generated_by_oid = db_get_all_rows_sql($sql_traps_generated_by_oid);
// No traps
if (empty($traps_generated_by_source) || empty($traps_generated_by_oid)) {
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
return;
}
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("/images/logo_vertical_water.png"));
// By SOURCE
$table_source = new StdClass();
$table_source->width = '100%';
$table_source->head[] = __("Traps received by source") . " - " . sprintf(__('Top %d'), 25);
$table_source->head_colspan[] = 2;
$table_source->headstyle[] = "background-color: #82b92e";
$table_source->size = array();
$table_source->size['table'] = '50%';
$table_source->size['graph'] = '50%';
$table_source->data = array();
$table_source_row = array();
$table_source_data = new StdClass();
$table_source_data->width = '100%';
$table_source_data->head = array();
$table_source_data->head['source'] = __('Source IP');
$table_source_data->head['num'] = __('Number');
$table_source_data->data = array();
$table_source_graph_data = array();
foreach ($traps_generated_by_source as $trap) {
$row = array();
$agent = agents_get_agent_with_ip($trap['source']);
if ($agent === false) {
$row['source'] = '<a href="index.php?sec=estado&sec2=godmode/agentes/configurar_agente&new_agent=1&direccion='.$trap["source"].'" title="'.__('Create agent').'">'.$trap["source"].'</a>';
}
else {
$agent_id = $agent["id_agente"];
$agent_name = ui_print_truncate_text($agent["nombre"], "agent_medium", true, true, true, '[&hellip;]', '');
$row['source'] = "<a href=\"index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$agent_id\" title=\"".__('View agent details')."\">";
$row['source'] .= "<strong>$agent_name</strong></a>";
}
$row['num'] = (int) $trap['num'];
$table_source_data->data[] = $row;
$table_source_graph_data[$trap["source"]] = (int) $trap["num"];
}
$table_source_row['table'] = html_print_table($table_source_data, true);
unset($table_source_data);
if (empty($table_source_graph_data))
$table_source_graph = graph_nodata_image();
else
$table_source_graph = pie3d_graph($config['flash_charts'], $table_source_graph_data, 400, 550, __("Other"),
'', $water_mark, $config['fontpath'], $config['font_size'], 1);
$table_source_row['graph'] = $table_source_graph;
$table_source->data[] = $table_source_row;
html_print_table($table_source);
unset($table_source);
// By OID
$table_oid = new StdClass();
$table_oid->width = '100%';
$table_oid->head[] = __("Traps received by OID") . " - " . sprintf(__('Top %d'), 25);
$table_oid->head_colspan[] = 2;
$table_oid->headstyle[] = "background-color: #82b92e";
$table_oid->size = array();
$table_oid->size['table'] = '50%';
$table_oid->size['graph'] = '50%';
$table_oid->data = array();
$table_oid_row = array();
$table_oid_data = new StdClass();
$table_oid_data->width = '100%';
$table_oid_data->head = array();
$table_oid_data->head['oid'] = __('Trap OID');
$table_oid_data->head['num'] = __('Number');
$table_oid_data->data = array();
$table_oid_graph_data = array();
foreach ($traps_generated_by_oid as $trap) {
$table_oid_data->data[] = array(
'oid' => $trap['oid'],
'num' => (int) $trap['num']
);
$table_oid_graph_data[$trap["oid"]] = (int) $trap["num"];
}
$table_oid_row['table'] = html_print_table($table_oid_data, true);
unset($table_oid_data);
if (empty($table_oid_graph_data))
$table_oid_graph = graph_nodata_image();
else
$table_oid_graph = pie3d_graph($config['flash_charts'], $table_oid_graph_data, 400, 550, __("Other"),
'', $water_mark, $config['fontpath'], $config['font_size'], 1);
$table_oid_row['graph'] = $table_oid_graph;
$table_oid->data[] = $table_oid_row;
html_print_table($table_oid);
unset($table_oid);
?>

View File

@ -40,7 +40,6 @@ $offset = (int) get_parameter ('offset',0);
$trap_type = (int) get_parameter ('trap_type', -1); $trap_type = (int) get_parameter ('trap_type', -1);
$group_by = (int)get_parameter('group_by', 0); $group_by = (int)get_parameter('group_by', 0);
$refr = (int)get_parameter("refr", 0); $refr = (int)get_parameter("refr", 0);
$tab = (string) get_parameter("tab");
$user_groups = users_get_groups ($config['id_user'],"AR", false); $user_groups = users_get_groups ($config['id_user'],"AR", false);
$str_user_groups = ''; $str_user_groups = '';
@ -65,22 +64,11 @@ $url = "index.php?sec=estado&" .
"trap_type=" . $trap_type . "&" . "trap_type=" . $trap_type . "&" .
"group_by=" .$group_by; "group_by=" .$group_by;
switch ($tab) { $statistics['text'] = '<a href="index.php?sec=estado&sec2=operation/snmpconsole/snmp_statistics&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
case 'statistics':
$statistics['active'] = true;
break;
default:
$list['active'] = true;
break;
}
$statistics['text'] = '<a href="' . $url . '&pure=' . $config["pure"] . '&refr=' . $refr . '&tab=statistics">' .
html_print_image("images/op_reporting.png", true, array ("title" => __('Statistics'))) .'</a>'; html_print_image("images/op_reporting.png", true, array ("title" => __('Statistics'))) .'</a>';
$list['text'] = '<a href="' . $url . '&pure=' . $config["pure"] . '&refr=' . $refr . '">' . $list['text'] = '<a href="' . $url . '&pure=' . $config["pure"] . '&refr=' . $refr . '">' .
html_print_image("images/op_snmp.png", true, array ("title" => __('List'))) .'</a>'; html_print_image("images/op_snmp.png", true, array ("title" => __('List'))) .'</a>';
$list['active'] = true;
if ($tab)
$url .= "&tab=$tab";
if ($config["pure"]) { if ($config["pure"]) {
$fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=0&refr=' . $refr . '">' . html_print_image("images/normal_screen.png", true, array("title" => __('Normal screen'))) . '</a>'; $fullscreen['text'] = '<a target="_top" href="'.$url.'&pure=0&refr=' . $refr . '">' . html_print_image("images/normal_screen.png", true, array("title" => __('Normal screen'))) . '</a>';
@ -354,441 +342,372 @@ ui_toggle($filter, __('Toggle filter(s)'));
unset ($table); unset ($table);
if ($tab == '') { $traps = db_get_all_rows_sql($sql);
$trapcount = (int) db_get_value_sql($sql_count);
$traps = db_get_all_rows_sql($sql);
$trapcount = (int) db_get_value_sql($sql_count);
// No traps
if (empty ($traps)) {
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
return;
}
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
for ($i=0; $i < count($traps); $i++) {
unset($traps[$i]['rnum']);
}
}
$url_snmp = "index.php?" .
"sec=snmpconsole&" .
"sec2=operation/snmpconsole/snmp_view&" .
"filter_severity=" . $filter_severity . "&" .
"filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refr=" . ((int)get_parameter('refr', 0)) . "&" .
"pure=" . $config["pure"] . "&" .
"group_by=" . $group_by . "&" .
"free_search_string=" . $free_search_string;
$urlPagination = $url_snmp . "&pagination=" . $pagination . "&offset=" . $offset;
ui_pagination ($trapcount, $urlPagination, $offset, $pagination);
echo '<form name="eventtable" method="POST" action="' . $url_snmp . '">';
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = '99%';
$table->class = "databox";
$table->head = array ();
$table->size = array ();
$table->data = array ();
$table->align = array ();
$table->head[0] = __('Status');
$table->align[0] = "center";
$table->size[0] = '5%';
$table->head[1] = __('SNMP Agent');
$table->align[1] = "center";
$table->size[1] = '15%';
$table->head[2] = __('OID');
$table->align[2] = "center";
$table->size[2] = '18%';
if ($group_by) {
$table->head[3] = __('Count');
$table->align[3] = "center";
$table->size[3] = '5%';
}
$table->head[4] = __('Value');
$table->align[4] = "center";
$table->size[4] = '10%';
$table->head[5] = __('User ID');
$table->align[5] = "center";
$table->size[5] = '10%';
$table->head[6] = __('Timestamp');
$table->align[6] = "center";
$table->size[6] = '10%';
$table->head[7] = __('Alert');
$table->align[7] = "center";
$table->size[7] = '5%';
$table->head[8] = __('Action');
$table->align[8] = "center";
$table->size[8] = '10%';
$table->head[9] = html_print_checkbox_extended ("allbox", 1, false, false, "javascript:CheckAll();", 'class="chk" title="'.__('All').'"', true);
$table->align[9] = "center";
$table->size[9] = '5%';
$table->style[8] = "background: #F3F3F3; color: #111 !important;";
// Skip offset records
$idx = 0;
if ($traps !== false) {
foreach ($traps as $trap) {
$data = array ();
if (empty($trap["description"])){
$trap["description"]="";
}
$severity = enterprise_hook ('get_severity', array ($trap));
if ($severity === ENTERPRISE_NOT_HOOK) {
$severity = $trap["alerted"] == 1 ? $trap["priority"] : 1;
}
//Status
if ($trap["status"] == 0) {
$data[0] = html_print_image("images/pixel_red.png", true, array("title" => __('Not validated'), "width" => "20", "height" => "20"));
}
else {
$data[0] = html_print_image("images/pixel_green.png", true, array("title" => __('Validated'), "width" => "20", "height" => "20"));
}
// Agent matching source address
$table->cellclass[$idx][1] = get_priority_class ($severity);
$agent = agents_get_agent_with_ip ($trap['source']);
if ($agent === false) {
if (! check_acl ($config["id_user"], 0, "AR")) {
continue;
}
$data[1] = '<a href="index.php?sec=estado&sec2=godmode/agentes/configurar_agente&new_agent=1&direccion='.$trap["source"].'" title="'.__('Create agent').'">'.$trap["source"].'</a>';
}
else {
if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
continue;
}
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'" title="'.__('View agent details').'">';
$data[1] .= '<strong>'.$agent["nombre"].'</strong></a>';
}
//OID
$table->cellclass[$idx][2] = get_priority_class ($severity);
$data[2] = '<a href="javascript: toggleVisibleExtendedInfo(' . $trap["id_trap"] . ');">' . (empty($trap["oid"]) ? __('N/A') : $trap["oid"]) .'</a>';
//Count
if ($group_by) {
$sql = "SELECT * FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'";
$group_traps = db_get_all_rows_sql($sql);
$count_group_traps = count($group_traps);
$table->cellclass[$idx][3] = get_priority_class ($severity);
$data[3] = '<strong>'.$count_group_traps.'</strong></a>';
}
//Value
$table->cellclass[$idx][4] = get_priority_class ($severity);
if (empty ($trap["value"])) {
$data[4] = __('N/A');
}
else {
$data[4] = ui_print_truncate_text($trap["value"], GENERIC_SIZE_TEXT, false);
}
//User
$table->cellclass[$idx][5] = get_priority_class ($severity);
if (!empty ($trap["status"])) {
$data[5] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit&ver='.$trap["id_usuario"].'">'.substr ($trap["id_usuario"], 0, 8).'</a>';
if (!empty($trap["id_usuario"]))
$data[5] .= ui_print_help_tip(get_user_fullname($trap["id_usuario"]), true);
}
else {
$data[5] = '--';
}
// Timestamp
$table->cellclass[$idx][6] = get_priority_class ($severity);
$data[6] = '<span title="'.$trap["timestamp"].'">';
$data[6] .= ui_print_timestamp ($trap["timestamp"], true);
$data[6] .= '</span>';
// Use alert severity if fired
if (!empty ($trap["alerted"])) {
$data[7] = html_print_image("images/pixel_yellow.png", true, array("width" => "20", "height" => "20", "border" => "0", "title" => __('Alert fired')));
}
else {
$data[7] = html_print_image("images/pixel_gray.png", true, array("width" => "20", "height" => "20", "border" => "0", "title" => __('Alert not fired')));
}
//Actions
$data[8] = "";
if (empty ($trap["status"]) && check_acl ($config["id_user"], 0, "IW")) {
$data[8] .= '<a href="' . $url_snmp . '&check='.$trap["id_trap"].'">' . html_print_image("images/ok.png", true, array("border" => '0', "title" => __('Validate'))) . '</a> ';
}
if ($trap['source'] == '') {
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user',$config['id_user']);
if ($is_admin) {
$data[8] .= '<a href="' . $url_snmp . '&delete='.$trap["id_trap"].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">' . html_print_image("images/cross.png", true, array("border" => "0", "title" => __('Delete'))) . '</a> ';
}
} else {
$agent_trap_group = db_get_value('id_grupo', 'tagente', 'nombre', $trap['source']);
if ((check_acl ($config["id_user"], $agent_trap_group, "AW"))) {
$data[8] .= '<a href="' . $url_snmp . '&delete='.$trap["id_trap"].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">' . html_print_image("images/cross.png", true, array("border" => "0", "title" => __('Delete'))) . '</a> ';
}
}
$data[8] .= '<a href="javascript: toggleVisibleExtendedInfo(' . $trap["id_trap"] . ');">' . html_print_image("images/eye.png", true, array("alt" => __('Show more'), "title" => __('Show more'))) .'</a>';
$data[8] .= enterprise_hook ('editor_link', array ($trap));
$data[9] = html_print_checkbox_extended ("snmptrapid[]", $trap["id_trap"], false, false, '', 'class="chk"', true);
array_push ($table->data, $data);
//Hiden file for description
$string = '<table style="border:solid 1px #D3D3D3;" width="90%" class="toggle">
<tr>
<td align="left" valign="top" width="15%" ><b>' . __('Custom data:') . '</b></td>
<td align="left" >';
if ($group_by) {
$new_url = "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&" .
"filter_severity=" . $filter_severity . "&" .
"filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refr=" . ((int)get_parameter('refr', 0)) . "&" .
"pure=" . $config["pure"] . "&" .
"group_by=0&" .
"free_search_string=" . $free_search_string;
$string .= '<a href='.$new_url.'>'.__('See more details').'</a>';
} else {
// Print binding vars separately
$binding_vars = explode ("\t", $trap['oid_custom']);
foreach ($binding_vars as $var) {
$string .= $var . "<br/>";
}
}
$string .= '</td>
</tr>
<tr>
<td align="left" valign="top">' . '<b>' . __('OID:') . '</td>
<td align="left"> ' . $trap['oid'] . '</td>
</tr>';
if ($trap["description"] != "") {
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('Description:') . '</td>
<td align="left">' . $trap['description'] . '</td>
</tr>';
}
if ($trap["type"] != "") {
$trap_types = array(-1 => __('None'), 0 => __('Cold start (0)'), 1 => __('Warm start (1)'), 2 => __('Link down (2)'), 3 => __('Link up (3)'), 4 => __('Authentication failure (4)'), 5 => __('Other'));
switch ($trap["type"]) {
case -1:
$desc_trap_type = __('None');
break;
case 0:
$desc_trap_type = __('Cold start (0)');
break;
case 1:
$desc_trap_type = __('Warm start (1)');
break;
case 2:
$desc_trap_type = __('Link down (2)');
break;
case 3:
$desc_trap_type = __('Link up (3)');
break;
case 4:
$desc_trap_type = __('Authentication failure (4)');
break;
default:
$desc_trap_type = __('Other');
break;
}
$string .= '<tr><td align="left" valign="top">' . '<b>' . __('Type:') . '</td><td align="left">' . $desc_trap_type . '</td></tr>';
}
if ($group_by) {
$sql = "SELECT * FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'";
$group_traps = db_get_all_rows_sql($sql);
$count_group_traps = count($group_traps);
$sql = "SELECT timestamp FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'
ORDER BY `timestamp` DESC";
$last_trap = db_get_value_sql($sql);
$sql = "SELECT timestamp FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'
ORDER BY `timestamp` ASC";
$first_trap = db_get_value_sql($sql);
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('Count:') . '</td>
<td align="left">' . $count_group_traps . '</td>
</tr>';
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('First trap:') . '</td>
<td align="left">' . $first_trap . '</td>
</tr>';
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('Last trap:') . '</td>
<td align="left">' . $last_trap . '</td>
</tr>';
}
$string .= '</table>';
$data = array($string); //$data = array($trap['description']);
$idx++;
$table->rowclass[$idx] = 'trap_info_' . $trap['id_trap'];
$table->colspan[$idx][0] = 10;
$table->rowstyle[$idx] = 'display: none;';
array_push ($table->data, $data);
$idx++;
}
}
// No matching traps
if ($idx == 0) {
echo '<div class="nf">' . __('No matching traps found') . '</div>';
}
else {
html_print_table ($table);
}
unset ($table);
echo '<div style="width:98%; text-align:right;">';
if (check_acl ($config["id_user"], 0, "IW")) {
html_print_submit_button (__('Validate'), "updatebt", false, 'class="sub ok"');
}
if (check_acl ($config['id_user'], 0, "IM")) {
echo "&nbsp;";
html_print_submit_button (__('Delete'), "deletebt", false, 'class="sub delete" onClick="javascript:return confirm(\''.__('Are you sure?').'\')"');
}
echo "</div></form>";
echo '<div style="float:left; padding-left:30px; line-height: 17px; vertical-align: top; width:120px;">';
echo '<h3>' . __('Status') . '</h3>';
echo html_print_image("images/pixel_green.png", true, array("width" => "20", "height" => "20")) . ' - ' . __('Validated');
echo '<br />';
echo html_print_image("images/pixel_red.png", true, array("width" => "20", "height" => "20")) . ' - ' . __('Not validated');
echo '</div>';
echo '<div style="float:left; padding-left:30px; line-height: 17px; vertical-align: top; width:120px;">';
echo '<h3>' . __('Alert') . '</h3>';
echo html_print_image("images/pixel_yellow.png", true, array("width" => "20", "height" => "20")) . ' - ' .__('Fired');
echo '<br />';
echo html_print_image("images/pixel_gray.png", true, array("width" => "20", "height" => "20")) . ' - ' . __('Not fired');
echo '</div>';
echo '<div style="float:left; padding-left:30px; line-height: 19px; vertical-align: top; width:120px;">';
echo '<h3>' . __('Action') . '</h3>';
echo html_print_image("images/ok.png", true) . ' - ' .__('Validate');
echo '<br />';
echo html_print_image("images/cross.png", true) . ' - ' . __('Delete');
echo '</div>';
echo '<div style="float:left; padding-left:30px; line-height: 17px; vertical-align: top; width:120px;">';
echo '<h3>'.__('Legend').'</h3>';
foreach (get_priorities () as $num => $name) {
echo '<span class="'.get_priority_class ($num).'">'.$name.'</span>';
echo '<br />';
}
echo '</div>';
echo '<div style="clear:both;">&nbsp;</div>';
// No traps
if (empty ($traps)) {
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
return;
} }
else {
$traps = db_get_all_rows_sql($sql_all); if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
$trapcount = (int) db_get_value_sql($sql_count); for ($i=0; $i < count($traps); $i++) {
unset($traps[$i]['rnum']);
// No traps
if (empty ($traps)) {
echo '<div class="nf">'.__('There are no SNMP traps in database').'</div>';
return;
} }
}
if (($config['dbtype'] == 'oracle') && ($traps !== false)) { $url_snmp = "index.php?" .
for ($i=0; $i < count($traps); $i++) { "sec=snmpconsole&" .
unset($traps[$i]['rnum']); "sec2=operation/snmpconsole/snmp_view&" .
} "filter_severity=" . $filter_severity . "&" .
} "filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refr=" . ((int)get_parameter('refr', 0)) . "&" .
"pure=" . $config["pure"] . "&" .
"group_by=" . $group_by . "&" .
"free_search_string=" . $free_search_string;
include_once($config['homedir'] . '/include/functions_graph.php'); $urlPagination = $url_snmp . "&pagination=" . $pagination . "&offset=" . $offset;
ui_pagination ($trapcount, $urlPagination, $offset, $pagination);
echo '<form name="eventtable" method="POST" action="' . $url_snmp . '">';
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->width = '99%';
$table->class = "databox";
$table->head = array ();
$table->size = array ();
$table->data = array ();
$table->align = array ();
$table->head[0] = __('Status');
$table->align[0] = "center";
$table->size[0] = '5%';
$table->head[1] = __('SNMP Agent');
$table->align[1] = "center";
$table->size[1] = '15%';
$table->head[2] = __('OID');
$table->align[2] = "center";
$table->size[2] = '18%';
if ($group_by) {
$table->head[3] = __('Count');
$table->align[3] = "center";
$table->size[3] = '5%';
}
$table->head[4] = __('Value');
$table->align[4] = "center";
$table->size[4] = '10%';
$table->head[5] = __('User ID');
$table->align[5] = "center";
$table->size[5] = '10%';
$table->head[6] = __('Timestamp');
$table->align[6] = "center";
$table->size[6] = '10%';
$table->head[7] = __('Alert');
$table->align[7] = "center";
$table->size[7] = '5%';
$table->head[8] = __('Action');
$table->align[8] = "center";
$table->size[8] = '10%';
$table->head[9] = html_print_checkbox_extended ("allbox", 1, false, false, "javascript:CheckAll();", 'class="chk" title="'.__('All').'"', true);
$table->align[9] = "center";
$table->size[9] = '5%';
$table->style[8] = "background: #F3F3F3; color: #111 !important;";
// Skip offset records
$idx = 0;
if ($traps !== false) {
$data_aux = array();
foreach ($traps as $trap) { foreach ($traps as $trap) {
$source = $trap['source']; $data = array ();
$oid = $trap['oid']; if (empty($trap["description"])){
$trap["description"]="";
if (!isset($data_aux[$source])) }
$data_aux[$source] = array(); $severity = enterprise_hook ('get_severity', array ($trap));
if ($severity === ENTERPRISE_NOT_HOOK) {
if (!isset($data_aux[$source][$oid])) $severity = $trap["alerted"] == 1 ? $trap["priority"] : 1;
$data_aux[$source][$oid] = array('num' => 1, 'text' => '');
else {
$data_aux[$source][$oid]['num']++;
if (empty($data_aux[$source][$oid]['text']))
$data_aux[$source][$oid]['text'] = $trap['text'];
} }
} //Status
if ($trap["status"] == 0) {
$id = -1; $data[0] = html_print_image("images/pixel_red.png", true, array("title" => __('Not validated'), "width" => "20", "height" => "20"));
$data = array();
if (!empty($traps)) {
$data['name'] = __("Traps received by source");
$data['children'] = array();
foreach ($data_aux as $source => $oid_data) {
$children = array();
$children['id'] = $id++;
$children['name'] = $source;
$children['children'] = array();
foreach ($oid_data as $oid => $values) {
$children_data = array();
$children_data['id'] = $id++;
$children_data['name'] = $oid;
$children_data['value'] = $values['num'];
$children_data['tooltip_content'] = '';
if (!empty($values['text']))
$children_data['tooltip_content'] .= "<b>" . $values['text'] . "</b><br>";
$children_data['tooltip_content'] .= sprintf(__('%d traps received from this source with this oid'), $values['num']);
$children['children'][] = $children_data;
}
$data['children'][] = $children;
} }
else {
$data[0] = html_print_image("images/pixel_green.png", true, array("title" => __('Validated'), "width" => "20", "height" => "20"));
}
// Agent matching source address
$table->cellclass[$idx][1] = get_priority_class ($severity);
$agent = agents_get_agent_with_ip ($trap['source']);
if ($agent === false) {
if (! check_acl ($config["id_user"], 0, "AR")) {
continue;
}
$data[1] = '<a href="index.php?sec=estado&sec2=godmode/agentes/configurar_agente&new_agent=1&direccion='.$trap["source"].'" title="'.__('Create agent').'">'.$trap["source"].'</a>';
}
else {
if (! check_acl ($config["id_user"], $agent["id_grupo"], "AR")) {
continue;
}
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'" title="'.__('View agent details').'">';
$data[1] .= '<strong>'.$agent["nombre"].'</strong></a>';
}
//OID
$table->cellclass[$idx][2] = get_priority_class ($severity);
$data[2] = '<a href="javascript: toggleVisibleExtendedInfo(' . $trap["id_trap"] . ');">' . (empty($trap["oid"]) ? __('N/A') : $trap["oid"]) .'</a>';
//Count
if ($group_by) {
$sql = "SELECT * FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'";
$group_traps = db_get_all_rows_sql($sql);
$count_group_traps = count($group_traps);
$table->cellclass[$idx][3] = get_priority_class ($severity);
$data[3] = '<strong>'.$count_group_traps.'</strong></a>';
}
//Value
$table->cellclass[$idx][4] = get_priority_class ($severity);
if (empty ($trap["value"])) {
$data[4] = __('N/A');
}
else {
$data[4] = ui_print_truncate_text($trap["value"], GENERIC_SIZE_TEXT, false);
}
//User
$table->cellclass[$idx][5] = get_priority_class ($severity);
if (!empty ($trap["status"])) {
$data[5] = '<a href="index.php?sec=workspace&sec2=operation/users/user_edit&ver='.$trap["id_usuario"].'">'.substr ($trap["id_usuario"], 0, 8).'</a>';
if (!empty($trap["id_usuario"]))
$data[5] .= ui_print_help_tip(get_user_fullname($trap["id_usuario"]), true);
}
else {
$data[5] = '--';
}
// Timestamp
$table->cellclass[$idx][6] = get_priority_class ($severity);
$data[6] = '<span title="'.$trap["timestamp"].'">';
$data[6] .= ui_print_timestamp ($trap["timestamp"], true);
$data[6] .= '</span>';
// Use alert severity if fired
if (!empty ($trap["alerted"])) {
$data[7] = html_print_image("images/pixel_yellow.png", true, array("width" => "20", "height" => "20", "border" => "0", "title" => __('Alert fired')));
}
else {
$data[7] = html_print_image("images/pixel_gray.png", true, array("width" => "20", "height" => "20", "border" => "0", "title" => __('Alert not fired')));
}
//Actions
$data[8] = "";
if (empty ($trap["status"]) && check_acl ($config["id_user"], 0, "IW")) {
$data[8] .= '<a href="' . $url_snmp . '&check='.$trap["id_trap"].'">' . html_print_image("images/ok.png", true, array("border" => '0', "title" => __('Validate'))) . '</a> ';
}
if ($trap['source'] == '') {
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user',$config['id_user']);
if ($is_admin) {
$data[8] .= '<a href="' . $url_snmp . '&delete='.$trap["id_trap"].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">' . html_print_image("images/cross.png", true, array("border" => "0", "title" => __('Delete'))) . '</a> ';
}
} else {
$agent_trap_group = db_get_value('id_grupo', 'tagente', 'nombre', $trap['source']);
if ((check_acl ($config["id_user"], $agent_trap_group, "AW"))) {
$data[8] .= '<a href="' . $url_snmp . '&delete='.$trap["id_trap"].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">' . html_print_image("images/cross.png", true, array("border" => "0", "title" => __('Delete'))) . '</a> ';
}
}
$data[8] .= '<a href="javascript: toggleVisibleExtendedInfo(' . $trap["id_trap"] . ');">' . html_print_image("images/eye.png", true, array("alt" => __('Show more'), "title" => __('Show more'))) .'</a>';
$data[8] .= enterprise_hook ('editor_link', array ($trap));
$data[9] = html_print_checkbox_extended ("snmptrapid[]", $trap["id_trap"], false, false, '', 'class="chk"', true);
array_push ($table->data, $data);
//Hiden file for description
$string = '<table style="border:solid 1px #D3D3D3;" width="90%" class="toggle">
<tr>
<td align="left" valign="top" width="15%" ><b>' . __('Custom data:') . '</b></td>
<td align="left" >';
if ($group_by) {
$new_url = "index.php?sec=snmpconsole&sec2=operation/snmpconsole/snmp_view&" .
"filter_severity=" . $filter_severity . "&" .
"filter_fired=" . $filter_fired . "&" .
"filter_status=" . $filter_status . "&" .
"refr=" . ((int)get_parameter('refr', 0)) . "&" .
"pure=" . $config["pure"] . "&" .
"group_by=0&" .
"free_search_string=" . $free_search_string;
$string .= '<a href='.$new_url.'>'.__('See more details').'</a>';
} else {
// Print binding vars separately
$binding_vars = explode ("\t", $trap['oid_custom']);
foreach ($binding_vars as $var) {
$string .= $var . "<br/>";
}
}
$string .= '</td>
</tr>
<tr>
<td align="left" valign="top">' . '<b>' . __('OID:') . '</td>
<td align="left"> ' . $trap['oid'] . '</td>
</tr>';
if ($trap["description"] != "") {
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('Description:') . '</td>
<td align="left">' . $trap['description'] . '</td>
</tr>';
}
if ($trap["type"] != "") {
$trap_types = array(-1 => __('None'), 0 => __('Cold start (0)'), 1 => __('Warm start (1)'), 2 => __('Link down (2)'), 3 => __('Link up (3)'), 4 => __('Authentication failure (4)'), 5 => __('Other'));
switch ($trap["type"]) {
case -1:
$desc_trap_type = __('None');
break;
case 0:
$desc_trap_type = __('Cold start (0)');
break;
case 1:
$desc_trap_type = __('Warm start (1)');
break;
case 2:
$desc_trap_type = __('Link down (2)');
break;
case 3:
$desc_trap_type = __('Link up (3)');
break;
case 4:
$desc_trap_type = __('Authentication failure (4)');
break;
default:
$desc_trap_type = __('Other');
break;
}
$string .= '<tr><td align="left" valign="top">' . '<b>' . __('Type:') . '</td><td align="left">' . $desc_trap_type . '</td></tr>';
}
if ($group_by) {
$sql = "SELECT * FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'";
$group_traps = db_get_all_rows_sql($sql);
$count_group_traps = count($group_traps);
$sql = "SELECT timestamp FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'
ORDER BY `timestamp` DESC";
$last_trap = db_get_value_sql($sql);
$sql = "SELECT timestamp FROM ttrap WHERE 1=1
$where_without_group
AND oid='".$trap['oid']."'
AND source='".$trap['source']."'
ORDER BY `timestamp` ASC";
$first_trap = db_get_value_sql($sql);
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('Count:') . '</td>
<td align="left">' . $count_group_traps . '</td>
</tr>';
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('First trap:') . '</td>
<td align="left">' . $first_trap . '</td>
</tr>';
$string .= '<tr>
<td align="left" valign="top">' . '<b>' . __('Last trap:') . '</td>
<td align="left">' . $last_trap . '</td>
</tr>';
}
$string .= '</table>';
$data = array($string); //$data = array($trap['description']);
$idx++;
$table->rowclass[$idx] = 'trap_info_' . $trap['id_trap'];
$table->colspan[$idx][0] = 10;
$table->rowstyle[$idx] = 'display: none;';
array_push ($table->data, $data);
$idx++;
} }
echo graph_snmp_traps_treemap($data, 'auto', 500);
} }
// No matching traps
if ($idx == 0) {
echo '<div class="nf">' . __('No matching traps found') . '</div>';
}
else {
html_print_table ($table);
}
unset ($table);
echo '<div style="width:98%; text-align:right;">';
if (check_acl ($config["id_user"], 0, "IW")) {
html_print_submit_button (__('Validate'), "updatebt", false, 'class="sub ok"');
}
if (check_acl ($config['id_user'], 0, "IM")) {
echo "&nbsp;";
html_print_submit_button (__('Delete'), "deletebt", false, 'class="sub delete" onClick="javascript:return confirm(\''.__('Are you sure?').'\')"');
}
echo "</div></form>";
echo '<div style="float:left; padding-left:30px; line-height: 17px; vertical-align: top; width:120px;">';
echo '<h3>' . __('Status') . '</h3>';
echo html_print_image("images/pixel_green.png", true, array("width" => "20", "height" => "20")) . ' - ' . __('Validated');
echo '<br />';
echo html_print_image("images/pixel_red.png", true, array("width" => "20", "height" => "20")) . ' - ' . __('Not validated');
echo '</div>';
echo '<div style="float:left; padding-left:30px; line-height: 17px; vertical-align: top; width:120px;">';
echo '<h3>' . __('Alert') . '</h3>';
echo html_print_image("images/pixel_yellow.png", true, array("width" => "20", "height" => "20")) . ' - ' .__('Fired');
echo '<br />';
echo html_print_image("images/pixel_gray.png", true, array("width" => "20", "height" => "20")) . ' - ' . __('Not fired');
echo '</div>';
echo '<div style="float:left; padding-left:30px; line-height: 19px; vertical-align: top; width:120px;">';
echo '<h3>' . __('Action') . '</h3>';
echo html_print_image("images/ok.png", true) . ' - ' .__('Validate');
echo '<br />';
echo html_print_image("images/cross.png", true) . ' - ' . __('Delete');
echo '</div>';
echo '<div style="float:left; padding-left:30px; line-height: 17px; vertical-align: top; width:120px;">';
echo '<h3>'.__('Legend').'</h3>';
foreach (get_priorities () as $num => $name) {
echo '<span class="'.get_priority_class ($num).'">'.$name.'</span>';
echo '<br />';
}
echo '</div>';
echo '<div style="clear:both;">&nbsp;</div>';
?> ?>
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">

View File

@ -86,12 +86,14 @@ if (is_ajax ())
} }
if ($printModuleTable) { if ($printModuleTable) {
$id_module = get_parameter('id_module'); $id_module = get_parameter('id_module');
$id_agent = get_parameter('id_agent');
if (defined ('METACONSOLE')) { if (defined ('METACONSOLE')) {
$server = metaconsole_get_connection ($server_name); $server = metaconsole_get_connection ($server_name);
metaconsole_connect($server); metaconsole_connect($server);
} }
treeview_printTable($id_agent, $server);
treeview_printModuleTable($id_module, $server); treeview_printModuleTable($id_module, $server);
@ -451,7 +453,7 @@ if (is_ajax ())
echo " "; echo " ";
} }
echo "<a style='vertical-align: middle;' onfocus='JavaScript: this.blur()' href='javascript: loadModuleTable(" . $row["id_agente_modulo"] . ", \"" . $server_name . "\")'>"; echo "<a style='vertical-align: middle;' onfocus='JavaScript: this.blur()' href='javascript: loadModuleTable(" . $row["id_agente_modulo"] . ", \"" . $server_name . "\"". "," . $id.")'>";
echo ui_print_truncate_text(io_safe_output($row['nombre']), 40, true); echo ui_print_truncate_text(io_safe_output($row['nombre']), 40, true);
echo "</a>"; echo "</a>";
if ($row['quiet']) { if ($row['quiet']) {
@ -847,11 +849,11 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
}); });
} }
function loadModuleTable(id_module, server_name) { function loadModuleTable(id_module, server_name, id_agent) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>, url: <?php echo '"' . ui_get_full_url("ajax.php", false, false, false) . '"'; ?>,
data: "page=<?php echo $_GET['sec2']; ?>&printModuleTable=1&id_module=" + id_module + "&server_name=" + server_name, data: "page=<?php echo $_GET['sec2']; ?>&printModuleTable=1&id_module=" + id_module + "&server_name=" + server_name +"&id_agent="+id_agent,
success: function(data) { success: function(data) {
$('#cont').html(data); $('#cont').html(data);
forced_title_callback(); forced_title_callback();

View File

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

View File

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

View File

@ -38,7 +38,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('graph_res','5'), ('graph_res','5'),
('step_compact','1'), ('step_compact','1'),
('db_scheme_version','5.1'), ('db_scheme_version','5.1'),
('db_scheme_build','PD140923'), ('db_scheme_build','PD140924'),
('show_unknown','0'), ('show_unknown','0'),
('show_lastalerts','1'), ('show_lastalerts','1'),
('style','pandora'), ('style','pandora'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 5.1-140923 Version: 5.1-140924
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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