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
< ? 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 Modules {
private $correct_acl = false ;
private $acl = " AR " ;
private $default = true ;
private $group = 0 ;
private $status = AGENT_MODULE_STATUS_NOT_NORMAL ;
private $free_search = '' ;
private $module_group = - 1 ;
private $tag = '' ;
2013-04-09 11:29:03 +02:00
private $id_agent = 0 ;
private $all_modules = false ;
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
private $list_status = null ;
2013-04-09 11:29:03 +02:00
private $columns = null ;
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
function __construct () {
$system = System :: getInstance ();
$this -> list_status = array (
- 1 => __ ( 'All' ),
AGENT_MODULE_STATUS_NORMAL => __ ( 'Normal' ),
AGENT_MODULE_STATUS_WARNING => __ ( 'Warning' ),
AGENT_MODULE_STATUS_CRITICAL_BAD => __ ( 'Critical' ),
AGENT_MODULE_STATUS_UNKNOW => __ ( 'Unknown' ),
AGENT_MODULE_STATUS_NOT_NORMAL => __ ( 'Not normal' ), //default
AGENT_MODULE_STATUS_NOT_INIT => __ ( 'Not init' ));
2013-04-09 11:29:03 +02:00
$this -> columns = array ( 'agent' => 1 );
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
if ( $system -> checkACL ( $this -> acl )) {
$this -> correct_acl = true ;
}
else {
$this -> correct_acl = false ;
}
}
public function ajax ( $parameter2 = false ) {
$system = System :: getInstance ();
if ( ! $this -> correct_acl ) {
return ;
}
else {
switch ( $parameter2 ) {
case 'get_modules' :
$this -> getFilters ();
$page = $system -> getRequest ( 'page' , 0 );
$modules = array ();
$end = 1 ;
$listModules = $this -> getListModules ( $page , true );
if ( ! empty ( $listModules [ 'modules' ])) {
$end = 0 ;
$modules = $listModules [ 'modules' ];
}
echo json_encode ( array ( 'end' => $end , 'modules' => $modules ));
break ;
}
}
}
2013-04-09 11:29:03 +02:00
public function setFilters ( $filters ) {
if ( isset ( $filters [ 'id_agent' ])) {
$this -> id_agent = $filters [ 'id_agent' ];
}
if ( isset ( $filters [ 'all_modules' ])) {
$this -> all_modules = $filters [ 'all_modules' ];
}
}
public function disabledColumns ( $columns = null ) {
if ( ! empty ( $columns )) {
foreach ( $columns as $column ) {
unset ( $this -> columns [ $column ]);
}
}
}
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
private function getFilters () {
$system = System :: getInstance ();
$user = User :: getInstance ();
$this -> free_search = $system -> getRequest ( 'free_search' , '' );
if ( $this -> free_search != '' ) {
$this -> default = false ;
}
$this -> status = $system -> getRequest ( 'status' , __ ( " Status " ));
if (( $this -> status === __ ( " Status " )) || ( $this -> status == AGENT_MODULE_STATUS_NOT_NORMAL )) {
$this -> status = AGENT_MODULE_STATUS_NOT_NORMAL ;
}
else {
$this -> default = false ;
}
$this -> group = ( int ) $system -> getRequest ( 'group' , __ ( " Group " ));
if ( ! $user -> isInGroup ( $this -> acl , $this -> group )) {
$this -> group = 0 ;
}
if (( $this -> group === __ ( " Group " )) || ( $this -> group == 0 )) {
$this -> group = 0 ;
}
else {
$this -> default = false ;
}
$this -> module_group = ( int ) $system -> getRequest ( 'module_group' , __ ( " Module group " ));
if (( $this -> module_group === __ ( " Module group " )) || ( $this -> module_group == - 1 )
|| ( $this -> module_group == 0 )) {
$this -> module_group = - 1 ;
}
else {
$this -> default = false ;
}
$this -> tag = ( int ) $system -> getRequest ( 'tag' , __ ( " Tag " ));
if (( $this -> tag === __ ( " Tag " )) || ( $this -> tag == 0 )) {
$this -> tag = 0 ;
}
else {
$this -> default = false ;
}
}
public function show () {
if ( ! $this -> correct_acl ) {
$this -> show_fail_acl ();
}
else {
$this -> getFilters ();
$this -> show_modules ();
}
}
private function show_fail_acl () {
$ui = Ui :: getInstance ();
$ui -> createPage ();
$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 );
$ui -> showPage ();
}
private function show_modules () {
$ui = Ui :: getInstance ();
$ui -> createPage ();
$ui -> createDefaultHeader ( __ ( " PandoraFMS: Modules " ));
$ui -> showFooter ( false );
$ui -> beginContent ();
$filter_title = sprintf ( __ ( 'Filter Modules by %s' ),
$this -> filterEventsGetString ());
$ui -> contentBeginCollapsible ( $filter_title );
$ui -> beginForm ( " index.php?page=modules " );
$system = System :: getInstance ();
$groups = users_get_groups_for_select (
$system -> getConfig ( 'id_user' ), " AR " , true , true , false , 'id_grupo' );
$options = array (
'name' => 'group' ,
'title' => __ ( 'Group' ),
'label' => __ ( 'Group' ),
'items' => $groups ,
'selected' => $this -> group
);
$ui -> formAddSelectBox ( $options );
$options = array (
'name' => 'status' ,
'title' => __ ( 'Status' ),
'label' => __ ( 'Status' ),
'items' => $this -> list_status ,
'selected' => $this -> status
);
$ui -> formAddSelectBox ( $options );
$module_groups = db_get_all_rows_sql ( " SELECT *
FROM tmodule_group
ORDER BY name " );
$module_groups = io_safe_output ( $module_groups );
$options = array (
'name' => 'module_group' ,
'title' => __ ( 'Module group' ),
'label' => __ ( 'Module group' ),
'item_id' => 'id_mg' ,
'item_value' => 'name' ,
'items' => $module_groups ,
'selected' => $this -> module_group
);
$ui -> formAddSelectBox ( $options );
$tags = tags_get_user_tags ();
$options = array (
'name' => 'tag' ,
'title' => __ ( 'Tag' ),
'label' => __ ( 'Tag' ),
'items' => $tags ,
'selected' => $this -> tag
);
$ui -> formAddSelectBox ( $options );
$options = array (
'name' => 'free_search' ,
'value' => $this -> free_search ,
'placeholder' => __ ( 'Free search' )
);
$ui -> formAddInputSearch ( $options );
$options = array (
'icon' => 'refresh' ,
'icon_pos' => 'right' ,
'text' => __ ( 'Apply Filter' )
);
$ui -> formAddSubmitButton ( $options );
$html = $ui -> getEndForm ();
$ui -> contentCollapsibleAddItem ( $html );
$ui -> contentEndCollapsible ();
$this -> listModulesHtml ();
$ui -> endContent ();
$ui -> showPage ();
}
private function getListModules ( $page = 0 , $ajax = false ) {
$system = System :: getInstance ();
$user = User :: getInstance ();
$id_type_web_content_string = db_get_value ( 'id_tipo' ,
'ttipo_modulo' , 'nombre' , 'web_content_string' );
$total = 0 ;
$modules = array ();
$sql_conditions_base = " WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_estado . id_agente_modulo = tagente_modulo . id_agente_modulo " ;
2013-04-09 11:29:03 +02:00
// Part SQL for the id_agent
$sql_conditions_agent = '' ;
if ( $this -> id_agent != 0 ) {
$sql_conditions_agent = " AND tagente_modulo.id_agente = " . $this -> id_agent ;
}
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
// Part SQL for the Group
if ( $this -> group != 0 ) {
$sql_conditions_group = " AND tagente.id_grupo = " . $this -> group ;
}
else {
$user_groups = implode ( ',' , $user -> getIdGroups ( $this -> acl ));
$sql_conditions_group = " AND tagente.id_grupo IN ( " . $user_groups . " ) " ;
}
// Part SQL for the Tag
$sql_conditions_tags = tags_get_acl_tags ( $user -> getIdUser (),
$this -> group , $this -> acl , 'module_condition' , 'AND' , 'tagente_modulo' );
$sql_conditions = " AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 " ;
// Part SQL for the module_group
if ( $this -> module_group > - 1 ) {
$sql_conditions .= sprintf ( " AND tagente_modulo.id_module_group = '%d' " ,
$this -> module_group );
}
// Part SQL for the free search
if ( $this -> free_search != " " ) {
$sql_conditions .= sprintf ( " AND (tagente.nombre LIKE '%%%s%%'
OR tagente_modulo . nombre LIKE '%%%s%%'
OR tagente_modulo . descripcion LIKE '%%%s%%' ) " ,
$this -> free_search , $this -> free_search , $this -> free_search );
}
// Part SQL fro Status
if ( $this -> status == AGENT_MODULE_STATUS_NORMAL ) { //Normal
$sql_conditions .= " AND tagente_estado.estado = 0
AND ( utimestamp > 0 OR ( tagente_modulo . id_tipo_modulo IN ( 21 , 22 , 23 , 100 ))) " ;
}
elseif ( $this -> status == AGENT_MODULE_STATUS_CRITICAL_BAD ) { //Critical
$sql_conditions .= " AND tagente_estado.estado = 1 AND utimestamp > 0 " ;
}
elseif ( $this -> status == AGENT_MODULE_STATUS_WARNING ) { //Warning
$sql_conditions .= " AND tagente_estado.estado = 2 AND utimestamp > 0 " ;
}
elseif ( $this -> status == AGENT_MODULE_STATUS_NOT_NORMAL ) { //Not normal
$sql_conditions .= " AND tagente_estado.estado <> 0 " ;
}
elseif ( $this -> status == AGENT_MODULE_STATUS_UNKNOW ) { //Unknown
$sql_conditions .= " AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0 " ;
}
elseif ( $this -> status == AGENT_MODULE_STATUS_NOT_INIT ) { //Not init
$sql_conditions .= " AND tagente_estado.utimestamp = 0
AND tagente_modulo . id_tipo_modulo NOT IN ( 21 , 22 , 23 , 100 ) " ;
}
if ( $this -> tag > 0 ) {
$sql_conditions .= " AND tagente_modulo.id_agente_modulo IN (
SELECT ttag_module . id_agente_modulo
FROM ttag_module
WHERE ttag_module . id_tag = " . $this->tag . " ) " ;
}
2013-04-09 11:29:03 +02:00
$sql_conditions_all = $sql_conditions_base . $sql_conditions_agent . $sql_conditions .
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
$sql_conditions_group . $sql_conditions_tags ;
$sql_select = " SELECT
( SELECT GROUP_CONCAT ( ttag . name SEPARATOR ',' )
FROM ttag
WHERE ttag . id_tag IN (
SELECT ttag_module . id_tag
FROM ttag_module
WHERE ttag_module . id_agente_modulo = tagente_modulo . id_agente_modulo ))
AS tags ,
tagente_modulo . id_agente_modulo ,
tagente . intervalo AS agent_interval ,
tagente . nombre AS agent_name ,
tagente_modulo . nombre AS module_name ,
tagente_modulo . history_data ,
tagente_modulo . flag AS flag ,
tagente . id_grupo AS id_group ,
tagente . id_agente AS id_agent ,
tagente_modulo . id_tipo_modulo AS module_type ,
tagente_modulo . module_interval ,
tagente_estado . datos ,
tagente_estado . estado ,
tagente_modulo . min_warning ,
tagente_modulo . max_warning ,
tagente_modulo . str_warning ,
tagente_modulo . unit ,
tagente_modulo . min_critical ,
tagente_modulo . max_critical ,
tagente_modulo . str_critical ,
tagente_modulo . extended_info ,
tagente_modulo . critical_inverse ,
tagente_modulo . warning_inverse ,
tagente_modulo . critical_instructions ,
tagente_modulo . warning_instructions ,
tagente_modulo . unknown_instructions ,
tagente_estado . utimestamp AS utimestamp " ;
$sql_total = " SELECT count(*) " ;
$sql = " FROM tagente, tagente_modulo, tagente_estado " .
$sql_conditions_all ;
2013-04-09 11:29:03 +02:00
$sql_limit = " ORDER BY tagente.nombre ASC " ;
if ( ! $this -> all_modules ) {
$sql_limit = " LIMIT " . ( int )( $page * $system -> getPageSize ()) . " , " . ( int ) $system -> getPageSize ();
}
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
2013-04-09 11:29:03 +02:00
$total = db_get_value_sql ( $sql_total . $sql ); html_debug_print ( $sql_select . $sql . $sql_limit , true );
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
$modules_db = db_get_all_rows_sql ( $sql_select . $sql . $sql_limit );
if ( empty ( $modules_db )) {
$modules_db = array ();
}
else {
$modules = array ();
foreach ( $modules_db as $module ) {
$row = array ();
2013-04-09 11:29:03 +02:00
if ( $this -> columns [ 'agent' ]) {
$row [ 0 ] = $row [ __ ( 'Agent name' )] =
'<span class="data"><span class="show_collapside" style="display: none; font-weight: bolder;">' . __ ( 'Agent' ) . ' </span>' .
'<a class="ui-link" data-ajax="false" href="index.php?page=agent&id=' . $module [ " id_agent " ] . '">' . $module [ 'agent_name' ] . '</a>' .
'</span>' ;
}
2013-04-08 13:08:35 +02:00
$row [ 2 ] = $row [ __ ( 'Module name' )] =
'<span class="data"><span class="show_collapside" style="display: none; font-weight: bolder;">' . __ ( 'Module' ) . ' </span>' .
$module [ 'module_name' ];
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
if ( $module [ 'utimestamp' ] == 0 && (( $module [ 'module_type' ] < 21 ||
$module [ 'module_type' ] > 23 ) && $module [ 'module_type' ] != 100 )) {
$row [ 5 ] = $row [ __ ( 'Status' )] = ui_print_status_image ( STATUS_MODULE_NO_DATA ,
__ ( 'NOT INIT' ), true );
}
elseif ( $module [ " estado " ] == 0 ) {
$row [ 5 ] = $row [ __ ( 'Status' )] = ui_print_status_image ( STATUS_MODULE_OK ,
__ ( 'NORMAL' ) . " : " . $module [ " datos " ], true );
}
elseif ( $module [ " estado " ] == 1 ) {
$row [ 5 ] = $row [ __ ( 'Status' )] = ui_print_status_image ( STATUS_MODULE_CRITICAL ,
__ ( 'CRITICAL' ) . " : " . $module [ " datos " ], true );
}
elseif ( $module [ " estado " ] == 2 ) {
$row [ 5 ] = $row [ __ ( 'Status' )] = ui_print_status_image ( STATUS_MODULE_WARNING ,
__ ( 'WARNING' ) . " : " . $module [ " datos " ], true );
}
else {
$last_status = modules_get_agentmodule_last_status (
$module [ 'id_agente_modulo' ]);
switch ( $last_status ) {
case 0 :
$row [ 5 ] = $row [ __ ( 'Status' )] = ui_print_status_image ( STATUS_MODULE_UNKNOWN ,
__ ( 'UNKNOWN' ) . " - " . __ ( 'Last status' ) . " " .
__ ( 'NORMAL' ) . " : " . $module [ " datos " ], true );
break ;
case 1 :
$row [ 5 ] = $row [ __ ( 'Status' )] = ui_print_status_image ( STATUS_MODULE_UNKNOWN ,
__ ( 'UNKNOWN' ) . " - " . __ ( 'Last status' ) . " " .
__ ( 'CRITICAL' ) . " : " . $module [ " datos " ], true );
break ;
case 2 :
$row [ 5 ] = $row [ __ ( 'Status' )] = ui_print_status_image ( STATUS_MODULE_UNKNOWN ,
__ ( 'UNKNOWN' ) . " - " . __ ( 'Last status' ) . " " .
__ ( 'WARNING' ) . " : " . $module [ " datos " ], true );
break ;
}
}
2013-04-08 13:08:35 +02:00
$row [ 4 ] = $row [ __ ( 'Interval' )] =
( $module [ 'module_interval' ] == 0 ) ? human_time_description_raw ( $module [ 'agent_interval' ]) : human_time_description_raw ( $module [ 'module_interval' ]);
$row [ 4 ] = $row [ __ ( 'Interval' )] = '<span class="data"><span class="show_collapside" style="display: none; font-weight: bolder;">' . __ ( 'Interval.' ) . ' </span>' .
$row [ __ ( 'Interval' )] .
'</span>' ;
$row [ 6 ] = $row [ __ ( 'Timestamp' )] =
'<span class="data"><span class="show_collapside" style="display: none; font-weight: bolder;"> ' . __ ( 'Last update.' ) . ' </span>' .
ui_print_timestamp ( $module [ " utimestamp " ], true ) . '</span>' ;
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
if ( is_numeric ( $module [ " datos " ])) {
$output = format_numeric ( $module [ " datos " ]);
// Show units ONLY in numeric data types
if ( isset ( $module [ " unit " ])) {
$output .= " " .
'<i>' . io_safe_output ( $module [ " unit " ]) . '</i>' ;
}
}
else {
$is_web_content_string =
( bool ) db_get_value_filter ( 'id_agente_modulo' ,
'tagente_modulo' ,
array ( 'id_agente_modulo' => $module [ 'id_agente_modulo' ],
'id_tipo_modulo' => $id_type_web_content_string ));
//Fixed the goliat sends the strings from web
//without HTML entities
if ( $is_web_content_string ) {
$module [ 'datos' ] = io_safe_input ( $module [ 'datos' ]);
}
//Fixed the data from Selenium Plugin
if ( $module [ 'datos' ] != strip_tags ( $module [ 'datos' ])) {
$module [ 'datos' ] = io_safe_input ( $module [ 'datos' ]);
}
if ( $is_web_content_string ) {
$module_value = $module [ " datos " ];
}
else {
$module_value = io_safe_output ( $module [ " datos " ]);
}
$sub_string = substr ( io_safe_output ( $module [ " datos " ]), 0 , 12 );
if ( $module_value == $sub_string ) {
$output = $module_value ;
}
else {
$output = $sub_string ;
}
}
2013-04-04 19:44:07 +02:00
$row [ 7 ] = $row [ __ ( 'Data' )] =
2013-04-08 13:08:35 +02:00
'<span style="white-space: nowrap;">' .
'<span style="display: none;" class="show_collapside">' . $row [ __ ( 'Status' )] . ' </span>' .
'<a data-ajax="false" class="ui-link" href="index.php?page=module_graph&id=' . $module [ 'id_agente_modulo' ] . '">' .
'<span style="vertical-align: 30%;">' . html_print_image ( 'images/chart_curve.png' , true , array ( " style " => 'vertical-align: middle;' )) . '</span>' .
' ' . $output . '</a>' . '</span>' ;
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
if ( ! $ajax ) {
2013-04-09 11:29:03 +02:00
if ( $this -> columns [ 'agent' ]) {
unset ( $row [ 0 ]);
}
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
unset ( $row [ 1 ]);
unset ( $row [ 2 ]);
unset ( $row [ 4 ]);
unset ( $row [ 5 ]);
unset ( $row [ 6 ]);
unset ( $row [ 7 ]);
}
$modules [ $module [ 'id_agente_modulo' ]] = $row ;
}
}
return array ( 'modules' => $modules , 'total' => $total );
}
2013-04-09 11:29:03 +02:00
public function listModulesHtml ( $page = 0 , $return = false ) {
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
$system = System :: getInstance ();
$ui = Ui :: getInstance ();
$listModules = $this -> getListModules ( $page );
2013-04-09 11:29:03 +02:00
//$ui->debug($listModules, true);
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
if ( $listModules [ 'total' ] == 0 ) {
2013-04-09 11:29:03 +02:00
$html = '<p style="color: #ff0000;">' . __ ( 'No modules' ) . '</p>' ;
if ( ! $return ) {
$ui -> contentAddHtml ( $html );
}
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
}
else {
$table = new Table ();
$table -> id = 'list_Modules' ;
$table -> importFromHash ( $listModules [ 'modules' ]);
2013-04-09 11:29:03 +02:00
if ( ! $return ) {
$ui -> contentAddHtml ( $table -> getHTML ());
}
else {
$html .= $table -> getHTML ();
2013-04-19 13:39:41 +02:00
return $html ;
2013-04-09 11:29:03 +02:00
}
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
2013-04-09 11:29:03 +02:00
if ( ! $this -> all_modules ) {
if ( $system -> getPageSize () < $listModules [ 'total' ]) {
$ui -> contentAddHtml ( '<div id="loading_rows">' .
html_print_image ( 'images/spinner.gif' , true ) .
' ' . __ ( 'Loading...' ) .
'</div>' );
$this -> addJavascriptAddBottom ();
}
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
}
}
}
private function addJavascriptAddBottom () {
$ui = Ui :: getInstance ();
$ui -> contentAddHtml ( " <script type= \" text/javascript \" >
var load_more_rows = 1 ;
var page = 1 ;
$ ( document ) . ready ( function () {
$ ( window ) . bind ( \ " scroll \" , function () {
if ( load_more_rows ) {
if ( $ ( this ) . scrollTop () + $ ( this ) . height ()
>= ( $ ( document ) . height () - 100 )) {
load_more_rows = 0 ;
postvars = {};
postvars [ \ " action \" ] = \" ajax \" ;
postvars [ \ " parameter1 \" ] = \" modules \" ;
postvars [ \ " parameter2 \" ] = \" get_modules \" ;
postvars [ \ " group \" ] = $ ( \" select[name='group'] \" ).val();
postvars [ \ " status \" ] = $ ( \" select[name='status'] \" ).val();
postvars [ \ " type \" ] = $ ( \" select[name='module_group'] \" ).val();
2013-04-19 13:39:41 +02:00
postvars [ \ " tag \" ] = $ ( \" select[name='tag'] \" ).val();
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
postvars [ \ " free_search \" ] = $ ( \" input[name='free_search'] \" ).val();
postvars [ \ " page \" ] = page;
page ++ ;
$ . post ( \ " index.php \" ,
postvars ,
function ( data ) {
if ( data . end ) {
$ ( \ " #loading_rows \" ).hide();
}
else {
2013-04-08 13:08:35 +02:00
$ . each ( data . modules , function ( key , module ) {
$ ( \ " table#list_Modules tbody \" ).append( \" <tr> \" +
\ " <th class='head_vertical'></th> \" +
\ " <td class='cell_0'><b class='ui-table-cell-label'> " . __ ( 'Agent name' ) . " </b> \" + module[0] + \" </td> \" +
\ " <td class='cell_1'><b class='ui-table-cell-label'> " . __ ( 'Module name' ) . " </b> \" + module[2] + \" </td> \" +
\ " <td class='cell_2'><b class='ui-table-cell-label'> " . __ ( 'Status' ) . " </b> \" + module[5] + \" </td> \" +
\ " <td class='cell_3'><b class='ui-table-cell-label'> " . __ ( 'Interval' ) . " </b> \" + module[4] + \" </td> \" +
\ " <td class='cell_4'><b class='ui-table-cell-label'> " . __ ( 'Timestamp' ) . " </b> \" + module[6] + \" </td> \" +
\ " <td class='cell_5'><b class='ui-table-cell-label'> " . __ ( 'Data' ) . " </b> \" + module[7] + \" </td> \" +
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
\ " </tr> \" );
});
load_more_rows = 1 ;
}
},
\ " json \" );
}
}
});
});
</ script > " );
}
private function filterEventsGetString () {
if ( $this -> default ) {
return __ ( " (Default) " );
}
else {
$status = $this -> list_status [ $this -> status ];
$group = groups_get_name ( $this -> group , true );
$module_group = db_get_value ( 'name' ,
'tmodule_group' , 'id_mg' , $this -> module_group );
$module_groups = io_safe_output ( $module_groups );
$tag = tags_get_name ( $this -> tag );
$string = sprintf (
__ ( " (Status: %s - Group: %s - Module group: %s - Tag: %s - Free Search: %s) " ),
$status , $group , $module_group , $tag , $this -> free_search );
return $string ;
}
}
}
?>