2010-09-17 Miguel de Dios <miguel.dedios@artica.es>
* include/fgraph.php: added function "grafico_modulo_sparse_mobile" for to paint a mobile graph. * include/functions_db.php: erased deprecate function "dame_grupo_icono". * include/functions_module.php: moved the functions "format_delete", "format_time", "format_data", "format_verbatim", "format_timestamp", "format_delete", "format_delete_string", "format_delete_log4x" from the file "operation/agentes/datos_agente.php" for to use in other source code places. * operation/agentes/datos_agente.php: extracted the functions "format_delete", "format_time", "format_data", "format_verbatim", "format_timestamp", "format_delete", "format_delete_string", "format_delete_log4x" to "include/functions_module.php" for to use in other source code. * operation/agentes/tactical.php: cleaned source code style. * operation/agentes/group_view.php: cleaned source code style. * mobile/operation/agents/view_agents.php: added class "viewGraph" to show graph and data of any module. * mobile/operation/agents/tactical.php: added first version of page to show tactical mobile page. * mobile/operation/agents/view_alerts.php: added first version of page to show alerts mobile page. * mobile/operation/agents/group_view.php: added first version of page to show group view mobile page. * mobile/operation/servers/view_servers.php: added first version of page to show servers mobile page. * mobile/include/style/main.css: added many new styles. * mobile/include/functions_web.php: added links into menu for new pages. * mobile/include/system.class.php: fixed scope of method "getConfig". * mobile/index.php: added hooks for new pages. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3250 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
a26e4db80f
commit
815adff2a4
|
@ -1,3 +1,49 @@
|
|||
2010-09-17 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/fgraph.php: added function "grafico_modulo_sparse_mobile" for
|
||||
to paint a mobile graph.
|
||||
|
||||
* include/functions_db.php: erased deprecate function "dame_grupo_icono".
|
||||
|
||||
* include/functions_module.php: moved the functions "format_delete",
|
||||
"format_time", "format_data", "format_verbatim", "format_timestamp",
|
||||
"format_delete", "format_delete_string", "format_delete_log4x" from the
|
||||
file "operation/agentes/datos_agente.php" for to use in other source code
|
||||
places.
|
||||
|
||||
* operation/agentes/datos_agente.php: extracted the functions
|
||||
"format_delete", "format_time", "format_data", "format_verbatim",
|
||||
"format_timestamp", "format_delete", "format_delete_string",
|
||||
"format_delete_log4x" to "include/functions_module.php" for to use in other
|
||||
source code.
|
||||
|
||||
* operation/agentes/tactical.php: cleaned source code style.
|
||||
|
||||
* operation/agentes/group_view.php: cleaned source code style.
|
||||
|
||||
* mobile/operation/agents/view_agents.php: added class "viewGraph" to show
|
||||
graph and data of any module.
|
||||
|
||||
* mobile/operation/agents/tactical.php: added first version of page to show
|
||||
tactical mobile page.
|
||||
|
||||
* mobile/operation/agents/view_alerts.php: added first version of page to
|
||||
show alerts mobile page.
|
||||
|
||||
* mobile/operation/agents/group_view.php: added first version of page to
|
||||
show group view mobile page.
|
||||
|
||||
* mobile/operation/servers/view_servers.php: added first version of page to
|
||||
show servers mobile page.
|
||||
|
||||
* mobile/include/style/main.css: added many new styles.
|
||||
|
||||
* mobile/include/functions_web.php: added links into menu for new pages.
|
||||
|
||||
* mobile/include/system.class.php: fixed scope of method "getConfig".
|
||||
|
||||
* mobile/index.php: added hooks for new pages.
|
||||
|
||||
2010-09-17 Junichi Satoh <junichi@rworks.jp>
|
||||
|
||||
* extras/pandoradb_migrate_v3.1_to_v3.2.sql: Added missing ';'.
|
||||
|
|
|
@ -1500,6 +1500,240 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$engine->sparse_graph ($period, $avg_only, $min_value, $max_value, $unit_name);
|
||||
}
|
||||
|
||||
function grafico_modulo_sparse_mobile ($agent_module_id, $period, $show_events,
|
||||
$width, $height , $title, $unit_name,
|
||||
$show_alerts, $avg_only = 0, $pure = false,
|
||||
$date = 0) {
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
// Set variables
|
||||
if ($date == 0) $date = get_system_time();
|
||||
$datelimit = $date - $period;
|
||||
$resolution = $config['graph_res'] * 50; //Number of points of the graph
|
||||
$interval = (int) ($period / $resolution);
|
||||
$agent_name = get_agentmodule_agent_name ($agent_module_id);
|
||||
$agent_id = get_agent_id ($agent_name);
|
||||
$module_name = get_agentmodule_name ($agent_module_id);
|
||||
$id_module_type = get_agentmodule_type ($agent_module_id);
|
||||
$module_type = get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
if ($uncompressed_module) {
|
||||
$avg_only = 1;
|
||||
}
|
||||
|
||||
// Get event data (contains alert data too)
|
||||
if ($show_events == 1 || $show_alerts == 1) {
|
||||
$events = get_db_all_rows_filter ('tevento',
|
||||
array ('id_agentmodule' => $agent_module_id,
|
||||
"utimestamp > $datelimit",
|
||||
"utimestamp < $date",
|
||||
'order' => 'utimestamp ASC'),
|
||||
array ('evento', 'utimestamp'));
|
||||
if ($events === false) {
|
||||
$events = array ();
|
||||
}
|
||||
}
|
||||
|
||||
// Get module data
|
||||
$data = get_db_all_rows_filter ('tagente_datos',
|
||||
array ('id_agente_modulo' => $agent_module_id,
|
||||
"utimestamp > $datelimit",
|
||||
"utimestamp < $date",
|
||||
'order' => 'utimestamp ASC'),
|
||||
array ('datos', 'utimestamp'));
|
||||
if ($data === false) {
|
||||
$data = array ();
|
||||
}
|
||||
|
||||
// Uncompressed module data
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
} else {
|
||||
// Get previous data
|
||||
$previous_data = get_previous_data ($agent_module_id, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
$previous_data['utimestamp'] = $datelimit;
|
||||
array_unshift ($data, $previous_data);
|
||||
}
|
||||
|
||||
// Get next data
|
||||
$nextData = get_next_data ($agent_module_id, $date);
|
||||
if ($nextData !== false) {
|
||||
array_push ($data, $nextData);
|
||||
} else if (count ($data) > 0) {
|
||||
// Propagate the last known data to the end of the interval
|
||||
$nextData = array_pop ($data);
|
||||
array_push ($data, $nextData);
|
||||
$nextData['utimestamp'] = $date;
|
||||
array_push ($data, $nextData);
|
||||
}
|
||||
|
||||
$min_necessary = 2;
|
||||
}
|
||||
|
||||
// Check available data
|
||||
if (count ($data) < $min_necessary) {
|
||||
if (!$graphic_type) {
|
||||
return fs_error_image ();
|
||||
}
|
||||
graphic_error ();
|
||||
}
|
||||
|
||||
// Data iterator
|
||||
$j = 0;
|
||||
|
||||
// Event iterator
|
||||
$k = 0;
|
||||
|
||||
// Set initial conditions
|
||||
$chart = array();
|
||||
if ($data[0]['utimestamp'] == $datelimit) {
|
||||
$previous_data = $data[0]['datos'];
|
||||
$j++;
|
||||
} else {
|
||||
$previous_data = 0;
|
||||
}
|
||||
|
||||
// Calculate chart data
|
||||
for ($i = 0; $i < $resolution; $i++) {
|
||||
$timestamp = $datelimit + ($interval * $i);
|
||||
|
||||
$total = 0;
|
||||
$count = 0;
|
||||
|
||||
// Read data that falls in the current interval
|
||||
$interval_min = false;
|
||||
$interval_max = false;
|
||||
while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) {
|
||||
if ($interval_min === false) {
|
||||
$interval_min = $data[$j]['datos'];
|
||||
}
|
||||
if ($interval_max === false) {
|
||||
$interval_max = $data[$j]['datos'];
|
||||
}
|
||||
|
||||
if ($data[$j]['datos'] > $interval_max) {
|
||||
$interval_max = $data[$j]['datos'];
|
||||
} else if ($data[$j]['datos'] < $interval_max) {
|
||||
$interval_min = $data[$j]['datos'];
|
||||
}
|
||||
$total += $data[$j]['datos'];
|
||||
$count++;
|
||||
$j++;
|
||||
}
|
||||
|
||||
// Data in the interval
|
||||
if ($count > 0) {
|
||||
$total /= $count;
|
||||
}
|
||||
|
||||
// Read events and alerts that fall in the current interval
|
||||
$event_value = 0;
|
||||
$alert_value = 0;
|
||||
while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] <= ($timestamp + $interval)) {
|
||||
if ($show_events == 1) {
|
||||
$event_value++;
|
||||
}
|
||||
if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') {
|
||||
$alert_value++;
|
||||
}
|
||||
$k++;
|
||||
}
|
||||
|
||||
// Data
|
||||
if ($count > 0) {
|
||||
$chart[$timestamp]['sum'] = $total;
|
||||
$chart[$timestamp]['min'] = $interval_min;
|
||||
$chart[$timestamp]['max'] = $interval_max;
|
||||
$previous_data = $total;
|
||||
// Compressed data
|
||||
} else {
|
||||
if ($uncompressed_module) {
|
||||
$chart[$timestamp]['sum'] = 0;
|
||||
$chart[$timestamp]['min'] = 0;
|
||||
$chart[$timestamp]['max'] = 0;
|
||||
} else {
|
||||
$chart[$timestamp]['sum'] = $previous_data;
|
||||
$chart[$timestamp]['min'] = $previous_data;
|
||||
$chart[$timestamp]['max'] = $previous_data;
|
||||
}
|
||||
}
|
||||
|
||||
$chart[$timestamp]['count'] = 0;
|
||||
$chart[$timestamp]['timestamp_bottom'] = $timestamp;
|
||||
$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
|
||||
$chart[$timestamp]['event'] = $event_value;
|
||||
$chart[$timestamp]['alert'] = $alert_value;
|
||||
}
|
||||
|
||||
// Get min, max and avg (less efficient but centralized for all modules and reports)
|
||||
$min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2);
|
||||
$max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2);
|
||||
$avg_value = round(get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
|
||||
|
||||
// Fix event and alert scale
|
||||
$event_max = $max_value * 1.25;
|
||||
foreach ($chart as $timestamp => $chart_data) {
|
||||
if ($chart_data['event'] > 0) {
|
||||
$chart[$timestamp]['event'] = $event_max;
|
||||
}
|
||||
if ($chart_data['alert'] > 0) {
|
||||
$chart[$timestamp]['alert'] = $event_max;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the title and time format
|
||||
if ($period <= 3600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'G:i:s';
|
||||
}
|
||||
elseif ($period <= 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'G:i';
|
||||
}
|
||||
elseif ($period <= 604800) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M j';
|
||||
}
|
||||
elseif ($period <= 2419200) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M j';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M j';
|
||||
}
|
||||
|
||||
// Flash chart
|
||||
$caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value;
|
||||
if (! $graphic_type) {
|
||||
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption);
|
||||
}
|
||||
|
||||
$engine = get_graph_engine ($period);
|
||||
$engine->width = $width;
|
||||
$engine->height = $height;
|
||||
$engine->data = &$chart;
|
||||
$engine->xaxis_interval = $resolution * 1.8;
|
||||
$engine->title = "";
|
||||
$engine->subtitle = $caption;
|
||||
$engine->show_title = false; //true;
|
||||
$engine->max_value = $max_value;
|
||||
$engine->min_value = $min_value;
|
||||
$engine->events = (bool) $show_event;
|
||||
$engine->alert_top = false;
|
||||
$engine->alert_bottom = false;;
|
||||
if (! $pure) {
|
||||
$engine->legend = &$legend;
|
||||
}
|
||||
$engine->fontpath = $config['fontpath'];
|
||||
|
||||
$engine->sparse_graph ($period, $avg_only, $min_value, $max_value, $unit_name);
|
||||
}
|
||||
|
||||
function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
||||
$width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0,
|
||||
$date = 0 ) {
|
||||
|
@ -2418,6 +2652,10 @@ if ($graphic_type) {
|
|||
grafico_modulo_sparse ($id, $period, $draw_events, $width, $height,
|
||||
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date);
|
||||
break;
|
||||
case 'sparse_mobile':
|
||||
grafico_modulo_sparse_mobile ($id, $period, $draw_events, $width, $height,
|
||||
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date);
|
||||
break;
|
||||
case "boolean":
|
||||
grafico_modulo_boolean ($id, $period, $draw_events, $width, $height ,
|
||||
$label, $unit_name, $draw_alerts, 1, $pure, $date);
|
||||
|
|
|
@ -704,14 +704,6 @@ function get_group_icon ($id_group) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DEPRECATED in favor of get_group_icon
|
||||
*/
|
||||
function dame_grupo_icono ($id_group) {
|
||||
return get_group_icon ($id_group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agent id from a module id that it has.
|
||||
*
|
||||
|
|
|
@ -229,4 +229,76 @@ function get_agents_with_module_name ($module_name, $id_group, $filter = false,
|
|||
return get_db_all_rows_filter ('tagente, tagente_modulo',
|
||||
$filter, $fields);
|
||||
}
|
||||
|
||||
//
|
||||
// This are functions to format the data
|
||||
//
|
||||
|
||||
function format_time($ts)
|
||||
{
|
||||
return print_timestamp ($ts, true, array("prominent" => "comparation"));
|
||||
}
|
||||
|
||||
function format_data($data)
|
||||
{
|
||||
if (is_numeric ($data)) {
|
||||
$data = format_numeric($data, 2);
|
||||
} else {
|
||||
$data = safe_input ($data);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function format_verbatim($data){
|
||||
// We need to replace \n by <br> to create a "similar" output to
|
||||
// information recolected in logs.
|
||||
$data2 = preg_replace ("/\\n/", "<br>", $data);
|
||||
return "<span style='font-size:10px;'>" . $data2 . "</span>";
|
||||
}
|
||||
|
||||
function format_timestamp($ts)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// This returns data with absolute user-defined timestamp format
|
||||
// and numeric by data managed with 2 decimals, and not using Graph format
|
||||
// (replacing 1000 by K and 1000000 by G, like version 2.x
|
||||
return date ($config["date_format"], $ts);
|
||||
}
|
||||
|
||||
function format_delete($id)
|
||||
{
|
||||
global $period, $module_id, $config, $group;
|
||||
|
||||
$txt = "";
|
||||
|
||||
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
||||
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
function format_delete_string($id)
|
||||
{
|
||||
global $period, $module_id, $config, $group;
|
||||
|
||||
$txt = "";
|
||||
|
||||
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
||||
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete_string='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
function format_delete_log4x($id)
|
||||
{
|
||||
global $period, $module_id, $config, $group;
|
||||
|
||||
$txt = "";
|
||||
|
||||
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
||||
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete_log4x='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -16,10 +16,11 @@ function menu() {
|
|||
?>
|
||||
<div id="top_menu">
|
||||
<div id="menu">
|
||||
<a href="index.php?page=dashboard"><img class="icon_menu" alt="<?php echo __('Dashboard');?>" title="<?php echo __('Dashboard');?>" src="../images/house.png" /></a>
|
||||
<a href="index.php?page=tactical"><img class="icon_menu" alt="<?php echo __('Dashboard');?>" title="<?php echo __('Dashboard');?>" src="../images/house.png" /></a>
|
||||
<a href="index.php?page=agents"><img class="icon_menu" alt="<?php echo __('Agents');?>" title="<?php echo __('Agents');?>" src="../images/bricks.png" /></a>
|
||||
<a href=""><img class="icon_menu" alt="<?php echo __('Events');?>" title="<?php echo __('Events');?>" src="../images/lightning_go.png" /></a>
|
||||
<a href=""><img class="icon_menu" alt="<?php echo __('Groups');?>" title="<?php echo __('Groups');?>" src="../images/world.png" /></a>
|
||||
<a href="index.php?page=alerts"><img class="icon_menu" alt="<?php echo __('Alerts');?>" title="<?php echo __('Alerts');?>" src="../images/bell.png" /></a>
|
||||
<a href="index.php?page=groups"><img class="icon_menu" alt="<?php echo __('Groups');?>" title="<?php echo __('Groups');?>" src="../images/world.png" /></a>
|
||||
<a href="index.php?page=servers"><img class="icon_menu" alt="<?php echo __('Servers');?>" title="<?php echo __('Servers');?>" src="../images/god5.png" /></a>
|
||||
<a href=""><img class="icon_menu" alt="<?php echo __('Reports');?>" title="<?php echo __('Reports');?>" src="../images/reporting.png" /></a>
|
||||
<a href="index.php?action=logout"><img class="icon_menu" alt="<?php echo __('Logout');?>" title="<?php echo __('Logout');?>" src="../images/log-out.png" /></a>
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
border: 0;
|
||||
|
||||
font-size: 12px;
|
||||
font-family: Arial;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
body {
|
||||
|
@ -50,11 +55,30 @@ input {
|
|||
border: #CCCCCC 1px solid;
|
||||
}
|
||||
|
||||
.title_h3 {
|
||||
.title_h3, .title_h3 * {
|
||||
border-top: 1px solid #CCCCCC;
|
||||
margin: 5px;
|
||||
color: #3F4E2F;
|
||||
}
|
||||
|
||||
.title_h3_server {
|
||||
border-top: 1px solid #CCCCCC;
|
||||
border-bottom: 1px solid #CCCCCC;
|
||||
margin: 5px;
|
||||
color: #3F4E2F;
|
||||
}
|
||||
tr.rowPair {
|
||||
background-color: #fff;
|
||||
}
|
||||
tr.rowOdd {
|
||||
background-color: #EEEEEE;
|
||||
}
|
||||
tr.rowPair:hover {
|
||||
background-color: #E0E0E0;
|
||||
}
|
||||
tr.rowOdd:hover {
|
||||
background-color: #E0E0E0
|
||||
}
|
||||
/*----------------INI-MENU----------------------------------------------------*/
|
||||
#top_menu {
|
||||
background: #3F4E2F;
|
||||
|
|
|
@ -50,7 +50,7 @@ class System {
|
|||
return $return;
|
||||
}
|
||||
|
||||
private function getConfig($name, $default = null) {
|
||||
public function getConfig($name, $default = null) {
|
||||
if (!isset($this->config[$name])) {
|
||||
return $default;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ require_once("include/user.class.php");
|
|||
require_once("include/functions_web.php");
|
||||
require_once('operation/agents/view_agents.php');
|
||||
require_once('operation/servers/view_servers.php');
|
||||
require_once('operation/agents/tactical.php');
|
||||
require_once('operation/agents/group_view.php');
|
||||
require_once('operation/agents/view_alerts.php');
|
||||
|
||||
$system = new System();
|
||||
|
||||
|
@ -46,7 +49,20 @@ $user->hackinjectConfig();
|
|||
if (!$user->checkLogin()) {
|
||||
$user->login();
|
||||
}
|
||||
else {
|
||||
$user->hackinjectConfig();
|
||||
menu();
|
||||
|
||||
if (! give_acl ($system->getConfig('id_user'), 0, "AR")) {
|
||||
audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access Agent Data view");
|
||||
require ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$tactical = new Tactical();
|
||||
$tactical->show();
|
||||
}
|
||||
break;
|
||||
case 'logout':
|
||||
$user->logout();
|
||||
|
@ -57,23 +73,79 @@ $user->hackinjectConfig();
|
|||
}
|
||||
else {
|
||||
menu();
|
||||
$page = $system->getRequest('page', 'dashboard');
|
||||
$page = $system->getRequest('page', 'tactical');
|
||||
switch ($page) {
|
||||
default:
|
||||
case 'dashboard':
|
||||
case 'tactical':
|
||||
if (! give_acl ($system->getConfig('id_user'), 0, "AR")) {
|
||||
audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access Agent Data view");
|
||||
require ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$tactical = new Tactical();
|
||||
$tactical->show();
|
||||
break;
|
||||
case 'agents':
|
||||
if (! give_acl ($system->getConfig('id_user'), 0, "AR")) {
|
||||
audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access Agent Data view");
|
||||
require ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$viewAgents = new ViewAgents();
|
||||
$viewAgents->show();
|
||||
break;
|
||||
case 'agent':
|
||||
$viewAgent = new ViewAgent();
|
||||
$viewAgent->show();
|
||||
$action = $system->getRequest('action', 'view_agent');
|
||||
switch ($action) {
|
||||
case 'view_module_graph':
|
||||
$idAgentModule = $system->getRequest('id', 0);
|
||||
$viewGraph = new viewGraph($idAgentModule);
|
||||
$viewGraph->show();
|
||||
break;
|
||||
default:
|
||||
case 'view_agent':
|
||||
$viewAgent = new ViewAgent();
|
||||
$viewAgent->show();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'servers':
|
||||
if (! give_acl ($system->getConfig('id_user'), 0, "PM")) {
|
||||
audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access Agent Data view");
|
||||
require ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$viewServers = new ViewServers();
|
||||
$viewServers->show();
|
||||
break;
|
||||
case 'alerts':
|
||||
if (! give_acl ($system->getConfig('id_user'), 0, "PM")) {
|
||||
audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access Agent Data view");
|
||||
require ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$viewAlerts = new ViewAlerts();
|
||||
$viewAlerts->show();
|
||||
break;
|
||||
case 'groups':
|
||||
if (! give_acl ($system->getConfig('id_user'), 0, "PM")) {
|
||||
audit_db ($system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access Agent Data view");
|
||||
require ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$groupView = new GroupView();
|
||||
$groupView->show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
<?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.
|
||||
|
||||
class GroupView {
|
||||
private $system;
|
||||
|
||||
public function __construct() {
|
||||
global $system;
|
||||
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$groups = get_user_groups ($this->system->getConfig('id_user'));
|
||||
|
||||
$table = null;
|
||||
$table->width = '100%';
|
||||
|
||||
$table->align = array();
|
||||
for($i = 0; $i <= 8; $i++) {
|
||||
$table->align[$i] = 'center';
|
||||
}
|
||||
|
||||
$table->head = array();
|
||||
$table->head[0] = ' ';
|
||||
$table->head[1] = '<span title="' . __('Total Agents') . '" alt="' . __('Total Agents') . '">' . __('T') . '</span>';
|
||||
$table->head[2] = '<span title="' . __('Agent unknown') . '" alt="' . __('Agent unknown') . '">' . __('A') . '</span>';
|
||||
$table->head[3] = '<span title="' . __('Unknown') . '" alt="' . __('Unknown') . '">' . __('U') . '</span>';
|
||||
$table->head[4] = '<span title="' . __('Not Init') . '" alt="' . __('Not Init') . '">' . __('N') . '</span>';
|
||||
$table->head[5] = '<span title="' . __('Normal') . '" alt="' . __('Normal') . '">' . __('N') . '</span>';
|
||||
$table->head[6] = '<span title="' . __('Warning') . '" alt="' . __('Warning') . '">' . __('W') . '</span>';
|
||||
$table->head[7] = '<span title="' . __('Critical') . '" alt="' . __('Critical') . '">' . __('C') . '</span>';
|
||||
$table->head[8] = '<span title="' . __('Alert fired') . '" alt="' . __('Alert fired') . '">' . __('A') . '</span>';
|
||||
|
||||
$rowPair = false;
|
||||
$iterator = 0;
|
||||
foreach ($groups as $idGroup => $group) {
|
||||
if ($rowPair)
|
||||
$table->rowclass[$iterator] = 'rowPair';
|
||||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
if ($idGroup == 0) continue; //avoid the all group
|
||||
$groupData = get_group_stats($idGroup);
|
||||
|
||||
if ($groupData['total_agents'] == 0) continue; //avoid the empty groups
|
||||
|
||||
$data = array();
|
||||
|
||||
$groupName = get_group_name($idGroup);
|
||||
|
||||
$data[] = '<a href="index.php?page=agents&filter_group=' . $idGroup . '"><img alt="' . $groupName . '" title="' . $groupName . '" src="../images/groups_small/' . get_group_icon($idGroup) . '" /></a>';
|
||||
$data[] = $groupData['total_agents'];
|
||||
$data[] = $groupData['agents_unknown'];
|
||||
$data[] = $groupData['monitor_unknown'];
|
||||
$data[] = $groupData['monitor_not_init'];
|
||||
$data[] = $groupData["monitor_ok"];
|
||||
$data[] = $groupData["monitor_warning"];
|
||||
$data[] = $groupData["monitor_critical"];
|
||||
$data[] = $groupData["monitor_alerts_fired"];
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,113 @@
|
|||
<?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.
|
||||
|
||||
class Tactical {
|
||||
private $system;
|
||||
|
||||
function __construct() {
|
||||
global $system;
|
||||
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
function show() {
|
||||
$img = "../include/fgraph.php?tipo=progress&height=8&width=70&mode=0&percent=";
|
||||
|
||||
$data = get_group_stats();
|
||||
|
||||
$table = null;
|
||||
$table->width = '100%';
|
||||
|
||||
$table->size[0] = '10px';
|
||||
|
||||
$table->align[0] = 'center';
|
||||
$table->align[3] = 'right';
|
||||
|
||||
$table->colspan = array();
|
||||
$table->colspan[0][0] = 2;
|
||||
$table->colspan[0][1] = 2;
|
||||
|
||||
$table->data[0][0] = "<h3 class='title_h3_server'>" . __('Status') . "</h3>" ;
|
||||
$table->data[1][0] = '<span title="' . __('Global health') . '" alt="' . __('Global health') . '">' . __('G') . '</span> ';
|
||||
$table->data[1][1] = print_image ($img.$data["global_health"], true);
|
||||
$table->data[2][0] = '<span title="' . __('Monitor health') . '" alt="' . __('Monitor health') . '">' . __('M') . '</span> ';
|
||||
$table->data[2][1] = print_image ($img.$data["monitor_health"], true);
|
||||
$table->data[3][0] = '<span title="' . __('Module sanity') . '" alt="' . __('Module sanity') . '">' . __('M') . '</span> ';
|
||||
$table->data[3][1] = print_image ($img.$data["module_sanity"], true);
|
||||
$table->data[4][0] = '<span title="' . __('Alert level') . '" alt="' . __('Alert level') . '">' . __('A') . '</span> ';
|
||||
$table->data[4][1] = print_image ($img.$data["alert_level"], true);
|
||||
$table->data[5][0] = $table->data[5][1] = '';
|
||||
$table->data[6][0] = $table->data[6][1] = '';
|
||||
$table->data[7][0] = $table->data[7][1] = '';
|
||||
$table->data[8][0] = $table->data[8][1] = '';
|
||||
|
||||
$table->data[0][1] = "<h3 class='title_h3_server'>" . __('Monitor checks') . "</h3>";
|
||||
$table->data[1][2] = __('Monitor checks');
|
||||
$table->data[1][3] = $data["monitor_checks"];
|
||||
$table->data[2][2] = '<span style="color: #c00;">' . __('Monitors critical') . '</span>';
|
||||
$table->data[2][3] = '<span style="color: #c00;">' . $data["monitor_critical"] . '</span>';
|
||||
$table->data[3][2] = '<span style="color: #ffcc00;">' . __('Monitors warning') .'</span>';
|
||||
$table->data[3][3] = '<span style="color: #ffcc00;">' . $data["monitor_warning"] . '</span>';
|
||||
$table->data[4][2] = '<span style="color: #8ae234;">' . __('Monitors normal') . '</span>';
|
||||
$table->data[4][3] = '<span style="color: #8ae234;">' . $data["monitor_ok"] . '</span>';
|
||||
$table->data[5][2] = '<span style="color: #aaa;">' . __('Monitors unknown') . '</span>';
|
||||
$table->data[5][3] = '<span style="color: #aaa;">' . $data["monitor_unknown"] . '</span>';
|
||||
$table->data[6][2] = '<span style="color: #ef2929;">' . __('Monitors not init') . '</span>';
|
||||
$table->data[6][3] = '<span style="color: #ef2929;">' . $data["monitor_not_init"] . '</span>';
|
||||
$table->data[7][2] = '<span style="color: #000;">' . __('Alerts defined') . '</span>';
|
||||
$table->data[7][3] = '<span style="color: #000;">' . $data["monitor_alerts"] . '</span>';
|
||||
$table->data[8][2] = '<span style="color: #ff8800;">' . __('Alerts fired') . '</span>';
|
||||
$table->data[8][3] = '<span style="color: #ff8800;">' . $data["monitor_alerts_fired"] . '</span>';
|
||||
|
||||
print_table($table);
|
||||
|
||||
echo "<h3 class='title_h3_server'>" . __('Server performance') . "</h3>";
|
||||
|
||||
$server_performance = get_server_performance();
|
||||
|
||||
$table = null;
|
||||
$table->width = '100%';
|
||||
|
||||
$table->align = array();
|
||||
$table->align[1] = 'right';
|
||||
|
||||
$table->data[0][0] = '<span style="color: #729fcf;">' . __('Local modules rate') . '</span>';
|
||||
$table->data[0][1] = '<span style="color: #729fcf;">' . format_numeric($server_performance ["local_modules_rate"]) . '</span>';
|
||||
$table->data[1][0] = '<span style="color: #729fcf;">' . __('Remote modules rate') . '</span>';
|
||||
$table->data[1][1] = '<span style="color: #729fcf;">' . format_numeric($server_performance ["remote_modules_rate"]) . '</span>';
|
||||
$table->data[2][0] = '<span style="color: #3465a4;">' . __('Local modules') . '</span>';
|
||||
$table->data[2][1] = '<span style="color: #3465a4;">' . format_numeric($server_performance ["total_local_modules"]) . '</span>';
|
||||
$table->data[3][0] = '<span style="color: #3465a4;">' . __('Remote modules') . '</span>';
|
||||
$table->data[3][1] = '<span style="color: #3465a4;">' . format_numeric($server_performance ["total_remote_modules"]) . '</span>';
|
||||
$table->data[4][0] = '<span style="color: #000;">' . __('Total running modules') . '</span>';
|
||||
$table->data[4][1] = '<span style="color: #000;">' . format_numeric($server_performance ["total_modules"]) . '</span>';
|
||||
|
||||
print_table($table);
|
||||
|
||||
echo "<h3 class='title_h3_server'>" . __('Summary') . "</h3>";
|
||||
|
||||
$table = null;
|
||||
$table->width = '100%';
|
||||
$table->align[1] = 'right';
|
||||
$table->data[0][0] = '<span style="color: #000;">' . __('Total agents') . '</span>';
|
||||
$table->data[0][1] = '<span style="color: #000;">' . $data["total_agents"] . '</span>';
|
||||
$table->data[1][0] = '<span style="color: #ef2929;">' . __('Uninitialized modules') . '</span>';
|
||||
$table->data[1][1] = '<span style="color: #ef2929;">' . $data["server_sanity"] . '</span>';
|
||||
$table->data[2][0] = '<span style="color: #aaa;">' . __('Agents unknown') . '</span>';
|
||||
$table->data[2][1] = '<span style="color: #aaa;">' . $data["agents_unknown"] . '</span>';
|
||||
|
||||
print_table($table);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -15,6 +15,7 @@
|
|||
require_once("../include/functions_agents.php");
|
||||
require_once("../include/functions_reporting.php");
|
||||
require_once("../include/functions_alerts.php");
|
||||
require_once("../include/functions_modules.php");
|
||||
|
||||
class ViewAgents {
|
||||
private $user;
|
||||
|
@ -98,6 +99,7 @@ class ViewAgents {
|
|||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$agent_info = get_agent_module_info ($agent["id_agente"]); //$this->system->debug($agent_info);
|
||||
|
||||
|
@ -167,6 +169,14 @@ class ViewAgent {
|
|||
}
|
||||
|
||||
public function show() {
|
||||
$idGroup = $this->agent['id_grupo'];
|
||||
if (! give_acl ($this->system->getConfig('id_user'), $idGroup, "AR")) {
|
||||
audit_db ($this->system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access (read) to agent ".get_agent_name($this->idAgent));
|
||||
include ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$table = null;
|
||||
|
||||
$table->width = '100%';
|
||||
|
@ -178,7 +188,7 @@ class ViewAgent {
|
|||
$table->data[1][0] = __('IP:');
|
||||
$table->data[1][1] = implode(',', $this->ips);
|
||||
$table->data[2][0] = __('OS:');
|
||||
$table->data[2][1] = str_replace('images/os_icons/', '../images/os_icons/', print_os_icon($this->agent['id_os']));
|
||||
$table->data[2][1] = str_replace('images/os_icons/', '../images/os_icons/', print_os_icon($this->agent['id_os'], true, true));
|
||||
$table->data[3][0] = __('Last contact');
|
||||
$table->data[3][1] = $this->agent['ultimo_contacto'];
|
||||
|
||||
|
@ -222,10 +232,11 @@ class ViewAgent {
|
|||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$data = array();
|
||||
|
||||
$data[] = printTruncateText($module["nombre"], 10, true, true);
|
||||
$data[] = '<a href="index.php?page=agent&action=view_module_graph&id=' . $module['id_agente_modulo'] . '">' . printTruncateText($module["nombre"], 10, true, true) . '</a>';
|
||||
$status = STATUS_MODULE_WARNING;
|
||||
$title = "";
|
||||
|
||||
|
@ -315,12 +326,15 @@ class ViewAgent {
|
|||
|
||||
echo "<h3 class='title_h3'>" . __('Alerts') . "</h3>";
|
||||
$alertsSimple = get_agent_alerts_simple (array($this->idAgent));
|
||||
$rowPair = false;
|
||||
$iterator = 0;
|
||||
foreach ($alertsSimple as $alert) {
|
||||
if ($rowPair)
|
||||
$table->rowclass[$iterator] = 'rowPair';
|
||||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$data = array();
|
||||
|
||||
|
@ -382,4 +396,149 @@ class ViewAgent {
|
|||
// }
|
||||
}
|
||||
}
|
||||
|
||||
class viewGraph {
|
||||
private $system;
|
||||
private $idAgentModule;
|
||||
|
||||
function __construct($idAgentModule = 0) {
|
||||
global $system;
|
||||
|
||||
$this->system = $system;
|
||||
$this->idAgentModule = $idAgentModule;
|
||||
$this->agentModule = get_db_row_filter('tagente_modulo', array('id_agente_modulo' => $this->idAgentModule));
|
||||
//$this->system->debug($this->agentModule);
|
||||
$this->period = $this->system->getRequest('period', 86400);
|
||||
$this->offset = $this->system->getRequest("offset", 0);
|
||||
|
||||
$this->agent = get_db_row_filter('tagente', array('id_agente' => $this->agentModule['id_agente']));
|
||||
}
|
||||
|
||||
function show() {
|
||||
$idGroup = $this->agent['id_grupo'];
|
||||
if (! give_acl ($this->system->getConfig('id_user'), $idGroup, "AR")) {
|
||||
audit_db ($this->system->getConfig('id_user'), $_SERVER['REMOTE_ADDR'], "ACL Violation",
|
||||
"Trying to access (read) to agent ".get_agent_name($this->idAgent));
|
||||
include ("../general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$image = "../include/fgraph.php?tipo=sparse_mobile&draw_alerts=1&draw_events=1' .
|
||||
'&id=" . $this->idAgentModule . "&zoom=1&label=".safe_output($this->agentModule['nombre']) .
|
||||
"&height=120&width=240&period=" . $this->period . "&avg_only=0";
|
||||
|
||||
$image .= "&date=" . get_system_time ();
|
||||
|
||||
echo "<h3 class='title_h3'><a href='index.php?page=agent&id=" . $this->agentModule['id_agente'] . "'>" . get_agentmodule_agent_name($this->idAgentModule)."</a> / ".safe_output($this->agentModule['nombre']) . "</h3>";
|
||||
|
||||
echo "<h3 class='title_h3'>" . __('Graph') . "</h3>";
|
||||
print_image ($image, false, array ("border" => 0));
|
||||
|
||||
echo "<h3 class='title_h3'>" . __('Data') . "</h3>";
|
||||
|
||||
echo "<form method='post' action='index.php?page=agent&action=view_module_graph&id=" . $this->idAgentModule . "'>";
|
||||
echo __("Choose period:");
|
||||
$intervals = array ();
|
||||
$intervals[3600] = human_time_description_raw (3600); // 1 hour
|
||||
$intervals[86400] = human_time_description_raw (86400); // 1 day
|
||||
$intervals[604800] = human_time_description_raw (604800); // 1 week
|
||||
$intervals[2592000] = human_time_description_raw (2592000); // 1 month
|
||||
echo print_extended_select_for_time ($intervals, 'period', $this->period, 'this.form.submit();', '', '0', 5) . __(" secs");
|
||||
echo "</form><br />";
|
||||
|
||||
$moduletype_name = get_moduletype_name (get_agentmodule_type ($this->idAgentModule));
|
||||
|
||||
if ($moduletype_name == "log4x") {
|
||||
$sql_body = sprintf ("FROM tagente_datos_log4x
|
||||
WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
|
||||
|
||||
$columns = array(
|
||||
|
||||
//"Timestamp" => array("utimestamp", "format_timestamp", "align" => "center" ),
|
||||
"Sev" => array("severity", "format_data", "align" => "center", "width" => "70px"),
|
||||
"Message" => array("message", "format_verbatim", "align" => "left", "width" => "45%"),
|
||||
"StackTrace" => array("stacktrace", "format_verbatim", "align" => "left", "width" => "50%")
|
||||
);
|
||||
}
|
||||
else if (preg_match ("/string/", $moduletype_name)) {
|
||||
$sql_body = sprintf (" FROM tagente_datos_string
|
||||
WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
|
||||
|
||||
$columns = array(
|
||||
//"Timestamp" => array("utimestamp", "format_timestamp", "align" => "center"),
|
||||
"Data" => array("datos", "format_data", "align" => "center"),
|
||||
"Time" => array("utimestamp", "format_time", "align" => "center")
|
||||
);
|
||||
}
|
||||
else {
|
||||
$sql_body = sprintf (" FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $this->idAgentModule, (get_system_time () - $this->period));
|
||||
|
||||
$columns = array(
|
||||
//"Timestamp" => array("utimestamp", "format_timestamp", "align" => "center"),
|
||||
"Data" => array("datos", "format_data", "align" => "center"),
|
||||
"Time" => array("utimestamp", "format_time", "align" => "center")
|
||||
);
|
||||
}
|
||||
|
||||
$sql_count = 'SELECT COUNT(*) ' . $sql_body;
|
||||
|
||||
$count = get_db_value_sql($sql_count);
|
||||
|
||||
$sql = 'SELECT * ' . $sql_body . ' LIMIT ' . $this->offset . ',' . $this->system->getPageSize();
|
||||
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
||||
$table = null;
|
||||
$table->width = '100%';
|
||||
$table->head = array();
|
||||
$index = 0;
|
||||
foreach($columns as $col => $attr) {
|
||||
$table->head[$index] = $col;
|
||||
|
||||
if (isset($attr["align"]))
|
||||
$table->align[$index] = $attr["align"];
|
||||
|
||||
if (isset($attr["width"]))
|
||||
$table->size[$index] = $attr["width"];
|
||||
|
||||
$index++;
|
||||
}
|
||||
|
||||
$table->data = array(); //$this->system->debug($result);
|
||||
$rowPair = false;
|
||||
$iterator = 0;
|
||||
foreach ($result as $row) {
|
||||
if ($rowPair)
|
||||
$table->rowclass[$iterator] = 'rowPair';
|
||||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$data = array ();
|
||||
|
||||
foreach($columns as $col => $attr){
|
||||
$data[] = $attr[1] ($row[$attr[0]]);
|
||||
//debugPrint( "\$data[] = ".$attr[1]." (".$row[$attr[0]].");");
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
$pagination = pagination ($count,
|
||||
get_url_refresh (array ('period' => $this->period)),
|
||||
0, 0, true);
|
||||
|
||||
$pagination = str_replace('images/go_first.png', '../images/go_first.png', $pagination);
|
||||
$pagination = str_replace('images/go_previous.png', '../images/go_previous.png', $pagination);
|
||||
$pagination = str_replace('images/go_next.png', '../images/go_next.png', $pagination);
|
||||
$pagination = str_replace('images/go_last.png', '../images/go_last.png', $pagination);
|
||||
|
||||
echo $pagination;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,89 @@
|
|||
<?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.
|
||||
|
||||
class ViewAlerts {
|
||||
private $system;
|
||||
|
||||
public function __construct() {
|
||||
global $system;
|
||||
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$table = null;
|
||||
$table->width = '100%';
|
||||
$table->head = array();
|
||||
$table->head[0] = __('Module');
|
||||
$table->head[1] = __('Template');
|
||||
$table->head[2] = __('Action');
|
||||
$table->head[2] = '<span title="' . __('Last fired') . '" alt="' . __('Last fired') . '">' . __('Last') . '</span>';
|
||||
$table->head[3] = '<span title="' . __('Status') . '" alt="' . __('Status') . '">' . __('S') . '</span>';
|
||||
|
||||
|
||||
$table->align = array();
|
||||
$table->align[3] = 'right';
|
||||
$table->align[2] = 'center';
|
||||
$table->data = array();
|
||||
$table->rowclass = array();
|
||||
|
||||
$groups = get_user_groups($this->system->getConfig('id_user'));
|
||||
$idGroups = array_keys($groups);
|
||||
$agents = get_group_agents($idGroups);
|
||||
|
||||
$alertsSimple = get_agent_alerts_simple($agents);
|
||||
|
||||
$rowPair = false;
|
||||
$iterator = 0;
|
||||
foreach ($alertsSimple as $alert) {
|
||||
if ($rowPair)
|
||||
$table->rowclass[$iterator] = 'rowPair';
|
||||
else
|
||||
$table->rowclass[$iterator] = 'rowOdd';
|
||||
$rowPair = !$rowPair;
|
||||
$iterator++;
|
||||
|
||||
$data = array();
|
||||
|
||||
$idAgent = get_agentmodule_agent($alert["id_agent_module"]);
|
||||
|
||||
$data[] = '<a href="index.php?page=agent&id=' . $idAgent . '">' . printTruncateText(get_agentmodule_name($alert["id_agent_module"]), 10, true, true) . '</a>';
|
||||
$template = safe_output(get_alert_template ($alert['id_alert_template']));
|
||||
$data[] = printTruncateText(safe_output($template['name']), 10, true, true);
|
||||
$data[] = print_timestamp ($alert["last_fired"], true, array('units' => 'tiny'));
|
||||
|
||||
$status = STATUS_ALERT_NOT_FIRED;
|
||||
$title = "";
|
||||
|
||||
if ($alert["times_fired"] > 0) {
|
||||
$status = STATUS_ALERT_FIRED;
|
||||
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
|
||||
} elseif ($alert["disabled"] > 0) {
|
||||
$status = STATUS_ALERT_DISABLED;
|
||||
$title = __('Alert disabled');
|
||||
} else {
|
||||
$status = STATUS_ALERT_NOT_FIRED;
|
||||
$title = __('Alert not fired');
|
||||
}
|
||||
|
||||
$data[] = str_replace('.png', '_ball.png', str_replace('images/status_sets',
|
||||
'../images/status_sets', print_status_image($status, $title, true)));
|
||||
|
||||
$table->data[] = $data;
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -47,10 +47,10 @@ class ViewServers {
|
|||
$data = array();
|
||||
|
||||
if ($server['status'] == 0) {
|
||||
$server_status = print_status_image (STATUS_SERVER_DOWN, '', true);
|
||||
$server_status = print_status_image(STATUS_SERVER_DOWN, '', true);
|
||||
}
|
||||
else {
|
||||
$server_status = print_status_image (STATUS_SERVER_OK, '', true);
|
||||
$server_status = print_status_image(STATUS_SERVER_OK, '', true);
|
||||
}
|
||||
$data[] = strip_tags($server["name"]);
|
||||
$data[] = str_replace('images/', '../images/', $server['img']);
|
||||
|
|
|
@ -20,6 +20,8 @@ global $config;
|
|||
|
||||
check_login();
|
||||
|
||||
require_once('include/functions_modules.php');
|
||||
|
||||
$module_id = get_parameter_get ("id", 0);
|
||||
$period = get_parameter ("period", 86400);
|
||||
$group = get_agentmodule_group ($module_id);
|
||||
|
@ -145,82 +147,11 @@ foreach ($result as $row) {
|
|||
|
||||
if (empty ($table->data)) {
|
||||
echo '<h3 class="error">'.__('There was a problem locating the source of the graph').'</h3>';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pagination($count);
|
||||
print_table ($table);
|
||||
unset ($table);
|
||||
}
|
||||
|
||||
//
|
||||
// This are functions to format the data
|
||||
//
|
||||
|
||||
function format_time($ts)
|
||||
{
|
||||
return print_timestamp ($ts, true, array("prominent" => "comparation"));
|
||||
}
|
||||
|
||||
function format_data($data)
|
||||
{
|
||||
if (is_numeric ($data)) {
|
||||
$data = format_numeric($data, 2);
|
||||
} else {
|
||||
$data = safe_input ($data);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function format_verbatim($data){
|
||||
// We need to replace \n by <br> to create a "similar" output to
|
||||
// information recolected in logs.
|
||||
$data2 = preg_replace ("/\\n/", "<br>", $data);
|
||||
return "<span style='font-size:10px;'>" . $data2 . "</span>";
|
||||
}
|
||||
|
||||
function format_timestamp($ts)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// This returns data with absolute user-defined timestamp format
|
||||
// and numeric by data managed with 2 decimals, and not using Graph format
|
||||
// (replacing 1000 by K and 1000000 by G, like version 2.x
|
||||
return date ($config["date_format"], $ts);
|
||||
}
|
||||
|
||||
function format_delete($id)
|
||||
{
|
||||
global $period, $module_id, $config, $group;
|
||||
|
||||
$txt = "";
|
||||
|
||||
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
||||
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
function format_delete_string($id)
|
||||
{
|
||||
global $period, $module_id, $config, $group;
|
||||
|
||||
$txt = "";
|
||||
|
||||
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
||||
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete_string='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
function format_delete_log4x($id)
|
||||
{
|
||||
global $period, $module_id, $config, $group;
|
||||
|
||||
$txt = "";
|
||||
|
||||
if (give_acl ($config['id_user'], $group, "AW") ==1) {
|
||||
$txt = '<a href="index.php?sec=estado&sec2=operation/agentes/datos_agente&period='.$period.'&id='.$module_id.'&delete_log4x='.$id.'"><img src="images/cross.png" border="0" /></a>';
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -61,7 +61,6 @@ $counter = 1;
|
|||
// Old style table, we need a lot of special formatting,don't use table function
|
||||
// Prepare old-style table
|
||||
|
||||
|
||||
foreach ($groups as $id_group) {
|
||||
$data = get_group_stats($id_group);
|
||||
|
||||
|
@ -102,15 +101,20 @@ foreach ($groups as $id_group => $group_name) {
|
|||
// Calculate entire row color
|
||||
if ($data["monitor_alerts_fired"] > 0){
|
||||
echo "<tr style='background-color: #ffd78f; height: 35px; '>";
|
||||
} elseif ($data["monitor_critical"] > 0) {
|
||||
}
|
||||
elseif ($data["monitor_critical"] > 0) {
|
||||
echo "<tr style='background-color: #ffc0b5; height: 35px;'>";
|
||||
} elseif ($data["monitor_warning"] > 0) {
|
||||
}
|
||||
elseif ($data["monitor_warning"] > 0) {
|
||||
echo "<tr style='background-color: #f4ffbf; height: 35px;'>";
|
||||
} elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) {
|
||||
}
|
||||
elseif (($data["monitor_unknown"] > 0) || ($data["agents_unknown"] > 0)) {
|
||||
echo "<tr style='background-color: #ddd; height: 35px;'>";
|
||||
} elseif ($data["monitor_ok"] > 0) {
|
||||
}
|
||||
elseif ($data["monitor_ok"] > 0) {
|
||||
echo "<tr style='background-color: #bbffa4; height: 35px;'>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<tr style='height: 35px;'>";
|
||||
}
|
||||
|
||||
|
@ -139,7 +143,8 @@ foreach ($groups as $id_group => $group_name) {
|
|||
echo "<td style='font-weight: bold; font-size: 18px; color: #886666; text-align: center;'>";
|
||||
echo $data["agents_unknown"];
|
||||
echo "</td>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
|
@ -148,7 +153,8 @@ foreach ($groups as $id_group => $group_name) {
|
|||
echo "<td style='font-weight: bold; font-size: 18px; color: #666; text-align: center;'>";
|
||||
echo $data["monitor_unknown"];
|
||||
echo "</td>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
|
@ -158,17 +164,20 @@ foreach ($groups as $id_group => $group_name) {
|
|||
echo "<td style='font-weight: bold; font-size: 18px; color: #729fcf; text-align: center;'>";
|
||||
echo $data["monitor_not_init"];
|
||||
echo "</td>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
|
||||
// Monitors OK
|
||||
echo "<td style='font-weight: bold; font-size: 18px; color: #6ec300; text-align: center;'>";
|
||||
if ($data["monitor_ok"] > 0)
|
||||
if ($data["monitor_ok"] > 0) {
|
||||
echo $data["monitor_ok"];
|
||||
else
|
||||
}
|
||||
else {
|
||||
echo " ";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
// Monitors Warning
|
||||
|
@ -176,7 +185,8 @@ foreach ($groups as $id_group => $group_name) {
|
|||
echo "<td style='font-weight: bold; font-size: 18px; color: #f2ef00; text-align: center;'>";
|
||||
echo $data["monitor_warning"];
|
||||
echo "</td>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
|
@ -185,7 +195,8 @@ foreach ($groups as $id_group => $group_name) {
|
|||
echo "<td style='font-weight: bold; font-size: 18px; color: #bc0000; text-align: center;'>";
|
||||
echo $data["monitor_critical"];
|
||||
echo "</td>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
// Alerts fired
|
||||
|
@ -193,7 +204,8 @@ foreach ($groups as $id_group => $group_name) {
|
|||
echo "<td style='font-weight: bold; font-size: 18px; color: #ffa300; text-align: center;'>";
|
||||
echo $data["monitor_alerts_fired"];
|
||||
echo "</td>";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
|
|
|
@ -86,25 +86,29 @@ $table->style[0] = "padding-top:4px; padding-bottom:4px;";
|
|||
$table->data[0][0] ='<b>'.__('Global health').'</b>';
|
||||
|
||||
$table->style[1] = "padding-top:4px; padding-bottom:4px;";
|
||||
$table->data[1][0] = print_image ($img.$data["global_health"], true, array ("width" => '100%', "height" => 20, "title" => $data["global_health"].'% '.__('of monitors OK')));
|
||||
$table->data[1][0] = print_image ($img.$data["global_health"], true,
|
||||
array ("width" => '100%', "height" => 20, "title" => $data["global_health"].'% '.__('of monitors OK')));
|
||||
|
||||
$table->style[2] = "padding-top:4px; padding-bottom:4px;";
|
||||
$table->data[2][0] ='<b>'.__('Monitor health').'</b>';
|
||||
|
||||
$table->style[3] = "padding-top:4px; padding-bottom:4px;";
|
||||
$table->data[3][0] = print_image ($img.$data["monitor_health"], true, array ("width" => '100%', "height" => 20, "title" => $data["monitor_health"].'% '.__('of monitors up')));
|
||||
$table->data[3][0] = print_image ($img.$data["monitor_health"], true,
|
||||
array ("width" => '100%', "height" => 20, "title" => $data["monitor_health"].'% '.__('of monitors up')));
|
||||
|
||||
$table->style[4] = "padding-top:4px; padding-bottom:4px;";
|
||||
$table->data[4][0] = '<b>'.__('Module sanity').'</b>';
|
||||
|
||||
$table->style[5] = "padding-top:4px; padding-bottom:4px;";
|
||||
$table->data[5][0] = print_image ($img.$data["module_sanity"], true, array ("width" => '100%', "height" => 20, "title" => $data["module_sanity"].'% '.__('of total modules inited')));
|
||||
$table->data[5][0] = print_image ($img.$data["module_sanity"], true,
|
||||
array ("width" => '100%', "height" => 20, "title" => $data["module_sanity"].'% '.__('of total modules inited')));
|
||||
|
||||
$table->style[6] = "padding-top:4px; padding-bottom:4px;";
|
||||
$table->data[6][0] = '<b>'.__('Alert level').'</b>';
|
||||
|
||||
$table->style[7] = "padding-top:4px; padding-bottom:4px;";
|
||||
$table->data[7][0] = print_image ($img.$data["alert_level"], true, array ("width" => '100%', "height" => 20, "title" => $data["alert_level"].'% '.__('of defined alerts not fired')));
|
||||
$table->data[7][0] = print_image ($img.$data["alert_level"], true,
|
||||
array ("width" => '100%', "height" => 20, "title" => $data["alert_level"].'% '.__('of defined alerts not fired')));
|
||||
|
||||
print_table ($table);
|
||||
unset ($table);
|
||||
|
|
Loading…
Reference in New Issue