Permalink
Browse files

Initial git checkin

  • Loading branch information...
0 parents commit 3d26c6a0325ad36ce0bab1a3ca708c2fcddfc312 @lozzd committed Dec 6, 2009
Showing with 260 additions and 0 deletions.
  1. +98 −0 README
  2. BIN ajax-loader.gif
  3. +40 −0 config.php
  4. +57 −0 graphview.php
  5. +65 −0 index.php
98 README
@@ -0,0 +1,98 @@
+
+#########################################################################
+# #
+# CactiView v0.1 - Laurie Denness #
+# http://laurie.denness.net - laurie@denness.net #
+# #
+# Displays a section of Cacti graphs based on your selection. #
+# Graphs rotate automatically every 20 seconds (by default) #
+# #
+# Configuration is available in config.php #
+# #
+#########################################################################
+
+
+DISCLAIMER: I am not a PHP developer. I am a sysadmin. This code is probably not 100% glamorous,
+but it works. If you have any problems, I'm sure they won't be hard to solve; and I cannot be
+held responsible if you lose data, time, your girlfriend, your house, or anything else from
+using this code.
+
+
+0. Requirements
+
+- PHP
+- Cacti
+- A monitor dedicated for graphs, preferably hanging from the ceiling or wall.
+- A web browser running on a computer attached to said monitor
+
+1. Limitations
+
+At the present time, this is intended for a specific screen resolution and there is no easy
+way to change this dynamically. If it doesn't quite fit, please manually alter the size of the
+graphs using the numbers in graphview.php.
+
+2. What it does
+
+CactiView gives you a clean and simple view of one data source from Cacti at a time. You can
+name the data sources, and set the automatic rotation duration.
+
+You can see how this looks here: http://www.flickr.com/photos/lozzd/3210562508/
+
+One main large graph for the last 12 hours, 3 smaller graphs with longer time periods and a
+couple of other bits and bobs of information.
+
+3. Configuration
+
+To get the most of CactiView, you should make a couple of simple changes to your Cacti
+installation. These are optional, but will improve the output of CactiView. More details later.
+
+The actual configuration of CactiView is very simple. You do not even have to run CactiView on
+the same server as Cacti. Each configuration option is detailed in the config file, config.php.
+At the very least, you should set a sensible timeout, the web path to Cacti (to display the
+actual graphs) and of course the graphs. All that is required for this is the internal ID of
+the graph in Cacti, and a name for the graph.
+
+4. Using CactiView
+
+After configuration, open a browser (I suggest Google Chrome, more here:
+http://laurie.denness.net/blog/2009/05/finding-a-web-browser-for-constant-page-reloading/ )
+and point it to where you installed CactiView. e.g. http://host/cactiview
+
+You should land at your first graph, and after the timeout, it will rotate to the next graph
+in the array until it hits the last at which point it will start again at the being. This repeats
+forever.
+
+5. Hints and tips
+
+If displaying this unattended constantly, it is a good idea to use a method to turn off the
+display when no one will be looking at it (if possible!). On Windows, I provide a couple of
+small .exe files, one which sleeps the displays, and one to wake them. You can then use
+Task Scheduler to have the monitors be controlled automatically. Using Linux, you can use
+dpms to sleep and wake the monitors using cron.
+
+6. Modifying Cacti
+
+To remove the graph title from the CactiView graphs to make the display cleaner, you need
+to add a small amount of code to Cacti itself. This is optional, but recommended.
+
+--- cacti-0.8.7d/lib/rrd.php 2009-02-12 02:55:50.000000000 +0000
++++ cacti/lib/rrd.php 2009-04-01 16:41:08.961126012 +0000
+@@ -830,6 +830,16 @@
+ }
+ }
+
++ /* Last.fm modification, allow us to get a basic graph for CactiView */
++
++ if (isset($_GET['notitle'])) {
++ $graph["title_cache"] = '';
++ $graph["vertical_label"] = '';
++ $graph_opts .= "-c MGRID#888888" . RRD_NL;
++ $graph_opts .= "--slope-mode" . RRD_NL;
++ }
++
++
+
+
+7. Help me!
+
+No! Well maybe. Send me an email, and I can probably offer some advice. I apologise if not!
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,40 @@
+<?
+#########################################################################
+#
+# CactiView v0.1 - Laurie Denness
+# http://laurie.denness.net - laurie@denness.net
+#
+# Displays a section of Cacti graphs based on your selection.
+# Graphs rotate automatically every 20 seconds (by default)
+#
+# Configuration is available in config.php
+#
+#########################################################################
+
+## CactiView configuration
+
+# Time (in milliseconds) before the graphs will rotate automatically.
+$timeout = 20000;
+
+# Path to cacti (on your webserver, including the trailing slash) e.g. http://cactihost/cacti/
+$cactipath = "http://host/cacti/";
+
+
+# Graph definitions
+#
+# Alter the lines below to take the graphs you wish to rotate.
+# For example, if the Cacti URL http://host/cacti/graph.php?action=view&local_graph_id=558&rra_id=all
+# then your "cactiid" is 558. Then enter a title of your choosing to be display on the graph.
+#
+# You can define as many graphs as you wish.
+
+$graphs = array (
+array("cactiid" => 1 , "title" => "Graph 1" ),
+array("cactiid" => 2 , "title" => "Graph 2" ),
+);
+
+
+# Disable debugging
+error_reporting(0);
+
+?>
@@ -0,0 +1,57 @@
+<?php
+
+# Get the config
+include("config.php");
+
+# Get the requested graphid and store it in a somewhat more beautiful variable name
+$id = $_GET['id'];
+
+# Set up some variables
+# The Cacti ID
+$cactigraph = $graphs[$id]['cactiid'];
+# The title of the graph
+$title = $graphs[$id]["title"];
+
+# The title of the next graph, with some logic to set the next to the first if we run out of graphs
+if ($id < (count($graphs) -1)) {
+ $nexttitle = $graphs[$id+1]["title"];
+} else {
+ $nexttitle = $graphs[0]["title"];
+}
+
+?>
+
+<html>
+<head>
+<title>CactiView - Graph View</title>
+<style>
+body {
+ margin: 0px;
+ font-family: Tahoma, Helvetica, Verdana, Arial, sans-serif;
+}
+</style>
+</head>
+
+
+<body>
+
+<table>
+<tr>
+ <td><img src="<?php echo $cactipath ?>graph_image.php?action=zoom&local_graph_id=<?php echo $cactigraph ?>&rra_id=0&graph_height=970&graph_width=1085&graph_nolegend=1&graph_end=<?php echo time(); ?>&graph_start=<?php echo time() - 43200; ?>&view_type=tree&notitle=1"></td>
+ <td valign="top"><img src="<?php echo $cactipath ?>graph_image.php?action=view&local_graph_id=<?php echo $cactigraph ?>&rra_id=2&graph_height=255&graph_width=400&graph_nolegend=1&notitle=1">
+ <img src="<?php echo $cactipath ?>graph_image.php?action=view&local_graph_id=<?php echo $cactigraph ?>&rra_id=3&graph_height=255&graph_width=400&graph_nolegend=1&notitle=1">
+ <img src="<?php echo $cactipath ?>graph_image.php?action=view&local_graph_id=<?php echo $cactigraph ?>&rra_id=4&graph_height=255&graph_width=400&graph_nolegend=1&notitle=1">
+
+ <div style="margin-top: 10px; font-size: 48px; text-align: center;"><?php echo date('j/n/y G:i T'); ?></div>
+ <div style="font-size: 40px; text-align: center;"><?php echo date_format(date_create('now', timezone_open('EST')), 'j/n/y G:i T'); ?></div>
+
+ </td>
+</tr>
+</table>
+
+<div style="position: fixed; left: 100; width: 600; top: 30; font-size: 60px;"><?php echo $title; ?></div>
+<div style="position: fixed; left: 100; width: 600; top: 100; font-size: 30px;">Next: <?php echo $nexttitle ?></div><br />
+<div style="position: fixed; left: 1620; width: 30; top: 10;"><img src="ajax-loader.gif"></div><br />
+
+</body>
+</html>
@@ -0,0 +1,65 @@
+<?php
+
+#########################################################################
+#
+# CactiView v0.1 - Laurie Denness
+# http://laurie.denness.net - laurie@denness.net
+#
+# Displays a section of Cacti graphs based on your selection.
+# Graphs rotate automatically every 20 seconds (default)
+#
+# Configuration is available in config.php
+#
+#########################################################################
+
+
+include("config.php");
+
+header("Cache-Control: no-cache, must-revalidate");
+header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+
+$numbergraphs = count($graphs);
+
+?>
+
+<html>
+<head>
+<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
+<title>CactiView</title>
+
+<script language="javascript">
+var aTimer;
+var i;
+i = 1;
+function setRepeater() {
+ aTimer = window.setInterval("changePage();",<?php echo $timeout ?>);
+ return false;
+}
+
+function changePage() {
+
+ if (i==<?php echo $numbergraphs ?>) {
+ i = 0;
+ }
+
+ mainframe.location='graphview.php?id=' + i;
+
+ i++
+}
+
+setRepeater();
+
+</script>
+
+
+</head>
+
+
+
+
+<FRAMESET COLS="*">
+<FRAME SRC="graphview.php?id=0" NAME="mainframe">
+</FRAMESET>
+
+
+</html>

0 comments on commit 3d26c6a

Please sign in to comment.