当前位置: 首页>>代码示例>>Python>>正文


Python IPRoute.get方法代码示例

本文整理汇总了Python中pyroute2.IPRoute.get方法的典型用法代码示例。如果您正苦于以下问题:Python IPRoute.get方法的具体用法?Python IPRoute.get怎么用?Python IPRoute.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyroute2.IPRoute的用法示例。


在下文中一共展示了IPRoute.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mroute

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import get [as 别名]
def mroute():
    ip = IPRoute() # family = NETLINK_ROUTE "Receives routing and link
    # updates and may be used to modify the routing tables"
    ip.monitor()

    while True:
        for raw in ip.get():
            print '{event:10} {attrs}'.format(**raw)
开发者ID:shavenwarthog,项目名称:johntellsall,代码行数:10,代码来源:umon.py

示例2: main_loop

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import get [as 别名]
class main_loop():
    def __init__(self,group=RTMGRP_LINK |RTMGRP_IPV4_IFADDR,family= NETLINK_ROUTE,log=False):
        IPRoute.groups = RTMGRP_LINK |RTMGRP_IPV4_IFADDR
        IPRoute.groups = RTMGRP_LINK
        IPRoute.family = family
        self.ip = IPRoute()

        self.counter = 0
        self.log = log

    def monitor(self):
        self.ip.monitor()
        
        while True :
            self.buf = self.ip.get()
            self.parse_buf(self.buf[0])
            print self.buf
开发者ID:godvmxi,项目名称:demos,代码行数:19,代码来源:netlink.py

示例3: len

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import get [as 别名]
#!/usr/bin/python
'''
Slightly more complicate example, than trace_ip_link.
'''
import sys
from pyroute2 import IPRoute
from Queue import Empty

if len(sys.argv) < 2:
    print('choose program to run, e.g.:')
    print('%s ip link show' % (sys.argv[0]))
    sys.exit(0)

ip = IPRoute(debug=True)
q = ip.connect('ptrace://%s' % ' '.join(sys.argv[1:]), no_stdout=True)
while True:
    try:
        for msg in ip.get(q, raw=True):
            print(msg)
    except Empty:
        break
开发者ID:bouttier,项目名称:pyroute2,代码行数:23,代码来源:nldump.py

示例4: IPRoute

# 需要导入模块: from pyroute2 import IPRoute [as 别名]
# 或者: from pyroute2.IPRoute import get [as 别名]
#!/usr/bin/python
'''
Launch external command 'ip link show' and analyze
netlink traffic, that it sends/receives. Just like
tcpdump, but for netlink protocol.
'''
import sys
from pyroute2 import IPRoute
from Queue import Empty
from pprint import pprint

ip = IPRoute()
q = ip.connect('ptrace://' + ' '.join(sys.argv[1:]))
while True:
    try:
        pprint(ip.get(q, raw=True))
    except Empty:
        break
开发者ID:bouttier,项目名称:pyroute2,代码行数:20,代码来源:trace_ip_link.py


注:本文中的pyroute2.IPRoute.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。