Files
librenms-librenms/html/graph.php
T

195 lines
8.3 KiB
PHP
Raw Normal View History

2007-04-03 14:10:23 +00:00
<?php
2007-11-21 14:26:24 +00:00
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('log_errors', 1);
2007-04-03 14:10:23 +00:00
ini_set('allow_url_fopen', 0);
# ini_set('error_reporting', E_ALL);
include("../config.php");
include("../includes/functions.php");
include("includes/authenticate.inc");
2008-03-09 17:39:14 +00:00
if($_GET['params']) {
list($_GET['host'], $_GET['if'], $_GET['from'], $_GET['to'], $_GET['width'], $_GET['height'], $_GET['title'], $_GET['vertical'], $_GET['type'], $_GET['interfaces']) = explode("||", mcrypt_ecb(MCRYPT_DES, $key_value, $_GET['params'], MCRYPT_DECRYPT));
}
2007-04-03 14:10:23 +00:00
if($_GET['host']) {
$device_id = $_GET['host'];
} elseif($_GET['device']) {
$device_id = $_GET['device'];
} elseif($_GET['if']) {
$device_id = getifhost($_GET['if']);
2007-04-03 14:10:23 +00:00
$ifIndex = getifindexbyid($_GET['if']);
} elseif($_GET['peer']) {
$device_id = getpeerhost($_GET['peer']);
2007-04-03 14:10:23 +00:00
}
if($device_id) {
$hostname = gethostbyid($device_id);
}
2007-04-03 14:10:23 +00:00
$from = $_GET['from'];
$to = $_GET['to'];
$width = $_GET['width'];
$height = $_GET['height'];
$title = $_GET['title'];
$vertical = $_GET['vertical'];
$type = $_GET['type'];
2007-11-21 14:26:24 +00:00
$graphfile = strgen() . ".png";
2007-04-03 14:10:23 +00:00
$os = gethostosbyid($device_id);
2007-04-03 14:10:23 +00:00
switch ($type) {
2007-11-21 14:26:24 +00:00
case 'multi_bits':
$graph = graph_multi_bits ($_GET['interfaces'], $graphfile, $from, $to, $width, $height);
break;
case 'global_bits':
$graph = graph_global_bits ("global_bits.png", $from, $to, $width, $height);
break;
case 'device_bits':
$graph = graph_device_bits ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
2007-04-03 14:10:23 +00:00
case 'bits':
$graph = trafgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'pkts':
$graph = pktsgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'errors':
$graph = errorgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'nupkts':
$graph = nucastgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'uptime':
$graph = uptimegraph ($hostname . "/uptime.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
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;
case 'bgpupdates':
$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;
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;
case 'ip_graph':
2008-03-12 13:55:50 +00:00
$graph = ip_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'icmp_graph':
2008-03-12 13:55:50 +00:00
$graph = icmp_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'tcp_graph':
2008-03-12 13:55:50 +00:00
$graph = tcp_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'udp_graph':
2008-03-12 13:55:50 +00:00
$graph = udp_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
break;
case 'cpu':
if($os == "Linux" || $os == "NetBSD" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "Windows" || $os == "m0n0wall" || $os == "Voswall" || $os == "pfSense" || $os == "DragonFly" || $os == "OpenBSD") {
2008-03-12 13:55:50 +00:00
$graph = cpugraphUnix ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
} elseif($os == "IOS") {
2008-03-12 13:55:50 +00:00
$graph = cpugraph ($hostname . "/cpu.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 = cpugraphwin ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
} elseif($os == "ProCurve") {
2008-03-12 13:55:50 +00:00
$graph = cpugraphHP ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
2007-04-03 14:10:23 +00:00
} elseif($os == "Snom") {
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;
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;
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);
2007-04-03 14:10:23 +00:00
} elseif($os == "IOS") {
2008-03-12 13:55:50 +00:00
$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);
2007-04-03 14:10:23 +00:00
} elseif($os == "IOS") {
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" ) {
$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;
}
if($graph) {
2007-11-21 14:26:24 +00:00
header('Content-type: image/png');
2007-04-03 14:10:23 +00:00
echo(`cat graphs/$graphfile`);
} else {
2007-11-21 14:26:24 +00:00
header('Content-type: image/png');
echo(`cat images/no-graph.png`);
2007-04-03 14:10:23 +00:00
}
$delete = `rm graphs/$graphfile`;
?>