aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/html.inc.php
blob: 51e8b37898b775d9bf1f10a3b9fc1a7e8ddca734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

require_once 'conf/common.inc.php';
require_once 'inc/rrdtool.class.php';

function html_start() {
	global $CONFIG;

	if (isset($_GET['h']))
		$path = ' - '.htmlentities(ucfirst($_GET['h']));
	if (isset($_GET['p']))
		$path .= ' - '.htmlentities(ucfirst($_GET['p']));

	echo <<<EOT
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>CGP{$path}</title>
	<link rel="stylesheet" href="{$CONFIG['weburl']}/layout/style.css" type="text/css">
</head>
<body>

<div id="header">
  <h1><a href="{$CONFIG['weburl']}">Collectd Graph Panel</a></h1>
</div>

<div id="content">

EOT;
}

function html_end() {
	echo <<<EOT
</div>
<div id="footer">
<hr><span class="small">Collectd Graph Panel is distributed under the GNU General Public License (GPL)</span>
</div>
</body>
</html>
EOT;
}

function host_summary($hosts) {
	global $CONFIG;

	$rrd = new RRDTool;

	echo "<table class=\"summary\">\n";

	foreach($hosts as $host) {
		$rrd_info = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/load/load.rrd');
		if (!$rrd_info)
			continue;
		printf('<tr><th><a href="%s/host.php?h=%s">%s</a></th><td>%.2f</td><td>%.2f</td><td>%.2f</td></tr>'."\n",
		$CONFIG['weburl'],$host, $host,
		$rrd_info["ds[shortterm].last_ds"], $rrd_info["ds[midterm].last_ds"], $rrd_info["ds[longterm].last_ds"]);
	}

	echo "</table>\n";
}

?>