2013-03-15 15:50:47 +01:00
< ? 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.
include ( " ../include/functions_reporting.php " );
include ( " ../include/functions_servers.php " );
class Tactical {
private $correct_acl = false ;
function __construct () {
$system = System :: getInstance ();
if ( $system -> checkACL ()) {
$this -> correct_acl = true ;
}
else {
$this -> correct_acl = false ;
}
}
public function show () {
if ( ! $this -> correct_acl ) {
$this -> show_fail_acl ();
}
else {
$this -> show_tactical ();
}
}
private function show_fail_acl () {
$ui = Ui :: getInstance ();
$ui -> createPage ();
2013-03-21 19:47:28 +01:00
$options [ 'type' ] = 'onStart' ;
$options [ 'title_text' ] = __ ( 'You don\'t have access to this page' );
$options [ 'content_text' ] = __ ( 'Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database' );
$ui -> addDialog ( $options );
2013-03-15 15:50:47 +01:00
$ui -> showPage ();
}
private function show_tactical () {
$ui = Ui :: getInstance ();
$ui -> createPage ();
$ui -> createDefaultHeader ( __ ( " PandoraFMS: Tactical " ));
$ui -> showFooter ( false );
$ui -> beginContent ();
$ui -> contentBeginGrid ( 'responsive' );
$data = reporting_get_group_stats ();
2013-03-26 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_reporting.php, include/functions_groups.php:
changes for to use in the calls in mobile version.
* mobile/index.php, mobile/operation/events.php,
mobile/operation/modules.php, mobile/operation/events,
mobile/operation/events/events.php, mobile/operation/agents.php,
mobile/operation/tactical.php, mobile/operation/alerts.php,
mobile/include/style/main.css, mobile/include/ui.class.php,
mobile/include/user.class.php: changes and improves in the code
of mobile.
* mobile/operation/agents/*, mobile/operation/servers/*: removed
the old files from version pandora mobile 4.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7891 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-26 18:24:10 +01:00
$data [ 'mobile' ] = true ;
2013-03-15 15:50:47 +01:00
$formatted_data = reporting_get_stats_indicators ( $data , 280 , 20 , false );
$overview = ' < fieldset class = " databox " style = " width:97%; " >
< legend style = " text-align:left; color: #666; " > ' .
$formatted_data [ 'server_health' ][ 'title' ] .
'</legend>' .
$formatted_data [ 'server_health' ][ 'graph' ] .
'</fieldset>' .
' < fieldset class = " databox " style = " width:97%; " >
< legend style = " text-align:left; color: #666; " > ' .
$formatted_data [ 'monitor_health' ][ 'title' ] .
'</legend>' .
$formatted_data [ 'monitor_health' ][ 'graph' ] .
'</fieldset>' .
'</fieldset>' .
' < fieldset class = " databox " style = " width:97%; " >
< legend style = " text-align:left; color: #666; " > ' .
$formatted_data [ 'module_sanity' ][ 'title' ] .
'</legend>' .
$formatted_data [ 'module_sanity' ][ 'graph' ] .
'</fieldset>' .
'</fieldset>' .
' < fieldset class = " databox " style = " width:97%; " >
< legend style = " text-align:left; color: #666; " > ' .
$formatted_data [ 'alert_level' ][ 'title' ] .
'</legend>' .
$formatted_data [ 'alert_level' ][ 'graph' ] .
'</fieldset>' ;
$ui -> contentGridAddCell ( $overview );
$formatted_data = reporting_get_stats_alerts ( $data );
ob_start ();
$formatted_data .= reporting_get_stats_modules_status ( $data ) . " <br /> \n " .
reporting_get_stats_agents_monitors ( $data );
$graph_js = ob_get_clean ();
$formatted_data = $graph_js . $formatted_data ;
2013-03-27 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/operation/tactical.php,
mobile/include/ui.class.php, mobile/include/style/main.css,
mobile/images/datos_blue.png, mobile/images/datos_brown.png,
mobile/images/datos_green.png, mobile/images/datos_pink.png,
mobile/images/datos_grey.png, mobile/images/datos_red.png,
mobile/images/datos_yellow.png: some fixes and changes in the
Pandora mobile.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7895 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-27 18:51:35 +01:00
$ui -> contentGridAddCell ( $formatted_data , 'tactical' );
2013-03-15 15:50:47 +01:00
$ui -> contentEndGrid ();
$this -> getLastActivity ();
$ui -> contentBeginCollapsible ( __ ( 'Last activity' ));
$table = new Table ();
$table -> importFromHash ( $this -> getLastActivity ());
$ui -> contentCollapsibleAddItem ( $table -> getHTML ());
$ui -> contentEndCollapsible ();
$ui -> endContent ();
$ui -> showPage ();
}
private function getLastActivity () {
global $config ;
switch ( $config [ " dbtype " ]) {
case " mysql " :
$sql = sprintf ( " SELECT id_usuario,accion,fecha,ip_origen,descripcion,utimestamp
FROM tsesion
WHERE ( `utimestamp` > UNIX_TIMESTAMP ( NOW ()) - " . SECONDS_1WEEK . " )
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10 " , $config["id_user"] );
break ;
case " postgresql " :
$sql = sprintf ( " SELECT \" id_usuario \" , accion, fecha, \" ip_origen \" , descripcion, utimestamp
FROM tsesion
WHERE ( \ " utimestamp \" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - " . SECONDS_1WEEK . " )
AND \ " id_usuario \" = '%s' ORDER BY \" utimestamp \" DESC LIMIT 10 " , $config [ " id_user " ]);
break ;
case " oracle " :
$sql = sprintf ( " SELECT id_usuario, accion, fecha, ip_origen, descripcion, utimestamp
FROM tsesion
WHERE (( utimestamp > ceil (( sysdate - to_date ( '19700101000000' , 'YYYYMMDDHH24MISS' )) * ( " . SECONDS_1DAY . " )) - " . SECONDS_1WEEK . " )
AND id_usuario = '%s' ) AND rownum <= 10 ORDER BY utimestamp DESC " , $config["id_user"] );
break ;
}
$sessions = db_get_all_rows_sql ( $sql );
if ( $sessions === false )
$sessions = array ();
$return = array ();
foreach ( $sessions as $session ) {
$data = array ();
switch ( $config [ " dbtype " ]) {
case " mysql " :
case " oracle " :
$session_id_usuario = $session [ 'id_usuario' ];
$session_ip_origen = $session [ 'ip_origen' ];
break ;
case " postgresql " :
$session_id_usuario = $session [ 'id_usuario' ];
$session_ip_origen = $session [ 'ip_origen' ];
break ;
}
$data [ __ ( " User " )] = '<strong>' . $session_id_usuario . '</strong>' ;
$data [ __ ( " Action " )] = ui_print_session_action_icon ( $session [ 'accion' ], true );
$data [ __ ( " Action " )] .= $session [ 'accion' ];
$data [ __ ( " Date " )] = human_time_comparation ( $session [ 'utimestamp' ]);
$data [ __ ( " Source IP " )] = $session_ip_origen ;
$data [ __ ( " Description " )] = io_safe_output ( $session [ 'descripcion' ]);
$return [] = $data ;
}
return $return ;
}
}
?>