mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
git-svn-id: http://www.observium.org/svn/observer/trunk@1264 61d68cd4-352d-0410-923a-c4978735b2b8
83 lines
2.8 KiB
PHP
83 lines
2.8 KiB
PHP
<?php
|
|
|
|
if($_GET['debug']) {
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 0);
|
|
ini_set('log_errors', 0);
|
|
ini_set('allow_url_fopen', 0);
|
|
ini_set('error_reporting', E_ALL);
|
|
}
|
|
|
|
include("../includes/defaults.inc.php");
|
|
include("../config.php");
|
|
include("../includes/common.php");
|
|
include("../includes/rewrites.php");
|
|
include("includes/authenticate.inc.php");
|
|
|
|
if(!$config['allow_unauth_graphs']) {
|
|
if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
|
|
}
|
|
|
|
if($_GET['device']) {
|
|
$_GET['id'] = $_GET['device'];
|
|
$device_id = $_GET['device'];
|
|
} elseif($_GET['if']) {
|
|
$_GET['id'] = $_GET['if'];
|
|
} elseif($_GET['port']) {
|
|
$_GET['id'] = $_GET['port'];
|
|
} elseif($_GET['peer']) {
|
|
$_GET['id'] = $_GET['peer'];
|
|
}
|
|
|
|
$from = mres($_GET['from']);
|
|
$to = mres($_GET['to']);
|
|
$width = mres($_GET['width']);
|
|
$height = mres($_GET['height']);
|
|
$title = mres($_GET['title']);
|
|
$vertical = mres($_GET['vertical']);
|
|
$type = mres($_GET['type']);
|
|
$legend = mres($_GET['legend']);
|
|
$id = mres($_GET['id']);
|
|
|
|
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
|
|
|
|
$os = gethostosbyid($device_id);
|
|
if($config['os'][$os]['group']) {$os_group = $config['os'][$os]['group'];}
|
|
|
|
if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".inc.php")) {
|
|
/// Type + OS Specific
|
|
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".inc.php");
|
|
}elseif($os_group && is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php")) {
|
|
/// Type + OS Group Specific
|
|
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php");
|
|
} elseif(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) {
|
|
/// Type Specific
|
|
include($config['install_dir'] . "/html/includes/graphs/$type.inc.php");
|
|
}
|
|
|
|
if($rrd_options) {
|
|
if($_GET['debug']) { echo("<pre>".$config['rrdtool'] . " graph $graphfile $rrd_options\n\n"); }
|
|
$thing = shell_exec($config['rrdtool'] . " graph $graphfile $rrd_options");
|
|
# $thing = popen($config['rrdtool'] . " -",'w');
|
|
# fputs($thing, "graph $graphfile $rrd_options");
|
|
# pclose($thing);
|
|
if(is_file($graphfile)) {
|
|
header('Content-type: image/png');
|
|
$fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd);
|
|
unlink($graphfile);
|
|
} else {
|
|
header('Content-type: image/png');
|
|
$string = "Graph Generation Error";
|
|
$im = imagecreate($width, $height);
|
|
$orange = imagecolorallocate($im, 255, 255, 255);
|
|
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
|
|
imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0));
|
|
imagepng($im);
|
|
imagedestroy($im);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
?>
|