MonkeyBrains.net/~rudy/example Random examples
Munin is a great tool to quickly set up monitoring on your server farm. One thing that really augments an installation is the ability to see all the 'CPU' or 'netwrok' graphs on one page. This little PHP script can be tossed into your munin folder as 'smart.php' and used to auto-generate side-by-side comparisons.

smart.php

<html><head> <title>Munin multi-host view</title> <META name="Author" content="Rudy Rucker"> <META name="Description" content="Easily compare the same plugin graphs across all hosts in day/week/month/year timeframes. Find trends!"> <style> body { margin: 1px; font-family: geneva, helvetica; } A { color: blue; padding: 2px; } A:hover { padding: 1px; color: red; background:white; border: 1px solid blue; } .topbox { background:#aea; border:4px dotted green;} .imgleft, .imgright { width:501px; margin: 4px 0; background: #aea; border: 2px solid green;} .imgleft { float:left;} .imgright { float:right;} </style> </head> <body> <center> <div class=topbox> <a href=smart.php?time=day>Day</a> | <a href=smart.php?time=week>Week</a> | <a href=smart.php?time=month>Month</a> | <a href=smart.php?time=year>Year</a> <br> <a href=smart.php?search=cpu>CPU</a> | <a href=smart.php?search=if_eth0>if_eth0</a> | <a href=smart.php?search=if_eth1>if_eth1</a> | <a href=smart.php?search=mysql_queries>MySQL Queries</a> | <!-- example of custom plugin with wildcards... --> <a href=smart.php?search=ubnt_.*_signal>ubnt_signal</a> | <a href=smart.php?search=ubnt_.*_if>ubnt_if</a> <!-- example of some random other munin plugin | <a href=smart.php?search=smart_sda>S.M.A.R.T.</a> --> </div> </center> <?php $muninwwwdir = "./"; //$muninwwwdir = "/var/www/munin/"; //<-- set if the simple ./ doesn't work session_start(); $pos = array('imgleft', 'imgright'); // set up 3, if you like $search = 'cpu'; if (isset($_SESSION['search'])) { $search=$_SESSION['search']; } if (isset($_GET['search'])) { if (preg_match("/^([a-zA-Z0-9_]{2,50})(\.\*[a-zA-Z0-9_]{2,50})?$/", $_GET['search'])) { $search=$_GET['search']; $_SESSION['search']=$search; } } $timeframe = 'day'; if (isset($_SESSION['timeframe'])) { $timeframe=$_SESSION['timeframe']; } if (isset($_GET['time'])) { if (preg_match("/^(day|week|month|year)$/", $_GET['time'])) { $timeframe=$_GET['time']; $_SESSION['timeframe']=$timeframe; } } $images = array(); // Open a known directory, and proceed to read its contents if (is_dir($muninwwwdir)) { if ($dh = opendir($muninwwwdir)) { while (($subdir = readdir($dh)) !== false) { if (is_dir($subdir)) { if ($subdh = opendir($subdir)) { while (($file = readdir($subdh)) !== false) { if (preg_match("/(.*)-$search-$timeframe.png\$/", $file)) { array_push($images, "$subdir/$file"); } } } } } closedir($dh); } } // Sort and print results. sort($images); $counter = 0; foreach ($images as $file) { preg_match("/(.*)-$search-$timeframe.png\$/", $file, $match); echo "<div class='".$pos[$counter % count($pos)]."'>$match[1]<br> <img src=$file></div>\n"; if ($counter % count($pos) == count($pos)-1) { print "<br clear=all>\n"; } $counter++; } ?> <br clear=all> <hr> <img src='http://monkeybrains.net/~rudy/example/munin-multi-view.gif' align=left> <br> Page updated by Rudy <i>Fri Feb 19 00:59:10 PST 2010</i> <br>Host your server with monkeybrains.net! </html>