<?
global $t,$s;

# arrays of urls to munins:
$urler = array(
    
"no" => "http://munin.ping.uio.no/ping.uio.no/",
    
"fud" => "http://fud.no/munin/fud.no/",
    
"rune" => "http://munin.ping.uio.no/runehol.local/"
);

# Computers the different plaves:
$m = array( 
        
"no" => array("cyan.ping.uio.no","hugo.ping.uio.no","sam.ping.uio.no","vodka.ping.uio.no"),
    
"fud" => array("pride.fud.no","lust.fud.no"),
    
"rune" => array("azraq"),
);
# What kind of services to view
$s = array( 
    
"no" => array( 
        
"cyan.ping.uio.no" => array("df-day","if_eth0-day","exim_mailstats-day"),        
        
"hugo.ping.uio.no" => array("df-day","if_eth0-day","exim_mailstats-day"),        
        
"sam.ping.uio.no" => array("df-day","if_eth0-day","load-day"),        
        
"vodka.ping.uio.no" => array("df-day","if_eth0-day","exim_mailstats-day"),        
    ),

    
"fud" => array(
        
"pride.fud.no" => array("if_eth0-day","df-day"),
        
"lust.fud.no" => array("fw_conntrack-day","df-day"),
    ),
    
"rune" => array(
        
"azraq" => array("nfs_client-day","df-day","load-day"),
    ),
);
# Services to view at all computers:
# $t = array( "load-day" );
$t = array( );



# urler som skal startes opp.
$viktige = array(
    
"?t=load-day",
    
"?t=df-day",
    
"?t=cpu-day",
);


function 
arrow($im$x1$y1$x2$y2$alength$awidth$color) {

   
$distance sqrt(pow($x1 $x22) + pow($y1 $y22));

   
$dx $x2 + ($x1 $x2) * $alength $distance;
   
$dy $y2 + ($y1 $y2) * $alength $distance;

   
$k $awidth $alength;

   
$x2o $x2 $dx;
   
$y2o $dy $y2;

   
$x3 $y2o $k $dx;
   
$y3 $x2o $k $dy;

   
$x4 $dx $y2o $k;
   
$y4 $dy $x2o $k;

   
imageline($im$x1$y1$dx$dy$color);
   
imageline($im$x3$y3$x4$y4$color);
   
imageline($im$x3$y3$x2$y2$color);
   
imageline($im$x2$y2$x4$y4$color);

}

function 
ImageRectangleWithRoundedCorners(&$im$x1$y1$x2$y2$radius$color) {
    
// draw rectangle without corners
    
imagefilledrectangle($im$x1+$radius$y1$x2-$radius$y2$color);
    
imagefilledrectangle($im$x1$y1+$radius$x2$y2-$radius$color);
    
// draw circled corners
    
imagefilledellipse($im$x1+$radius$y1+$radius$radius*2$radius*2$color);
    
imagefilledellipse($im$x2-$radius$y1+$radius$radius*2$radius*2$color);
    
imagefilledellipse($im$x1+$radius$y2-$radius$radius*2$radius*2$color);
    
imagefilledellipse($im$x2-$radius$y2-$radius$radius*2$radius*2$color);
}

if (isset(
$_GET["image"])) {
    
header("Content-type: image/png");
    
$w 20;
    
$h 300;
    
$im = @imagecreate($w$h) or die("Cannot Initialize new GD image stream");
    
$black imagecolorallocate($im000);
    
$white imagecolorallocate($im255255255);
    
imagefilltoborder $im111$white );
    
ImageRectangleWithRoundedCorners($im55, ($w-2), ($h-2), 5$black);
    
imagestringup($im34, (4*($h/6)), $_GET["image"], $white);
    
# function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color) {
    
arrow($im202072066$white);
    
arrow($im280280728066$white);
    
imagepng($im);
    
imagedestroy($im);
    die();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
          "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <link rel="stylesheet" href="style.css" type="text/css" /> 
  <meta http-equiv="refresh" content="60" />
  <title>noc overview</title>
  <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
  <meta name="author" content="Rolf" />
</head>
<body>
<?

##### END OF CONFIGURATION

if (!empty($_GET["t"])) { # Hvis parameter: ?t=df-day vises følgende:
    
$s = array();
    
$t = array ($_GET["t"]);
}


function 
fix($str# returnerer stringen fra parameter, hvor -day/-week/-month er fjernet.
{
    
$str str_replace("-day","",$str);
    
$str str_replace("-week","",$str);
    
$str str_replace("-month","",$str);
    return 
$str;
}
echo 
"<p>";

foreach (
$urler as $location => $url) {
    foreach (
$s[$location] as $maskin => $v) {
        
$a0;
        foreach (
$s[$location][$maskin] as $i => $tjeneste) {
            
$a++;
            echo 
"<a href=".$url.$maskin."-".fix($tjeneste).".html><img src=".$url.$maskin."-".$tjeneste.".png></a>\n";
        }
        echo 
"<a href=".$url.$maskin.".html>".'<img border=0 src="?image='.$maskin.'">'."</a>\n";

    }
}
echo 
"</p><p>";

foreach (
$urler as $location => $url) {
    foreach (
$m[$location] as $maskin => $v) {
        if (!
array_key_exists("$v"$s[$location])) {
            echo 
"<a href=".$url.$v."-".fix("cpu-day").".html><img src=".$url.$v."-cpu-day.png></a>\n";
            echo 
"<a href=".$url.$maskin.".html>".'<img border=0 src="?image='.$v.'">'."</a>\n";
        }
    }
}
echo 
"</p><p>";
foreach (
$urler as $location => $url) {
    for (
$n 0$n count($t); $n++)
    {
        echo 
"<p>";
        for (
$i 0$i count($m[$location]); $i++)
        {
            echo 
"<a href=".$url.$m[$location][$i]."-".fix($t[$n]).".html><img src=".$url.$m[$location][$i]."-".$t[$n].".png></a>\n";
        }
        echo 
"</p>";
    }
}
echo 
"</p><p>";

foreach (
$viktige as $key => $url) {
    echo 
"<a href=$url>$url</a><br/>";
}

?>

</body>
</html>