Network MAP PHP
Problem this snippet solves: Hi all,
Here is a PHP script to use if you want to present you network map to a NOC or to the Application Support & Maintenance Services.
This replicate Network Map...
Published Nov 16, 2016
Version 1.0renato_martins_
Nimbostratus
Joined May 05, 2019
renato_martins_
Nimbostratus
Joined May 05, 2019
jaikumar_f5
Feb 21, 2017MVP
I did make the changes mentioned above, couldn't make it working. Please advise whats wrong.
f5 monitoring page
";
// funtion to display images. you can download them for F5 web interface. Place them into ./images folder
function getgif($status) {
$img_path = "/images";
switch($status) {
case 'up':
$img = $img_path."/status_circle_green.png";
break;
case 'down':
$img = $img_path."/status_diamond_red.png";
break;
case 'user-down':
$img = $img_path."/status_diamond_black.png";
break;
case 'unchecked';
$img = $img_path."/status_square_blue.png";
break;
default:
$img = $img_path."/status_circle_outline.gif";
}
return $img;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://$user:$password@$f5server/mgmt/tm/ltm/pool/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$pools = json_decode(curl_exec($ch));
curl_setopt($ch, CURLOPT_URL, "https://$user:$password@$f5server/mgmt/tm/ltm/virtual/");
$vservers = json_decode(curl_exec($ch));
curl_setopt($ch, CURLOPT_URL, "https://$user:$password@$f5server/mgmt/tm/ltm/node/");
$nodes = json_decode(curl_exec($ch));
curl_close($ch);
//NETWORK MAP presentation
echo "
VIRTUAL SERVERS
";
foreach ($vservers->{'items'} as $vs){
echo strtolower($vs->{'name'});
echo " ".$vs->{'destination'};
if ($vs->{'rules'}[1] != NULL){
echo "
";
echo $vs->{'rules'}[1];
}
foreach ($pools->{'items'} as $item ){
if ($vs->{'pool'} == $item->{'fullPath'}){
echo "
";
$stateurl = $item->{'membersReference'};
echo " ";
echo strtolower($item->{'name'});
echo " - (".$item->{'loadBalancingMode'}.")";
echo "
";
$rewrited_url = str_replace('localhost',$user.":".$password."@".$f5server,$stateurl->{'link'});
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $rewrited_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$members = json_decode(curl_exec($ch));
curl_close($ch);
foreach ($members->{'items'} as $member)
{
$img_path = getgif($member->{'state'});
echo " ";
echo strtolower($member->{'name'});
echo " - (".$member->{'address'}.")";
foreach ($nodes->{'items'} as $node){
if ($member->{'address'} === $node->{'address'}){
$img_path = getgif($node->{'state'});
echo " ";
echo strtolower($node->{'name'});
}
}
echo "
";
}
}
}
echo "
";
}
?>