Python 如何导出RYU统计数据

Python 如何导出RYU统计数据,python,ryu,Python,Ryu,有了RYU控制器,我如何将所有统计数据(在整个监控时间内)作为时间序列统计数据导出到csv文件中,例如使用应用程序?我通过在\u port\u stats\u reply\u处理程序中创建一个新文件来导出统计数据功能: file = open('stats.csv', 'a') 然后在循环中我添加了: for stat in sorted(body, key=attrgetter('port_no')): file.write("\n{},{},{},{},{

有了RYU控制器,我如何将所有统计数据(在整个监控时间内)作为时间序列统计数据导出到csv文件中,例如使用应用程序?

我通过在
\u port\u stats\u reply\u处理程序中创建一个新文件来导出统计数据
功能:

file = open('stats.csv', 'a')
然后在循环中我添加了:

for stat in sorted(body, key=attrgetter('port_no')):
            file.write("\n{},{},{},{},{},{}"
            .format(ev.msg.datapath.id,
            stat.port_no, stat.rx_packets, stat.rx_dropped,
            stat.tx_packets, stat.tx_dropped))