pythonryu

How to export RYU Stats


With RYU controller, how can I export all stats (throughout the monitoring time) into csv file as time series stats using e.g., simple_monitor application?


Solution

  • I managed to export the stats by creating a new file in the _port_stats_reply_handler function:

    file = open('stats.csv', 'a')
    

    Then in the loop I added:

    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))