Created
June 10, 2017 11:25
-
-
Save Esmala/fb9b2fd17a8c06ecba0d14a99ad1393d to your computer and use it in GitHub Desktop.
Network Status Monitor (Convert colour indications in image to percentages) for www.elisaip.net/utilization.shtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Analyze the .png file | |
function NetworkUtilization($x, $y) { | |
$imageFile = file_get_contents("http://www.elisaip.net/pics/intbone.png"); | |
$image = imagecreatefromstring($imageFile); | |
$rgb = imagecolorat($image,$x,$y); | |
$r = ($rgb >> 16) & 0xFF; | |
$g = ($rgb >> 8) & 0xFF; | |
$b = $rgb & 0xFF; | |
$color = $r.$g.$b; | |
if($color == "0" . "0". "0") { | |
$linkstate = "Link state:DOWN"; | |
} else { | |
$linkstate = "Link state:UP"; | |
} | |
if($color == "50" . "255" . "50") { | |
$util = "30%"; | |
} elseif($color == "0" . "255". "0") { | |
$util = "20%"; | |
} elseif($color == "100" . "255". "100") { | |
$util = "10%"; | |
} elseif($color == "50" . "180". "50") { | |
$util = "40%"; | |
} elseif($color == "100" . "150". "0") { | |
$util = "50%"; | |
} elseif($color == "255" . "255". "102") { | |
$util = "60%"; | |
} elseif($color == "255" . "204". "102") { | |
$util = "70%"; | |
} elseif($color == "255" . "153". "51") { | |
$util = "80%"; | |
} elseif($color == "255" . "101". "51") { | |
$util = "90%"; | |
} elseif($color == "255" . "0". "0") { | |
$util = "100%"; | |
} else { | |
$util = "0%"; | |
} | |
$status = $linkstate."\nLink utilization:".$util; | |
return $status; | |
} | |
//Link, Helsinki2 -> Tallinn1 | |
$helsinki2totallinn1 = NetworkUtilization(405, 286); | |
print "<p>Helsinki2 to Tallinn1/".$helsinki2totallinn1."</p>"; | |
//Link, Helsinki2 -> Frankfurt1 | |
$helsinki2tofrankfurt1 = NetworkUtilization(329, 240); | |
print "<p>Helsinki2 to Frankfurt1/".$helsinki2tofrankfurt1."</p>"; | |
//Link, Helsinki2 -> Stockholm4 | |
$helsinki2tostockholm4 = NetworkUtilization(345, 162); | |
print "<p>Helsinki2 to Stockholm4/".$helsinki2tostockholm4."</p>"; | |
//Link, Helsinki2 -> Domestic | |
$helsinki2todomestic = NetworkUtilization(413, 229); | |
print "<p>Helsinki2 to AS719 (Finnish domestic network)/".$helsinki2todomestic."</p>"; | |
//Link, Helsinki2 -> St. Petersburg | |
$helsinki2toleningrad = NetworkUtilization(369, 346); | |
print "<p>Helsinki2 to St. Petersburg/".$helsinki2toleningrad."</p>"; | |
//Link, Helsinki2 <- Frankfurt1 | |
$frankfurt1tohelsinki2 = NetworkUtilization(325, 273); | |
print "<p>Frankfurt1 to Helsinki2/".$frankfurt1tohelsinki2."</p>"; | |
//Link, Helsinki2 <- Tallinn1 | |
$tallinn1tohelsinki2 = NetworkUtilization(406, 338); | |
print "<p>Tallinn1 to Helsinki2/".$tallinn1tohelsinki2."</p>"; | |
//Link, Helsinki2 <- Stockholm4 | |
$stockholm4tohelsinki2 = NetworkUtilization(343, 119); | |
print "<p>Stockholm4 to Helsinki2/".$stockholm4tohelsinki2."</p>"; | |
//Link, Helsinki2 <- Domestic | |
$domestictohelsinki2 = NetworkUtilization(420, 266); | |
print "<p>AS719 (Finnish domestic network) to Helsinki2/".$domestictohelsinki2."</p>"; | |
//Link, Helsinki2 <- St. Petersburg | |
$leningradtohelsinki2 = NetworkUtilization(370, 386); | |
print "<p>St.Petersburg to Helsinki2/".$leningradtohelsinki2."</p>"; | |
//Link, Espoo1 -> Amsterdam1 | |
$espoo1toamsterdam1 = NetworkUtilization(402, 138); | |
print "<p>Espoo1 to Amsterdam1/".$espoo1toamsterdam1."</p>"; | |
//Link, Espoo1 -> Stockholm1 | |
$espoo1tostockholm1 = NetworkUtilization(464, 100); | |
print "<p>Espoo1 to Stockholm1/".$espoo1tostockholm1."</p>"; | |
//Link, Espoo1 -> Domestic | |
$espoo1todomestic = NetworkUtilization(513, 176); | |
print "<p>Espoo1 to AS719 (Finnish domestic network)/".$espoo1todomestic."</p>"; | |
//Link, Espoo1 -> Tallinn2 | |
$espoo1totallinn2 = NetworkUtilization(535, 225); | |
print "<p>Espoo1 to Tallinn2/".$espoo1totallinn2."</p>"; | |
//Link, Espoo1 <- Amsterdam1 | |
$amsterdam1toespoo1 = NetworkUtilization(187, 152); | |
print "<p>Amsterdam1 to Espoo1/".$amsterdam1toespoo1."</p>"; | |
//Link, Espoo1 <- Stockholm1 | |
$stockholm1toespoo1 = NetworkUtilization(376, 55); | |
print "<p>Stockholm1 to Espoo1/".$stockholm1toespoo1."</p>"; | |
//Link, Espoo1 <- Domestic | |
$domestictoespoo1 = NetworkUtilization(510, 242); | |
print "<p>AS719(Finnish domestic network) to Espoo1/".$domestictoespoo1."</p>"; | |
//Link, Espoo1 <- Tallinn2 | |
$tallinn2toespoo1 = NetworkUtilization(534, 305); | |
print "<p>Tallinn2 to Espoo1/".$tallinn2toespoo1."</p>"; | |
//Link, Stockholm1 -> Amsterdam1 | |
$stockholm1toamsterdam1 = NetworkUtilization(244, 50); | |
print "<p>Stockholm1 to Amsterdam1/".$stockholm1toamsterdam1."</p>"; | |
//Link, Stockholm1 -> Stockholm4 | |
$stockholm1tostockholm4 = NetworkUtilization(285, 43); | |
print "<p>Stockholm1 to Stockholm4/".$stockholm1tostockholm4."</p>"; | |
//Link, Stockholm1 <- Amsterdam1 | |
$amsterdam1tostockholm1 = NetworkUtilization(196, 106); | |
print "<p>Amsterdam1 to Stockholm1/".$amsterdam1tostockholm1."</p>"; | |
//Link, Stockholm1 <- Stockholm4 | |
$stockholm4tostockholm1 = NetworkUtilization(314, 62); | |
print "<p>Stockholm4 to Stockholm1/".$stockholm4tostockholm1."</p>"; | |
//Link, Amsterdam2 -> Amsterdam1 | |
$amsterdam2toamsterdam1 = NetworkUtilization(101, 221); | |
print "<p>Amsterdam2 to Amsterdam1/".$amsterdam2toamsterdam1."</p>"; | |
//Link, Amsterdam1 -> Amsterdam2 | |
$amsterdam1toamsterdam2 = NetworkUtilization(102, 202); | |
print "<p>Amsterdam1 to Amsterdam2/".$amsterdam1toamsterdam2."</p>"; | |
//Link, London -> Amsterdam2 | |
$londontoamsterdam2 = NetworkUtilization(77, 316); | |
print "<p>London to Amsterdam2/".$londontoamsterdam2."</p>"; | |
//Link, London <- Amsterdam2 | |
$amsterdam2tolondon = NetworkUtilization(77, 298); | |
print "<p>Amsterdam2 to London/".$amsterdam2tolondon."</p>"; | |
//Link, London -> Frankfurt1 | |
$londontofrankfurt1 = NetworkUtilization(144, 324); | |
print "<p>London to Frankfurt1/".$londontofrankfurt1."</p>"; | |
//Link, London <- Frankfurt1 | |
$frankfurt1tolondon = NetworkUtilization(167, 321); | |
print "<p>Frankfurt1 to London/".$frankfurt1tolondon."</p>"; | |
//Link, Frankfurt2 -> Frankfurt1 | |
$frankfurt2tofrankfurt1 = NetworkUtilization(202, 369); | |
print "<p>Frankfurt2 to Frankfurt1/".$frankfurt2tofrankfurt1."</p>"; | |
//Link, Frankfurt1 -> Frankfurt2 | |
$frankfurt1tofrankfurt2 = NetworkUtilization(219, 341); | |
print "<p>Frankfurt1 to Frankfurt2/".$frankfurt1tofrankfurt2."</p>"; | |
//Link, Frankfurt1 -> Amsterdam1 | |
$frankfurt1toamsterdam1 = NetworkUtilization(208, 240); | |
print "<p>Frankfurt1 to Amsterdam1/".$frankfurt1toamsterdam1."</p>"; | |
//Link, Frankfurt1 <- Amsterdam1 | |
$amsterdam1tofrankfurt1 = NetworkUtilization(193, 218); | |
print "<p>Amsterdam1 to Frankfurt1/".$amsterdam1tofrankfurt1."</p>"; | |
//Link, Frankfurt2 -> Tallinn1 | |
$frankfurt2totallinn1 = NetworkUtilization(277, 404); | |
print "<p>Frankfurt2 to Tallinn1/".$frankfurt2totallinn1."</p>"; | |
//Link Tallinn1 -> Frankfurt2 | |
$tallinn1tofrankfurt2 = NetworkUtilization(306, 403); | |
print "<p>Tallinn1 to Frankfurt2/".$tallinn1tofrankfurt2."</p>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment