2007-04-03 14:10:23 +00:00
|
|
|
<?php
|
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
|
2009-04-23 21:13:56 +00:00
|
|
|
if($_GET['debug']) {
|
2009-04-13 19:16:22 +00:00
|
|
|
ini_set('display_errors', 1);
|
2008-03-22 16:55:27 +00:00
|
|
|
ini_set('display_startup_errors', 0);
|
|
|
|
ini_set('log_errors', 0);
|
2007-04-03 14:10:23 +00:00
|
|
|
ini_set('allow_url_fopen', 0);
|
2009-04-23 21:13:56 +00:00
|
|
|
ini_set('error_reporting', E_ALL);
|
|
|
|
}
|
2007-04-03 14:10:23 +00:00
|
|
|
|
|
|
|
include("../config.php");
|
2009-05-07 13:47:51 +00:00
|
|
|
include("../includes/common.php");
|
|
|
|
include("../includes/graphing.php");
|
2007-04-03 14:10:23 +00:00
|
|
|
include("includes/authenticate.inc");
|
2009-05-07 13:47:51 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
# if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
|
2009-03-11 14:46:55 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
if($_GET['device']) {
|
2007-04-08 14:34:19 +00:00
|
|
|
$device_id = $_GET['device'];
|
|
|
|
} elseif($_GET['if']) {
|
|
|
|
$device_id = getifhost($_GET['if']);
|
2007-04-03 14:10:23 +00:00
|
|
|
$ifIndex = getifindexbyid($_GET['if']);
|
2009-10-13 20:07:31 +00:00
|
|
|
} elseif($_GET['port']) {
|
|
|
|
$device_id = getifhost($_GET['port']);
|
|
|
|
$ifIndex = getifindexbyid($_GET['port']);
|
2008-03-15 17:58:15 +00:00
|
|
|
} elseif($_GET['peer']) {
|
|
|
|
$device_id = getpeerhost($_GET['peer']);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
2008-03-15 17:58:15 +00:00
|
|
|
|
2009-03-30 11:20:18 +00:00
|
|
|
if($device_id) { $hostname = gethostbyid($device_id); }
|
2007-04-04 22:05:52 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
$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']);
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
|
2007-04-03 14:10:23 +00:00
|
|
|
|
2007-04-08 14:34:19 +00:00
|
|
|
$os = gethostosbyid($device_id);
|
2009-11-07 02:30:38 +00:00
|
|
|
$os_lower = strtolower($os);
|
|
|
|
if($os_groups[$os_lower]) {$os_group = $os_groups[$os_lower];}
|
|
|
|
|
|
|
|
if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".inc.php")) {
|
|
|
|
/// Type + OS Specific
|
|
|
|
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".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");
|
2009-10-28 13:49:37 +00:00
|
|
|
} elseif(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) {
|
2009-11-07 02:30:38 +00:00
|
|
|
/// Type Specific
|
2009-10-28 13:49:37 +00:00
|
|
|
include($config['install_dir'] . "/html/includes/graphs/$type.inc.php");
|
|
|
|
}
|
|
|
|
|
|
|
|
if($rrd_options) {
|
2009-11-11 11:56:14 +00:00
|
|
|
if($_GET['debug']) { echo("<pre>".$config['rrdtool'] . " graph $graphfile $rrd_options"); }
|
2009-10-28 13:49:37 +00:00
|
|
|
$thing = shell_exec($config['rrdtool'] . " graph $graphfile $rrd_options");
|
|
|
|
if(is_file($graphfile)) {
|
|
|
|
header('Content-type: image/png');
|
|
|
|
echo(`cat $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);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
2007-04-03 14:10:23 +00:00
|
|
|
switch ($type) {
|
2009-05-06 16:50:51 +00:00
|
|
|
case 'cisco_entity_sensor':
|
|
|
|
$graph = graph_entity_sensor ($_GET['a'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2008-04-03 21:52:59 +00:00
|
|
|
case 'fortigate_sessions':
|
|
|
|
$graph = graph_fortigate_sessions ($hostname . "/fortigate-sessions.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
|
|
|
case 'fortigate_cpu':
|
|
|
|
$graph = graph_fortigate_cpu ($hostname . "/fortigate-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
|
|
|
case 'fortigate_memory':
|
|
|
|
$graph = graph_fortigate_memory ($hostname . "/fortigate-memory.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2008-03-20 11:53:19 +00:00
|
|
|
case 'netscreen_sessions':
|
|
|
|
$graph = graph_netscreen_sessions ($hostname . "/netscreen-sessions.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
|
|
|
case 'netscreen_cpu':
|
|
|
|
$graph = graph_netscreen_cpu ($hostname . "/netscreen-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
|
|
|
case 'netscreen_memory':
|
|
|
|
$graph = graph_netscreen_memory ($hostname . "/netscreen-memory.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2009-07-31 10:53:54 +00:00
|
|
|
case 'multi_bits_duo':
|
|
|
|
$groups = array($_GET['interfaces'], $_GET['interfaces_b']);
|
|
|
|
$graph = graph_multi_bits_duo ($groups, $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend);
|
|
|
|
break;
|
|
|
|
case 'multi_bits_trio':
|
|
|
|
$groups = array($_GET['interfaces'], $_GET['interfaces_b'], $_GET['interfaces_c']);
|
|
|
|
$graph = graph_multi_bits_trio ($groups, $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend);
|
|
|
|
break;
|
2008-09-03 20:04:34 +00:00
|
|
|
case 'adsl_rate':
|
|
|
|
$graph = graph_adsl_rate ($hostname. "/adsl-4.rrd", $graphfile, $from, $to, $width, $height);
|
|
|
|
break;
|
|
|
|
case 'adsl_snr':
|
|
|
|
$graph = graph_adsl_snr ($hostname. "/adsl-4.rrd", $graphfile, $from, $to, $width, $height);
|
|
|
|
break;
|
|
|
|
case 'adsl_atn':
|
|
|
|
$graph = graph_adsl_atn ($hostname. "/adsl-4.rrd", $graphfile, $from, $to, $width, $height);
|
|
|
|
break;
|
2007-04-04 22:05:52 +00:00
|
|
|
case 'global_bits':
|
|
|
|
$graph = graph_global_bits ("global_bits.png", $from, $to, $width, $height);
|
|
|
|
break;
|
2009-02-02 15:38:34 +00:00
|
|
|
case 'mac_acc_int':
|
|
|
|
$graph = graph_mac_acc_interface ($_GET['if'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2009-09-18 14:45:34 +00:00
|
|
|
case 'mac_acc_pkts':
|
|
|
|
$graph = graph_mac_pkts ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2009-02-02 15:38:34 +00:00
|
|
|
case 'mac_acc':
|
2009-09-18 14:45:34 +00:00
|
|
|
case 'mac_acc_bits':
|
2009-02-02 15:38:34 +00:00
|
|
|
$graph = graph_mac_acc ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2007-06-06 09:23:41 +00:00
|
|
|
case 'unixfs_dev':
|
|
|
|
$graph = unixfsgraph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2007-04-03 14:10:23 +00:00
|
|
|
case 'unixfs':
|
2007-06-06 09:23:41 +00:00
|
|
|
$graph = unixfsgraph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
break;
|
2009-03-30 11:20:18 +00:00
|
|
|
case 'bgp_updates':
|
2008-03-15 17:58:15 +00:00
|
|
|
$bgpPeerIdentifier = mysql_result(mysql_query("SELECT bgpPeerIdentifier FROM bgpPeers WHERE bgpPeer_id = '".$_GET['peer']."'"),0);
|
|
|
|
$graph = bgpupdatesgraph ($hostname . "/bgp-" . $bgpPeerIdentifier . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2009-03-30 11:20:18 +00:00
|
|
|
case 'cbgp_prefixes':
|
|
|
|
$bgpPeerIdentifier = mysql_result(mysql_query("SELECT bgpPeerIdentifier FROM bgpPeers WHERE bgpPeer_id = '".$_GET['peer']."'"),0);
|
|
|
|
$graph = graph_cbgp_prefixes ($hostname . "/cbgp-" . $bgpPeerIdentifier . ".".$_GET['afi'].".".$_GET['safi'].".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2007-04-03 14:10:23 +00:00
|
|
|
case 'calls':
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = callsgraphSNOM ($hostname . "/data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
break;
|
2009-04-13 19:16:22 +00:00
|
|
|
case 'dev_cpmCPU':
|
|
|
|
$graph = graph_device_cpmCPU ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2009-04-23 21:13:56 +00:00
|
|
|
case 'cpmCPU':
|
|
|
|
$graph = graph_cpmCPU ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2007-04-03 14:10:23 +00:00
|
|
|
case 'temp':
|
2007-06-06 09:23:41 +00:00
|
|
|
$graph = temp_graph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
|
|
|
case 'dev_temp':
|
|
|
|
$graph = temp_graph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
break;
|
2009-04-23 21:13:56 +00:00
|
|
|
case 'cempMemPool':
|
|
|
|
$graph = graph_cempMemPool ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
break;
|
2007-04-03 14:10:23 +00:00
|
|
|
case 'mem':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = memgraphUnix ($hostname . "/mem.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2009-04-11 19:10:48 +00:00
|
|
|
} elseif($os == "IOS" || $os == "IOS XE") {
|
2009-04-23 21:13:56 +00:00
|
|
|
$graph = graph_device_cempMemPool ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2009-10-05 12:47:16 +00:00
|
|
|
} elseif($os == "CatOS") {
|
|
|
|
$graph = memgraph ($hostname . "/mem.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
} elseif($os == "Windows") {
|
|
|
|
} elseif($os == "ProCurve") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = memgraphHP ($hostname . "/mem.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'load':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = loadgraphUnix ($hostname . "/load.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2009-04-11 19:10:48 +00:00
|
|
|
} elseif($os == "IOS" || $os == "IOS XE") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = loadgraph ($hostname . "/load.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
} elseif($os == "Windows") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = loadgraphwin ($hostname . "/load.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'users':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = usersgraphUnix ($hostname . "/sys.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
} elseif($os == "Windows") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = usersgraphwin ($hostname . "/sys.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'procs':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = procsgraphUnix ($hostname . "/sys.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
} elseif($os == "Windows") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = procsgraphwin ($hostname . "/sys.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'unixfs':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) {
|
2007-04-08 14:34:19 +00:00
|
|
|
$graph = unixfsgraph ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'postfix':
|
2007-11-21 14:26:24 +00:00
|
|
|
case 'mail':
|
2007-04-03 14:10:23 +00:00
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = mailsgraphUnix ($hostname . "/mailstats.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-11-21 14:26:24 +00:00
|
|
|
case 'mailerrors':
|
2007-04-03 14:10:23 +00:00
|
|
|
case 'postfixerrors':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD") {
|
|
|
|
$graph = mailerrorgraphUnix ($hostname, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'courier':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = couriergraphUnix ($hostname . "/courierstats.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'apachehits':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = apachehitsgraphUnix ($hostname . "/apache.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'apachebits':
|
|
|
|
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD") {
|
2008-03-12 13:55:50 +00:00
|
|
|
$graph = apachebitsgraphUnix ($hostname . "/apache.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-03-30 11:20:18 +00:00
|
|
|
default:
|
2009-04-23 21:13:56 +00:00
|
|
|
break;
|
2009-10-28 13:49:37 +00:00
|
|
|
} // End SWITCH
|
2007-04-03 14:10:23 +00:00
|
|
|
|
|
|
|
if($graph) {
|
2007-11-21 14:26:24 +00:00
|
|
|
header('Content-type: image/png');
|
2009-10-28 13:49:37 +00:00
|
|
|
echo(`cat $graphfile`);
|
2007-04-03 14:10:23 +00:00
|
|
|
} else {
|
2007-11-21 14:26:24 +00:00
|
|
|
header('Content-type: image/png');
|
2009-03-30 11:20:18 +00:00
|
|
|
$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);
|
2007-04-03 14:10:23 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 13:49:37 +00:00
|
|
|
$delete = `rm $graphfile`;
|
|
|
|
|
|
|
|
} // End IF
|
|
|
|
|
2007-04-03 14:10:23 +00:00
|
|
|
|
|
|
|
?>
|