以bgp为路径,使用netjson生成交互式javascript图
aspath_graph的Python项目详细描述
aspath_graph将原始aspath转换为netjson图
NetJSON是一系列用于定义网络的json模式,NetJSON Graph 特定于定义节点如何互连。“aspath_graph”使用 这表示bgp自治系统为“节点”,以及它们如何连接 从输入的角度来看
这个项目旨在使从bgp作为原始形式的路径到 netjson图形可以理解的东西。这使得将属性添加到 基于其标签或ASN的节点,并在 css/js/html中的前端。
快速启动
要快速入门,请克隆repo并查看examples文件夹。它 有一个路径文本文件,说明我当时是如何看到1.0.0.0/12+的路径的。
对于您自己的数据,目前有两种输入方法:
- netconf到junos设备
- aspaths的纯文本文件
birdc 'show route table <name> all'|grep BGP\.as_path|egrep -o '[0-9]+ [0-9 ]+' > aspaths.txt
ssh junosrtr "show route protocol bgp | match \"AS path\""| sed -e 's/.*AS path: //g' > aspaths.txt
Nejjon图嵌入到现有页面和主题中非常简单,因此 正在获取你的as节点。我将向您介绍 主要项目,但下面是一个小例子。
<!DOCTYPE html><html><head><metacharset="utf-8"><linkhref="https://rawgit.com/interop-dev/netjsongraph.js/master/src/netjsongraph.css"rel="stylesheet"><linkhref="https://rawgit.com/interop-dev/netjsongraph.js/master/src/netjsongraph-theme.css"rel="stylesheet"></head><body><divid="wrap"><divclass="nav"><!-- Nav stuff... --></div><divclass="main-container"><!-- Imagine this your usual main container --><!-- You probably have several things down here... --><divid="legend"><!-- You can even add a legend, there's an example on the main project site --></div><divclass="bgp-ases"></div></div></div><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.12/d3.min.js"></script><scriptsrc="https://rawgit.com/interop-dev/netjsongraph.js/master/src/netjsongraph.js"></script><script>d3.netJsonGraph("example.json",{el:'.bgp-ases',metadata:false,charge:-250,labelDy:'-1.18em',});</script></body></html>
用法
$ aspath_graph --help Usage: aspath_graph [OPTIONS] INPUT Options: -v, --version Show the version and exit. -m, --mode [junos-netconf|txt] Mode to use -o, --output FILENAME Output file --asdot Whether to add ASDOT notation --ownas TEXT Apply perspective of own AS at the beginning of PATHS --runserver Run local server on 8000 --user TEXT Only used for relevant modes --nopassword If using a login mode, this will enable public key auth --yaml FILENAME YAML for mapping and ignoring ASes --pprint Pretty print JSON -h, --help Show this message and exit.
根据模式的值,输入可以是设备或文件。这个 默认为文件。(文本)
输出可以是“-”,以便将结果发送到stdout。
如果不通过“-nopassword”,系统将提示您输入 相关模式。
当使用“–asdot”提供asdot符号时,原始asplain也将 在节点上提供-就在“raw”属性下。
yaml可以这样格式化:(请注意,“ignore”只能是asplain)
label_map:65001:SFO65002:ORD65003:NYC65003.1:NYC-R165003.2:NYC-R2ignore:-7224-9059
默认情况下,asdot将根据上半部分进行标记。例如,如果65001 配置为标记为dfw时,65001.211将显示为dfw-r21。这个 假设您的TOR ASN是您的脊椎ASN+(机架号*10+1)-禁用 这只需将apg_asdot_raw设置为true/yes/anything。
任何支持的选项都可以通过env通过增加case来传递, 用'* '替换“--”,用“APG”进行前缀。例如,“APG U模式”