Reports And Reporting: puppet_rrd_overview.php

File puppet_rrd_overview.php, 1.6 KB (added by gebi, 10 months ago)

automatic index generator for rrdgraph reporting

Line 
1<?php
2# Copyright 2009: Michael Gebetsroither <gebi@grml.org>
3# License: GPLv2 or any later
4# Usage:
5#    - rename to index.php and drop into /var/lib/puppet/rrd
6#    - serve directory with webserver
7$intervals = array('daily', 'weekly', 'monthly', 'yearly');
8$interval ='weekly';
9if(isset($_GET["res"])) {
10    $get_res = $_GET["res"];
11    if(in_array($get_res, $intervals, true)) {
12        $interval = $_GET["res"];
13    } else {
14        header("Location: " . $_SERVER["SCRIPT_NAME"]);
15    }
16}?>
17<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
18       "http://www.w3.org/TR/html4/loose.dtd">
19<html><head>
20<title>Report graphs</title>
21<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
22<meta http-equiv="refresh" content="300">
23</head>
24<body>
25
26<?php
27//var_dump($_GET);
28//var_dump($_SERVER);
29$script_name = $_SERVER["SCRIPT_NAME"];
30echo "<div align=\"center\">\n";
31foreach ( $intervals as $i ) {
32    echo "<a href=\"$script_name?res=$i\">$i</a>\n";
33}
34echo '</div>';
35
36foreach ( scandir('.') as $host ) {
37    if(!is_dir($host)) {
38        continue;
39    } elseif( $host == '.' || $host == '..' ) {
40        continue;
41    }
42    echo "<div>\n";
43    foreach ( array ('time', 'resources', 'changes') as $res ) {
44        $img_path="$host/$res-$interval.png";
45        echo "<a href=\"$host/$res.html\">";
46        echo "<img style=\"width: 381px; height: 124px;\" src=\"$img_path\" alt=\"$img_path\" border=0>";
47        echo "</a>";
48    }
49    echo "<span style=\"vertical-align:top\"><a href=\"$host\">$host</a></span>\n";
50    echo "</div>\n";
51}
52?>
53</body></html>
54