2013-07-03 Miguel de Dios <miguel.dedios@artica.es>
* mobile/index.php, mobile/operation/networkmaps.php, mobile/operation/networkmap.php, mobile/operation/home.php, mobile/include/ui.class.php, include/functions_networkmap.php, include/functions_ui.php: uploaded the some changes and files for to show networkmaps in the Pandora mobile. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8457 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
10ea6944e7
commit
a1dcb44d81
|
@ -1,3 +1,11 @@
|
|||
2013-07-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* mobile/index.php, mobile/operation/networkmaps.php,
|
||||
mobile/operation/networkmap.php, mobile/operation/home.php,
|
||||
mobile/include/ui.class.php, include/functions_networkmap.php,
|
||||
include/functions_ui.php: uploaded the some changes and files
|
||||
for to show networkmaps in the Pandora mobile.
|
||||
|
||||
2013-07-03 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* godmode/users/configure_user.php: improve the meta
|
||||
|
@ -9,6 +17,25 @@
|
|||
* include/functions_api.php: Changed the way of encode
|
||||
data configuration in create/update config form API
|
||||
|
||||
2013-07-02 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* extensions/system_info.php: clean source code style.
|
||||
|
||||
* mobile/include/ui.class.php: fixed the selectbox for int values.
|
||||
|
||||
* mobile/operation/home.php, mobile/index.php,
|
||||
mobile/operation/networkmaps.php, mobile/operation/networkmap.php:
|
||||
added networkmap.
|
||||
|
||||
* include/functions_ui.php: added for get only the src of module
|
||||
type.
|
||||
|
||||
* include/functions_networkmap.php,
|
||||
operation/agentes/networkmap.topology.php: add support for
|
||||
networkmaps in mobile.
|
||||
|
||||
MERGED FROM THE BRANCH 4.0
|
||||
|
||||
2013-07-02 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_networkmap.php,
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage Network_Map
|
||||
|
@ -45,9 +47,9 @@ function networkmap_is_descendant ($node, $ascendant, $parents) {
|
|||
}
|
||||
|
||||
// Generate a dot graph definition for graphviz
|
||||
function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0,
|
||||
$font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1,
|
||||
$ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
|
||||
function networkmap_generate_dot ($pandora_name, $group = 0,
|
||||
$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
|
||||
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
|
||||
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
|
||||
$relative = false, $text_filter = '') {
|
||||
|
||||
|
@ -271,6 +273,7 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
|
|||
|
||||
$groups_hiden = array();
|
||||
foreach ($nodes_groups as $node_group) {
|
||||
|
||||
$node_count++;
|
||||
|
||||
// Save node parent information to define edges later
|
||||
|
@ -383,15 +386,18 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
|
|||
}
|
||||
switch ($node['type']) {
|
||||
case 'group':
|
||||
$graph .= networkmap_create_group_node ($node , $simple, $font_size)."\n\t\t";
|
||||
$graph .= networkmap_create_group_node ($node , $simple, $font_size) .
|
||||
"\n\t\t";
|
||||
$stats['groups'][] = $node['id_grupo'];
|
||||
break;
|
||||
case 'agent':
|
||||
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, true, true)."\n\t\t";
|
||||
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, true, true) .
|
||||
"\n\t\t";
|
||||
$stats['agents'][] = $node['id_agente'];
|
||||
break;
|
||||
case 'module':
|
||||
$graph .= networkmap_create_module_node ($node , $simple, $font_size)."\n\t\t";
|
||||
$graph .= networkmap_create_module_node ($node , $simple, $font_size) .
|
||||
"\n\t\t";
|
||||
$stats['modules'][] = $node['id_agente_modulo'];
|
||||
break;
|
||||
}
|
||||
|
@ -445,42 +451,55 @@ function networkmap_create_edge ($head, $tail, $layout, $nooverlap, $pure, $zoom
|
|||
|
||||
// Returns a group node definition
|
||||
function networkmap_create_group_node ($group, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null) {
|
||||
global $config;
|
||||
global $hack_networkmap_mobile;
|
||||
|
||||
$status = groups_get_status ($group['id_grupo']);
|
||||
|
||||
// Set node status
|
||||
switch($status) {
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$status_color = '#8DFF1D'; // Normal monitor
|
||||
$status_color = '#8DFF1D'; // Normal monitor
|
||||
break;
|
||||
case 1:
|
||||
$status_color = '#FF1D1D'; // Critical monitor
|
||||
$status_color = '#FF1D1D'; // Critical monitor
|
||||
break;
|
||||
case 2:
|
||||
$status_color = '#FFE308'; // Warning monitor
|
||||
$status_color = '#FFE308'; // Warning monitor
|
||||
break;
|
||||
case 4:
|
||||
$status_color = '#FFA300'; // Alert fired
|
||||
$status_color = '#FFA300'; // Alert fired
|
||||
break;
|
||||
default:
|
||||
$status_color = '#BBBBBB'; // Unknown monitor
|
||||
$status_color = '#BBBBBB'; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$icon = groups_get_icon($group['id_grupo']);
|
||||
|
||||
if ($simple == 0) {
|
||||
// Set node icon
|
||||
if (file_exists (html_print_image("images/groups_small/" . $icon . ".png", true, false, true, true))) {
|
||||
if ($hack_networkmap_mobile) {
|
||||
$img_node = $config['homedir'] . "/images/groups_small/" . $icon . ".png";
|
||||
html_debug_print($img_node, true);
|
||||
if (!file_exists($img_node)) {
|
||||
$img_node = '-';
|
||||
}
|
||||
$img_node = '<img src="' . $img_node . '" />';
|
||||
}
|
||||
else if (file_exists (html_print_image("images/groups_small/" . $icon . ".png", true, false, true, true))) {
|
||||
$img_node = html_print_image("images/groups_small/" . $icon . ".png", true, false, false, true);
|
||||
}
|
||||
else {
|
||||
$img_node = '-';
|
||||
}
|
||||
|
||||
if (strlen(groups_get_name($group['id_grupo'])) > 40){
|
||||
if (strlen(groups_get_name($group['id_grupo'])) > 40) {
|
||||
$name = substr(groups_get_name($group['id_grupo']), 0, 40) . '...';
|
||||
}
|
||||
else{
|
||||
else {
|
||||
$name = groups_get_name($group['id_grupo']);
|
||||
}
|
||||
|
||||
|
@ -518,7 +537,8 @@ function networkmap_create_group_node ($group, $simple = 0, $font_size = 10, $me
|
|||
// Returns a node definition
|
||||
function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true, $relative = false, $metaconsole = false, $id_server = null) {
|
||||
global $config;
|
||||
|
||||
global $hack_networkmap_mobile;
|
||||
|
||||
$status = agents_get_status_from_counts($agent);
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
|
@ -564,20 +584,28 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
|
|||
}
|
||||
|
||||
if ($simple == 0) {
|
||||
// Set node icon
|
||||
$img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true, $relative);
|
||||
$img_node = str_replace($config['homeurl'] . '/', '', $img_node);
|
||||
$img_node = str_replace($config['homeurl'], '', $img_node);
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
$img_node = str_replace('../../', '', $img_node);
|
||||
}
|
||||
|
||||
if ($relative) {
|
||||
$img_node = html_print_image($img_node, true, false, false, true);
|
||||
if ($hack_networkmap_mobile) {
|
||||
$img_node = ui_print_os_icon($agent['id_os'], false, true, true, true, true, true);
|
||||
|
||||
$img_node = $config['homedir'] . '/' . $img_node;
|
||||
$img_node = '<img src="' . $img_node . '" />';
|
||||
}
|
||||
else {
|
||||
$img_node = html_print_image($img_node, true, false, false, false);
|
||||
// Set node icon
|
||||
$img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true, $relative);
|
||||
$img_node = str_replace($config['homeurl'] . '/', '', $img_node);
|
||||
$img_node = str_replace($config['homeurl'], '', $img_node);
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
$img_node = str_replace('../../', '', $img_node);
|
||||
}
|
||||
|
||||
if ($relative) {
|
||||
$img_node = html_print_image($img_node, true, false, false, true);
|
||||
}
|
||||
else {
|
||||
$img_node = html_print_image($img_node, true, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (defined("METACONSOLE")) {
|
||||
|
@ -627,10 +655,13 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
|
|||
}
|
||||
|
||||
function networkmap_create_module_group_node ($module_group, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null) {
|
||||
global $config;
|
||||
global $hack_networkmap_mobile;
|
||||
|
||||
|
||||
// Set node status
|
||||
switch ($module_group['status']) {
|
||||
case 0:
|
||||
case 0:
|
||||
$status_color = '#8DFF1D'; // Normal monitor
|
||||
break;
|
||||
case 1:
|
||||
|
@ -666,6 +697,15 @@ function networkmap_create_module_group_node ($module_group, $simple = 0, $font_
|
|||
tooltip="' . $url_tooltip . '"];';
|
||||
}
|
||||
else {
|
||||
if ($hack_networkmap_mobile) {
|
||||
$img_node = ui_print_moduletype_icon($module['id_tipo_modulo'], true, true, false, true);
|
||||
|
||||
$img_node = $config['homedir'] . '/' . $img_node;
|
||||
$img_node = '<img src="' . $img_node . '" />';
|
||||
}
|
||||
else {
|
||||
$img_node = ui_print_moduletype_icon ($module['id_tipo_modulo'], true, true, false);
|
||||
}
|
||||
if (defined("METACONSOLE")) {
|
||||
$url = '';
|
||||
$url_tooltip = '';
|
||||
|
@ -685,8 +725,10 @@ function networkmap_create_module_group_node ($module_group, $simple = 0, $font_
|
|||
|
||||
// Returns a module node definition
|
||||
function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $metaconsole = false, $id_server = null) {
|
||||
global $config;
|
||||
global $hack_networkmap_mobile;
|
||||
|
||||
if(isset($module['status'])) {
|
||||
if (isset($module['status'])) {
|
||||
$status = $module['status'];
|
||||
}
|
||||
else {
|
||||
|
@ -696,7 +738,7 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $
|
|||
|
||||
// Set node status
|
||||
switch ($status) {
|
||||
case 0:
|
||||
case 0:
|
||||
$status_color = '#8DFF1D'; // Normal monitor
|
||||
break;
|
||||
case 1:
|
||||
|
@ -713,6 +755,16 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $
|
|||
break;
|
||||
}
|
||||
|
||||
if ($hack_networkmap_mobile) {
|
||||
$img_node = ui_print_moduletype_icon($module['id_tipo_modulo'], true, true, false, true);
|
||||
|
||||
$img_node = $config['homedir'] . '/' . $img_node;
|
||||
$img_node = '<img src="' . $img_node . '" />';
|
||||
}
|
||||
else {
|
||||
$img_node = ui_print_moduletype_icon ($module['id_tipo_modulo'], true, true, false);
|
||||
}
|
||||
|
||||
|
||||
if ($simple == 0) {
|
||||
if (defined("METACONSOLE")) {
|
||||
|
@ -733,7 +785,7 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $
|
|||
'", fontsize='.$font_size.', style="filled", ' .
|
||||
'fixedsize=true, width=0.30, height=0.30, ' .
|
||||
'label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>' .
|
||||
ui_print_moduletype_icon ($module['id_tipo_modulo'], true, true, false). '</TD></TR>
|
||||
$img_node . '</TD></TR>
|
||||
<TR><TD>' . io_safe_output($module['nombre']) . '</TD></TR></TABLE>>,
|
||||
shape="circle", URL="' . $url . '",
|
||||
tooltip="' . $url_tooltip . '"];';
|
||||
|
@ -762,6 +814,8 @@ function networkmap_create_module_node ($module, $simple = 0, $font_size = 10, $
|
|||
|
||||
// Returns the definition of the central module
|
||||
function networkmap_create_pandora_node ($name, $font_size = 10, $simple = 0, $stats = array()) {
|
||||
global $hack_networkmap_mobile;
|
||||
global $config;
|
||||
|
||||
$stats_json = base64_encode(json_encode($stats));
|
||||
|
||||
|
@ -782,9 +836,14 @@ function networkmap_create_pandora_node ($name, $font_size = 10, $simple = 0, $s
|
|||
$color = "#373737";
|
||||
}
|
||||
|
||||
$img_tag = html_print_image($img_src, true, false, false, true);
|
||||
|
||||
$img = '<TR><TD>' . $img_tag . '</TD></TR>';
|
||||
if ($hack_networkmap_mobile) {
|
||||
$img = '<TR><TD>' .
|
||||
"<img src='" . $config['homedir'] . '/' . "images/networkmap/pandora_node.png' />" .
|
||||
'</TD></TR>';
|
||||
}
|
||||
else {
|
||||
$img = '<TR><TD>' . html_print_image("images/networkmap/pandora_node.png", true, false, false, true) . '</TD></TR>';
|
||||
}
|
||||
$name = '<TR><TD BGCOLOR="#FFFFFF">'.$name.'</TD></TR>';
|
||||
$label = '<TABLE BORDER="0">'.$img.$name.'</TABLE>';
|
||||
if ($simple == 1) {
|
||||
|
@ -1010,7 +1069,7 @@ function networkmap_get_networkmaps ($id_user = '', $type = '', $optgrouped = tr
|
|||
break;
|
||||
}
|
||||
|
||||
if ($networkmaps_raw === false){
|
||||
if ($networkmaps_raw === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -499,6 +499,7 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small"
|
|||
else
|
||||
$icon = "world";
|
||||
|
||||
|
||||
$output = '';
|
||||
|
||||
// Don't show link in metaconsole
|
||||
|
@ -575,7 +576,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
|
|||
if ($networkmap) {
|
||||
$subfolter = 'networkmap';
|
||||
}
|
||||
|
||||
|
||||
$icon = (string) db_get_value ('icon_name', 'tconfig_os', 'id_os', (int) $id_os);
|
||||
$os_name = get_os_name ($id_os);
|
||||
if (empty ($icon)) {
|
||||
|
@ -1738,7 +1739,7 @@ function ui_debug ($var, $backtrace = true) {
|
|||
*
|
||||
* @return string An HTML string with the icon. Printed if return is false
|
||||
*/
|
||||
function ui_print_moduletype_icon ($id_moduletype, $return = false, $relative = false, $options = true) {
|
||||
function ui_print_moduletype_icon ($id_moduletype, $return = false, $relative = false, $options = true, $src = false) {
|
||||
global $config;
|
||||
|
||||
$type = db_get_row ("ttipo_modulo", "id_tipo", (int) $id_moduletype, array ("descripcion", "icon"));
|
||||
|
@ -1751,6 +1752,10 @@ function ui_print_moduletype_icon ($id_moduletype, $return = false, $relative =
|
|||
if (! file_exists ($config['homedir'].'/'.$imagepath))
|
||||
$imagepath = ENTERPRISE_DIR.'/'.$imagepath;
|
||||
|
||||
if ($src) {
|
||||
return $imagepath;
|
||||
}
|
||||
|
||||
if ($options) {
|
||||
return html_print_image ($imagepath, $return,
|
||||
array ("border" => 0,
|
||||
|
|
|
@ -520,7 +520,7 @@ class Ui {
|
|||
|
||||
$selected = '';
|
||||
if (isset($options['selected'])) {
|
||||
if ($options['selected'] == $item_id) {
|
||||
if ($options['selected'] === $item_id) {
|
||||
$selected = "selected = 'selected'";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ require_once('operation/agents.php');
|
|||
require_once('operation/modules.php');
|
||||
require_once('operation/module_graph.php');
|
||||
require_once('operation/agent.php');
|
||||
require_once('operation/networkmaps.php');
|
||||
require_once('operation/networkmap.php');
|
||||
$enterpriseHook = enterprise_include('mobile/include/enterprise.class.php');
|
||||
|
||||
$system = System::getInstance();
|
||||
|
@ -142,6 +144,14 @@ switch ($action) {
|
|||
$agent = new Agent();
|
||||
$agent->show();
|
||||
break;
|
||||
case 'networkmaps':
|
||||
$networkmaps = new Networkmaps();
|
||||
$networkmaps->show();
|
||||
break;
|
||||
case 'networkmap':
|
||||
$networkmap = new Networkmap();
|
||||
$networkmap->show();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,11 @@ class Home {
|
|||
'text' => __('Modules'),
|
||||
'href' => 'index.php?page=modules');
|
||||
$ui->contentAddHtml($ui->createButton($options));
|
||||
$options = array('icon' => 'star',
|
||||
'pos' => 'right',
|
||||
'text' => __('Networkmaps'),
|
||||
'href' => 'index.php?page=networkmaps');
|
||||
$ui->contentAddHtml($ui->createButton($options));
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,232 @@
|
|||
<?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.
|
||||
|
||||
require_once ('../include/functions_networkmap.php');
|
||||
|
||||
class Networkmap {
|
||||
private $correct_acl = false;
|
||||
private $acl = "AR";
|
||||
|
||||
private $id = 0;
|
||||
private $network_map = null;
|
||||
|
||||
function __construct() {
|
||||
$system = System::getInstance();
|
||||
|
||||
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 'xxx':
|
||||
//$this->getFilters();
|
||||
//$page = $system->getRequest('page', 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getFilters() {
|
||||
$system = System::getInstance();
|
||||
|
||||
$this->id = (int)$system->getRequest('id', 0);
|
||||
}
|
||||
|
||||
public function show() {
|
||||
if (!$this->correct_acl) {
|
||||
$this->show_fail_acl();
|
||||
}
|
||||
else {
|
||||
$this->getFilters();
|
||||
|
||||
$this->networkmap = db_get_row('tnetwork_map',
|
||||
'id_networkmap', $this->id);
|
||||
|
||||
$this->show_networkmap();
|
||||
}
|
||||
}
|
||||
|
||||
private function show_fail_acl() {
|
||||
$error['title_text'] = __('You don\'t have access to this page');
|
||||
$error['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');
|
||||
$home = new Home();
|
||||
$home->show($error);
|
||||
}
|
||||
|
||||
private function show_networkmap() {
|
||||
$ui = Ui::getInstance();
|
||||
$system = System::getInstance();
|
||||
|
||||
$ui->createPage();
|
||||
$ui->createDefaultHeader(sprintf(__("PandoraFMS: Networkmap %s"),
|
||||
$this->network_map['name']));
|
||||
$ui->showFooter(false);
|
||||
$ui->beginContent();
|
||||
|
||||
//Hack for mobile
|
||||
global $hack_networkmap_mobile;
|
||||
$hack_networkmap_mobile = true;
|
||||
|
||||
switch ($this->networkmap['type']) {
|
||||
case 'groups':
|
||||
$graph = networkmap_generate_dot_groups (
|
||||
__('Pandora FMS'),
|
||||
$this->networkmap['id_group'],
|
||||
$this->networkmap['simple'],
|
||||
$this->networkmap['font_size'],
|
||||
$this->networkmap['layout'],
|
||||
(bool)$this->networkmap['nooverlap'],
|
||||
$this->networkmap['zoom'],
|
||||
$this->networkmap['distance_nodes'],
|
||||
$this->networkmap['center'], 1, 0,
|
||||
$this->networkmap['only_modules_with_alerts'],
|
||||
$this->networkmap['id_module_group'],
|
||||
$this->networkmap['hide_policy_modules'],
|
||||
$this->networkmap['depth'],
|
||||
$this->networkmap['id_networkmap']);
|
||||
break;
|
||||
case 'policies':
|
||||
$enterprise = enterprise_include('/include/functions_policies.php');
|
||||
|
||||
if ($enterprise != ENTERPRISE_NOT_HOOK) {
|
||||
$graph = policies_generate_dot_graph (__('Pandora FMS'),
|
||||
$this->networkmap['id_group'],
|
||||
$this->networkmap['simple'],
|
||||
$this->networkmap['font_size'],
|
||||
$this->networkmap['layout'],
|
||||
(bool)$this->networkmap['nooverlap'],
|
||||
$this->networkmap['zoom'],
|
||||
$this->networkmap['distance_nodes'],
|
||||
$this->networkmap['center'], 1, 0,
|
||||
$this->networkmap['only_modules_with_alerts'],
|
||||
$this->networkmap['id_module_group'],
|
||||
$this->networkmap['depth'],
|
||||
$this->networkmap['id_networkmap']);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case 'topology':
|
||||
$graph = networkmap_generate_dot (__('Pandora FMS'),
|
||||
$this->networkmap['id_group'],
|
||||
$this->networkmap['simple'],
|
||||
$this->networkmap['font_size'],
|
||||
$this->networkmap['layout'],
|
||||
(bool)$this->networkmap['nooverlap'],
|
||||
$this->networkmap['zoom'],
|
||||
$this->networkmap['distance_nodes'],
|
||||
$this->networkmap['center'], 1, 0,
|
||||
$this->networkmap['id_networkmap'],
|
||||
$this->networkmap['show_snmp_modules'], true,
|
||||
true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($graph === false) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No networkmaps') . '</p>');
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$filter = networkmap_get_filter($this->networkmap['layout']);
|
||||
|
||||
// Generate image and map
|
||||
// If image was generated just a few minutes ago, then don't regenerate (it takes long) unless regen checkbox is set
|
||||
$filename_map = safe_url_extraclean (
|
||||
$system->getConfig('attachment_store')) . "/networkmap_" . $filter;
|
||||
$filename_img = safe_url_extraclean (
|
||||
$system->getConfig('attachment_store')) . "/networkmap_" .
|
||||
$filter . "_" . $this->networkmap['font_size'];
|
||||
$url_img = "../attachment/networkmap_" .
|
||||
$filter . "_" . $this->networkmap['font_size'];
|
||||
$filename_dot = safe_url_extraclean(
|
||||
$system->getConfig("attachment_store")) . "/networkmap_" . $filter;
|
||||
if ($this->networkmap['simple']) {
|
||||
$filename_map .= "_simple";
|
||||
$filename_img .= "_simple";
|
||||
$url_img .= "_simple";
|
||||
$filename_dot .= "_simple";
|
||||
}
|
||||
if ($this->networkmap['nooverlap']) {
|
||||
$filename_map .= "_nooverlap";
|
||||
$filename_img .= "_nooverlap";
|
||||
$url_img .= "_nooverlap";
|
||||
$filename_dot .= "_nooverlap";
|
||||
}
|
||||
$filename_map .= "_" . $this->networkmap['id_networkmap'] . ".map";
|
||||
$filename_img .= "_" . $this->networkmap['id_networkmap'] . ".png";
|
||||
$url_img .= "_" . $this->networkmap['id_networkmap'] . ".png";
|
||||
$filename_dot .= "_" . $this->networkmap['id_networkmap'] . ".dot";
|
||||
|
||||
if ($this->networkmap['regenerate'] != 1 && file_exists($filename_img) && filemtime($filename_img) > get_system_time () - 300) {
|
||||
$result = true;
|
||||
}
|
||||
else {
|
||||
$fh = @fopen ($filename_dot, 'w');
|
||||
if ($fh === false) {
|
||||
$result = false;
|
||||
}
|
||||
else {
|
||||
fwrite ($fh, $graph);
|
||||
$cmd = $filter . " -Tcmapx -o" . $filename_map." -Tpng -o".$filename_img." ".$filename_dot;
|
||||
$result = system ($cmd);
|
||||
html_debug_print($cmd, true);
|
||||
fclose ($fh);
|
||||
//unlink ($filename_dot);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
if (! file_exists ($filename_map)) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('Map could not be generated') . '</p>');
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
|
||||
return;
|
||||
}
|
||||
$ui->contentAddHtml('<div style="overflow: scroll; width: 100%; text-align: center;">');
|
||||
$ui->contentAddHtml('<img src="' . $url_img . '" />');
|
||||
$ui->contentAddHtml('</div>');
|
||||
}
|
||||
else {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('Map could not be generated') . '</p>');
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,202 @@
|
|||
<?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.
|
||||
|
||||
require_once ('../include/functions_networkmap.php');
|
||||
|
||||
class Networkmaps {
|
||||
private $correct_acl = false;
|
||||
private $acl = "AR";
|
||||
|
||||
private $default = true;
|
||||
private $group = 0;
|
||||
private $type = 0;
|
||||
|
||||
private $list_types = null;
|
||||
|
||||
function __construct() {
|
||||
$system = System::getInstance();
|
||||
|
||||
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 'xxx':
|
||||
//$this->getFilters();
|
||||
//$page = $system->getRequest('page', 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getFilters() {
|
||||
$system = System::getInstance();
|
||||
$user = User::getInstance();
|
||||
|
||||
$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->type = $system->getRequest('type', __("Type"));
|
||||
if (($this->type === __("Type")) || ($this->type == 0)) {
|
||||
$this->type = 0;
|
||||
}
|
||||
else {
|
||||
$this->default = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function show() {
|
||||
if (!$this->correct_acl) {
|
||||
$this->show_fail_acl();
|
||||
}
|
||||
else {
|
||||
$this->getFilters();
|
||||
$this->show_networkmaps();
|
||||
}
|
||||
}
|
||||
|
||||
private function show_fail_acl() {
|
||||
$error['title_text'] = __('You don\'t have access to this page');
|
||||
$error['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');
|
||||
$home = new Home();
|
||||
$home->show($error);
|
||||
}
|
||||
|
||||
private function show_networkmaps() {
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
$ui->createPage();
|
||||
$ui->createDefaultHeader(__("PandoraFMS: Networkmaps"));
|
||||
$ui->showFooter(false);
|
||||
$ui->beginContent();
|
||||
$filter_title = sprintf(__('Filter Networkmaps by %s'),
|
||||
$this->filterNetworkmapsGetString());
|
||||
$ui->contentBeginCollapsible($filter_title);
|
||||
$ui->beginForm("index.php?page=networkmaps");
|
||||
$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);
|
||||
|
||||
$networkmap_types = networkmap_get_filter_types();
|
||||
$networkmap_types[0] = __('All');
|
||||
$options = array(
|
||||
'name' => 'type',
|
||||
'title' => __('Type'),
|
||||
'label' => __('Type'),
|
||||
'items' => $networkmap_types,
|
||||
'selected' => $this->type
|
||||
);
|
||||
$ui->formAddSelectBox($options);
|
||||
|
||||
$options = array(
|
||||
'icon' => 'refresh',
|
||||
'icon_pos' => 'right',
|
||||
'text' => __('Apply Filter')
|
||||
);
|
||||
$ui->formAddSubmitButton($options);
|
||||
$html = $ui->getEndForm();
|
||||
$ui->contentCollapsibleAddItem($html);
|
||||
$ui->contentEndCollapsible();
|
||||
$this->listNetworkmapsHtml();
|
||||
$ui->endContent();
|
||||
$ui->showPage();
|
||||
}
|
||||
|
||||
private function listNetworkmapsHtml() {
|
||||
$system = System::getInstance();
|
||||
$ui = Ui::getInstance();
|
||||
|
||||
// Create filter
|
||||
$where = array();
|
||||
// Order by type field
|
||||
$where['order'] = 'type';
|
||||
|
||||
if ($this->group != '0')
|
||||
$where['id_group'] = $this->group;
|
||||
|
||||
if ($this->type != '0')
|
||||
$where['type'] = $this->type;
|
||||
|
||||
$network_maps = db_get_all_rows_filter('tnetwork_map',
|
||||
$where);
|
||||
if (empty($network_maps)) {
|
||||
$network_maps = array();
|
||||
}
|
||||
$list = array();
|
||||
foreach ($network_maps as $networkmap) {
|
||||
$row = array();
|
||||
$row[__('Name')] = '<a class="ui-link" data-ajax="false" href="index.php?page=networkmap&id=' . $networkmap['id_networkmap'] . '">' . io_safe_output($networkmap['name']) . '</a>';
|
||||
$row[__('Type')] = $networkmap['type'];
|
||||
$row[__('Group')] = ui_print_group_icon($networkmap["id_group"], true);
|
||||
$list[] = $row;
|
||||
}
|
||||
|
||||
if (count($network_maps) == 0) {
|
||||
$ui->contentAddHtml('<p style="color: #ff0000;">' . __('No networkmaps') . '</p>');
|
||||
}
|
||||
else {
|
||||
$table = new Table();
|
||||
$table->id = 'list_networkmaps';
|
||||
$table->importFromHash($list);
|
||||
$ui->contentAddHtml($table->getHTML());
|
||||
}
|
||||
}
|
||||
|
||||
private function filterNetworkmapsGetString() {
|
||||
if ($this->default) {
|
||||
return __("(Default)");
|
||||
}
|
||||
else {
|
||||
$networkmap_types = networkmap_get_filter_types();
|
||||
$networkmap_types[0] = __('All');
|
||||
$type = $networkmap_types[$this->type];
|
||||
$group = groups_get_name($this->group, true);
|
||||
|
||||
|
||||
$string = sprintf(
|
||||
__("(Type: %s - Group: %s)"),
|
||||
$type, $group);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue