mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 11:29:12 +02:00
* include/functions_menu.php, include/functions_html.php, include/functions_events.php, include/functions_messages.php, include/functions_modules.php, include/functions_exportserver.php, include/functions_reporting.php, include/functions_filemanager.php, include/pchart_graph.php, include/pandora_graph.php, include/auth/dev.php, include/auth/ldap.php, include/auth/mysql.php, include/config.inc.php, include/functions_networkmap.php, include/functions_servers.php, include/FusionCharts/FusionCharts_Gen.php, include/FusionCharts/FusionCharts.php, include/functions_network_profiles.php, include/gettext.php, include/functions_network_components.php, include/functions_visual_map.php, include/fgraph2.php, include/Image/image_functions.php, include/functions_config.php, include/help/en/help_plugin_parameters.php, include/help/en/help_snmpcommunity.php, include/help/en/help_wmiquery.php, include/help/en/help_postprocess.php, include/help/en/help_prediction_source_module.php, include/help/en/help_date_format.php, include/help/en/help_recontask.php, include/help/en/help_alert-matches.php, include/help/en/help_tcp_send.php, include/help/en/help_wmifield.php, include/help/en/help_duplicateconfig.php, include/help/en/help_agent_status.php, include/help/en/help_manage_alerts.php, include/help/en/help_wmikey.php, include/help/en/help_alert_type.php, include/help/en/help_network_component.php, include/help/en/help_time_stamp-comparation.php, include/help/en/help_eventview.php, include/help/en/help_timesource.php, include/help/en/help_alert_validation.php, include/help/en/help_map_builder.php, include/help/en/help_alert_recovery.php, include/help/en/help_module_type.php, include/help/en/help_planned_downtime.php, include/help/en/help_serverlag.php, include/help/en/help_alerts.php, include/help/en/help_snmpwalk.php, include/help/en/help_module_definition.php, include/help/en/help_plugin_definition.php, include/help/en/help_wminamespace.php, include/help/en/help_snmpoid.php include/help/en/help_manageconfig.php, include/help/es/help_alert_validation.php, include/help/es/help_plugin_parameters.php, include/help/es/help_snmpcommunity.php, include/help/es/help_wmiquery.php, include/help/es/help_map_builder.php, include/help/es/help_postprocess.php, include/help/es/help_date_format.php, include/help/es/help_alert_recovery.php, include/help/es/help_prediction_source_module.php, include/help/es/help_module_type.php, include/help/es/help_planned_downtime.php, include/help/es/help_alert-matches.php, include/help/es/help_recontask.php, include/help/es/help_alerts.php, include/help/es/help_serverlag.php, include/help/es/help_snmpwalk.php, include/help/es/help_module_definition.php, include/help/es/help_tcp_send.php, include/help/es/help_duplicateconfig.php, include/help/es/help_wmifield.php, include/help/es/help_manage_alerts.php, include/help/es/help_wmikey.php, include/help/es/help_plugin_definition.php, include/help/es/help_alert_type.php, include/help/es/help_snmpoid.php, include/help/es/help_wminamespace.php, include/help/es/help_network_component.php, include/help/es/help_time_stamp-comparation.php, include/help/es/help_manageconfig.php, include/help/es/help_timesource.php, include/config_process.php, include/functions_ui.php, include/htmlawed.php, include/functions_custom_graphs.php, include/fgraph.php, include/functions_incidents.php, include/functions.php, include/functions_agents.php, include/functions_db.php, include/functions_themes.php, include/streams.php, include/functions_fsgraph.php, include/functions_alerts.php, include/functions_reports.php, include/functions_extensions.php, include/functions_ui_renders.php: change comments blocks for delete the warnings to construct phpDoc Files, give a struct and order in the phpDoc files. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1881 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
298 lines
9.0 KiB
PHP
298 lines
9.0 KiB
PHP
<?php
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
// ==================================================
|
|
// Copyright (c) 2009 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 Lesser General Public License
|
|
// as published by the Free Software Foundation; 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.
|
|
|
|
/**
|
|
* @package Include
|
|
*/
|
|
|
|
/**
|
|
* Include the FusionCharts class
|
|
*/
|
|
require_once ('FusionCharts/FusionCharts_Gen.php');
|
|
|
|
// Returns the code needed to display the chart
|
|
function get_chart_code ($chart, $width, $height, $swf) {
|
|
$random_number = rand ();
|
|
$div_id = 'chart_div_' . $random_number;
|
|
$chart_id = 'chart_' . $random_number;
|
|
$output = '<div id="' . $div_id. '"></div>';
|
|
$output .= '<script type="text/javascript">
|
|
<!--
|
|
$(document).ready(function pie_' . $chart_id . ' () {
|
|
var myChart = new FusionCharts("' . $config['homeurl'] . $swf . '", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
|
|
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
|
|
myChart.addParam("WMode", "Transparent");
|
|
myChart.render("' . $div_id . '");
|
|
})
|
|
-->
|
|
</script>';
|
|
return $output;
|
|
}
|
|
|
|
// Returns a 3D bar chart
|
|
function fs_3d_bar_chart ($data, $width, $height) {
|
|
global $config;
|
|
|
|
if (sizeof ($data) == 0) {
|
|
return fs_error_image ();
|
|
}
|
|
|
|
// Generate the XML
|
|
$chart = new FusionCharts('Column3D', $width, $height);
|
|
|
|
$empty = 1;
|
|
foreach ($data as $name => $value) {
|
|
if ($value > 0) {
|
|
$empty = 0;
|
|
}
|
|
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';color=95BB04');
|
|
}
|
|
|
|
$chart->setChartParams('showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
|
|
|
|
// Return the code
|
|
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_Column3D.swf');
|
|
}
|
|
|
|
// Returns a 3D pie chart
|
|
function fs_3d_pie_chart ($data, $width, $height) {
|
|
global $config;
|
|
|
|
if (sizeof ($data) == 0) {
|
|
return fs_error_image ();
|
|
}
|
|
|
|
// Generate the XML
|
|
$chart = new FusionCharts('Pie3D', $width, $height);
|
|
$chart->setChartParams('showNames=1;showValues=0;showPercentageValues=0;baseFontSize=9');
|
|
|
|
$empty = 1;
|
|
foreach ($data as $name => $value) {
|
|
if ($value > 0) {
|
|
$empty = 0;
|
|
}
|
|
$chart->addChartData($value, 'name=' . clean_flash_string($name));
|
|
}
|
|
|
|
// Chart is not empty, but all elements are 0
|
|
if ($empty == 1) {
|
|
return fs_error_image ();
|
|
}
|
|
|
|
// Return the code
|
|
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_Pie3D.swf');
|
|
}
|
|
|
|
// Returns a 2D area chart
|
|
function fs_2d_area_chart ($data, $width, $height, $step = 1, $params = '') {
|
|
global $config;
|
|
|
|
if (sizeof ($data) == 0) {
|
|
return fs_error_image ();
|
|
}
|
|
|
|
// Generate the XML
|
|
$chart = new FusionCharts('Area2D', $width, $height);
|
|
|
|
$count = 0;
|
|
$num_vlines = 0;
|
|
$empty = 1;
|
|
foreach ($data as $name => $value) {
|
|
if ($count++ % $step == 0) {
|
|
$show_name = '1';
|
|
$num_vlines++;
|
|
} else {
|
|
$show_name = '0';
|
|
}
|
|
if ($value > 0) {
|
|
$empty = 0;
|
|
}
|
|
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=95BB04');
|
|
}
|
|
|
|
$chart->setChartParams('numVDivLines=' . $num_vlines . ';showAlternateVGridColor=1;showNames=1;rotateNames=1;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=1;areaBorderThickness=1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : '') . $params);
|
|
|
|
// Return the code
|
|
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_Area2D.swf');
|
|
}
|
|
|
|
// Returns a Pandora FMS module chart
|
|
function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i') {
|
|
global $config;
|
|
|
|
// Generate the XML
|
|
$chart = new FusionCharts('MSArea2D', $width, $height);
|
|
$num_vlines = 0;
|
|
$count = 0;
|
|
|
|
// Create categories
|
|
foreach ($data as $value) {
|
|
if ($count++ % $step == 0) {
|
|
$show_name = '1';
|
|
$num_vlines++;
|
|
} else {
|
|
$show_name = '0';
|
|
}
|
|
$chart->addCategory(date($time_format, $value['timestamp_bottom']), 'hoverText=' . date ($config['date_format'], $value['timestamp_bottom']) . ';showName=' . $show_name);
|
|
}
|
|
|
|
// Max chart
|
|
if ($avg_only == 0) {
|
|
$chart->addDataSet('Max', 'color=' . $config['graph_color3']);
|
|
foreach ($data as $value) {
|
|
$chart->addChartData($value['max']);
|
|
}
|
|
}
|
|
|
|
// Avg chart
|
|
$empty = 1;
|
|
$chart->addDataSet('Avg', 'color=' . $config['graph_color2']);
|
|
foreach ($data as $value) {
|
|
if ($value['sum'] > 0) {
|
|
$empty = 0;
|
|
}
|
|
$chart->addChartData($value['sum']);
|
|
}
|
|
|
|
// Min chart
|
|
if ($avg_only == 0) {
|
|
$chart->addDataSet('Min', 'color=' . $config['graph_color1']);
|
|
foreach ($data as $value) {
|
|
$chart->addChartData($value['min']);
|
|
}
|
|
}
|
|
|
|
$chart->setChartParams('animation=0;numVDivLines=' . $num_vlines . ';showAlternateVGridColor=1;showNames=1;rotateNames=1;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=1;areaBorderThickness=1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
|
|
|
|
$random_number = rand ();
|
|
$div_id = 'chart_div_' . $random_number;
|
|
$chart_id = 'chart_' . $random_number;
|
|
$output = '<div id="' . $div_id. '" style="z-index:1;"></div>';
|
|
$output .= '<script language="JavaScript" src="' . $config['homeurl'] . '/include/FusionCharts/FusionCharts.js"></script>';
|
|
$output .= '<script type="text/javascript">
|
|
<!--
|
|
function pie_' . $chart_id . ' () {
|
|
var myChart = new FusionCharts("' . $config['homeurl'] . '/include/FusionCharts/FCF_MSArea2D.swf", "' . $chart_id . '", "' . $width. '", "' . $height. '", "0", "1");
|
|
myChart.setDataXML("' . addslashes($chart->getXML ()) . '");
|
|
myChart.addParam("WMode", "Transparent");
|
|
myChart.render("' . $div_id . '");
|
|
}
|
|
pie_' . $chart_id . ' ();
|
|
-->
|
|
</script>';
|
|
return $output;
|
|
}
|
|
|
|
// Returns a Pandora FMS combined chart
|
|
function fs_combined_chart ($data, $categories, $sets, $width, $height, $type = 1, $step = 10, $time_format = 'G:i') {
|
|
global $config;
|
|
|
|
if (sizeof ($data) == 0) {
|
|
return fs_error_image ();
|
|
}
|
|
|
|
// Generate the XML
|
|
switch ($type) {
|
|
case 0: $chart_type = 'MSArea2D';
|
|
break;
|
|
case 1: $chart_type = 'StackedArea2D';
|
|
break;
|
|
case 2: $chart_type = 'MSLine';
|
|
break;
|
|
default: $chart_type = 'StackedArea2D';
|
|
}
|
|
|
|
$chart = new FusionCharts($chart_type, $width, $height);
|
|
|
|
// Create categories
|
|
$count = 0;
|
|
$num_vlines = 0;
|
|
foreach ($categories as $category) {
|
|
if ($count++ % $step == 0) {
|
|
$show_name = '1';
|
|
$num_vlines++;
|
|
} else {
|
|
$show_name = '0';
|
|
}
|
|
|
|
$chart->addCategory(date($time_format, $category['timestamp_bottom']), 'hoverText=' . date ($config['date_format'], $category['timestamp_bottom']) . ';showName=' . $show_name);
|
|
}
|
|
|
|
// Stack charts
|
|
$empty = 1;
|
|
for ($i = 0; $i < sizeof ($data); $i++) {
|
|
$chart->addDataSet ($sets[$i]);
|
|
foreach ($data[$i] as $value) {
|
|
if ($value > 0) {
|
|
$empty = 0;
|
|
}
|
|
$chart->addChartData($value);
|
|
}
|
|
}
|
|
|
|
$chart->setChartParams('animation=0;numVDivLines=' . $num_vlines . ';showAlternateVGridColor=1;showNames=1;rotateNames=1;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=1;areaBorderThickness=1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
|
|
|
|
// Return the code
|
|
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_' . $chart_type . '.swf');
|
|
}
|
|
|
|
// Returns a Pandora FMS agent event chart
|
|
function fs_agent_event_chart ($data, $width, $height, $step = 1) {
|
|
global $config;
|
|
|
|
if (sizeof ($data) == 0) {
|
|
return fs_error_image ();
|
|
}
|
|
|
|
// Generate the XML
|
|
$chart = new FusionCharts('Area2D', $width, $height);
|
|
|
|
$count = 0;
|
|
$num_vlines = 0;
|
|
foreach ($data as $name => $value) {
|
|
if ($count++ % $step == 0) {
|
|
$show_name = '1';
|
|
$num_vlines++;
|
|
} else {
|
|
$show_name = '0';
|
|
}
|
|
$chart->addChartData(1, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=' . $value);
|
|
}
|
|
|
|
$chart->setChartParams('numDivLines=0;numVDivLines=0;showNames=1;rotateNames=0;showValues=0;baseFontSize=9;showLimits=0;showAreaBorder=0;areaBorderThickness=1;canvasBgColor=9ABD18');
|
|
|
|
// Return the code
|
|
return get_chart_code ($chart, $width, $height, 'include/FusionCharts/FCF_Area2D.swf');
|
|
}
|
|
|
|
// Clean FLASH string strips non-valid characters for flashchart
|
|
function clean_flash_string ($string) {
|
|
$string = html_entity_decode ($string, ENT_QUOTES, "UTF-8");
|
|
$string = str_replace('&', '', $string);
|
|
$string = str_replace(' ', '', $string);
|
|
$string = str_replace ('"', '', $string);
|
|
return substr ($string, 0, 20);
|
|
}
|
|
|
|
// Prints an error image
|
|
function fs_error_image () {
|
|
global $config;
|
|
|
|
return '<img border="0" src="' . $config['homeurl'] . '/images/image_problem.png" />';
|
|
}
|
|
|
|
?>
|