rendered paste body#!/usr/local/bin/php -q
<?
require("/usr/home/asr/dbi.class.php");
$cfg_db = array(
"type" => "mysql",
"host" => "127.0.0.1",
"port" => "3306",
"name" => "netconfig",
"user" => "blah",
"pass" => "blah"
);
$db = new DBI;
$db->init($cfg_db);
printf("\n");
# spit out nyiix sessions w/o auth
#$sql = "SELECT * FROM bgpPeerSessions WHERE ix = 'nyiix' and md5enabled IS NULL or md5enabled != '1' ORDER BY peerIP";
#$sql = "SELECT * FROM bgpCustomerSessions, uberClientCache WHERE (bgpCustomerSessions.UberID = uberClientCache.UberID) ORDER BY voxRouter";
$sql = "SELECT * FROM bgpPeerSessions, peerParticipants WHERE (bgpPeerSessions.peerAS = peerParticipants.asn) and ix = 'nyiix' and md5enabled IS NULL or md5enabled != '1' ORDER BY peerIP";
$devices = $db->fetch_all($sql, "array");
for($i=0;$i<sizeof($devices);$i++) {
# if ($devices[$i]['status'] != 'active')
# continue;
print "neighbor {$devices[$i]['peerIP']} remote-as {$devices[$i]['peerAS']}\n";
print "neighbor {$devices[$i]['peerIP']} maximum-prefix {$devices[$i]['maxpre']}\n";
print "neighbor {$devices[$i]['peerIP']} peer-group peer-{$devices[$i]['ix']}\n";
print "neighbor {$devices[$i]['peerIP']} description \"PEER: ({$devices[$i]['name']}) [AS:{$devices[$i]['peerAS']}][IX:{$devices[$i]['ix']}]\" \n";
print "!\n";
}