Skip to content

Instantly share code, notes, and snippets.

@oremj
Created July 8, 2010 19:31
Show Gist options
  • Save oremj/468469 to your computer and use it in GitHub Desktop.
Save oremj/468469 to your computer and use it in GitHub Desktop.
<?php
$sizes = array("small", "medium", "large");
$periods = array("hour", "day", "week", "month", "year");
if(in_array($_GET['size'], $sizes)) {
$size = $_GET['size'];
} else {
$size = "medium";
}
if(in_array($_GET['period'], $periods)) {
$period = $_GET['period'];
} else {
$period = "day";
}
function graph_img($cluster, $name, $period, $size) {
$params = array('g' => $name, 'c' => $cluster, 'z' => $size, 'r' => $period);
return '<img src="graph.php?' . http_build_query($params) . '" />';
}
?>
<html>
<head>
<title>AMO: Stuff that matters</title>
</head>
<body>
<h1>AMO Graphs</h1>
<form method="get">
Period: <select name="period">
<?php foreach($periods as $p): ?>
<option <?php echo $p == $period ? 'selected="selected"' : ''; ?> value="<?php echo $p ?>"><?php echo $p ?></option>
<?php endforeach; ?>
</select>
Size: <select name="size">
<?php foreach($sizes as $s): ?>
<option <?php echo $s == $size ? 'selected="selected"': ''; ?> value="<?php echo $s ?>"><?php echo $s ?></option>
<?php endforeach; ?>
</select>
<input type="submit" value="Switch" />
</form>
<h2>Webheads</h2>
<div>
<?php echo graph_img('amo', 'cpu_report', $period, $size) ?>
<?php echo graph_img('amo', 'load_report', $period, $size) ?>
<?php echo graph_img('amo', 'apache_report', $period, $size) ?>
<?php echo graph_img('amo', 'network_report', $period, $size) ?>
</div>
<h2>Memcached</h2>
<div>
<?php echo graph_img('memcache-amo', 'memcached_report', $period, $size) ?>
<?php echo graph_img('memcache-amo', 'network_report', $period, $size) ?>
</div>
<h2>DB</h2>
<div>
<?php echo graph_img('db-amo', 'cpu_report', $period, $size) ?>
<?php echo graph_img('db-amo', 'load_report', $period, $size) ?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment