view doc/ucis.ano/bgp_graph/bgp_path_list_bird.php @ 1202:306a7562f05e draft

????????: abs <post@abslimit.info> ?? ????? master ???? ????? ????????? ? ???????????? ? ?origin/master?. ?????????, ??????? ????? ???????? ? ??????: ????? ????: db/as/49608/owner ????? ????: db/dom/ano/abslimit/owner ????? ????: db/dom/ano/netstalking/owner ????? ????: db/ip/15/0A/0B/00/cidr ????? ????: db/ip/15/0A/0B/00/owner ????? ????: db/usr/abslimit/git
author abs <abs@abslimit.info>
date Sun, 13 May 2018 14:57:04 +0300
parents d44b9afb4a25
children
line wrap: on
line source

#!/usr/bin/php
<?php
$mynode = array_key_exists('LOCALNODE',$_SERVER)?$_SERVER['LOCALNODE']:0;

$fds = NULL;
$proc = proc_open('birdc', array(0 => array('pipe','r'), 1 => array('pipe','w'), 2 => STDERR), $fds);
fwrite($fds[0], "show route all\n");
fclose($fds[0]);
$paths = array();

while (!feof($fds[1])) {
	$line = stream_get_line($fds[1], 1024, "\n");
	if ($line === NULL || $line === FALSE) break;
	if (!strlen($line) || $line[0] != "\t") continue;
	if (substr($line, 0, 14) != "\tBGP.as_path: ") continue;
	$path = substr($line, 14);
	if (in_array($path, $paths)) continue;
	$paths[] = $path;
	print($mynode.' '.$path."\n");
}