I downloaded the nox from git repository. Both in "git://noxrepo.org/nox" and "git://noxrepo.org/noxcore" there is the same file "monitor.py" in "src/scripts/" directory.

Thank Reid for helping! And I'll try webservice, too.

Wen-Pei


Reid Price wrote:
PS: Looks like something took a few liberties with spacing when I copied the example function. You should obviously ignore the indent after the one-line if.

  -Reid

On Jul 3, 2010, at 0:59, Reid Price <r...@nicira.com <mailto:r...@nicira.com>> wrote:

Hi Wen-Pei,

I haven't seen this in a while, it is certainly somewhat legacy. What version of nox are you using? This was intended to create a quick-and-dirty monitor page for the number of flows, but you should be able to modify to whatever purpose you want - I found webservice calls to be easily adaptable. Looking at it now, the main abstractions this script is missing is one or two functions: something to get a dictionary mapping data source names to int/float values (for harvest) and perhaps an additional one to get the names as a list (for extrapolate_sources). It is somewhat clumsily combined into a single reap function and two blocks of code to parse that output.

The oldest version of that script I could find was customized for a specific format of dpctl dump-tables, where the data looked like:
id: 2 name: linear   n_flows:     12 max_flows:    100
table 0: name hash2   , max 131072, active     14, matched      0
table 1: name linear  , max    100, active      0, matched      0

This has changed dramatically, as you mentioned. Using Open vSwitch's version of this command (ovs-ofctl dump-tables) shows me something like this:
Jul 03 00:04:06|00001|ofctl|INFO|connecting to unix:<bridge>
stats_reply (xid=0xe103ac66): flags=none type=3(table)
 2 tables
  0: hash    : wild=0x00000, max=1048576, active=0
               lookup=43921298, matched=43773778
  1: classifier: wild=0x3fffff, max= 65536, active=10
               lookup=0, matched=0

In practice, replacing the middle section of the harvest function with anything that would parse that into "info = {'hash': 0, 'classifier': 10}" would be sufficient. A regex is probably the classiest way, but something ugly is a little quicker to see if the rest is working - for example, this would likely suffice for the above:
for line in table:
    if 'active' not in line:  continue
        name = line.split(':')[1].strip()
        active = int(line.split('=')[-1])
        info[name] = active
You would also have to make a modification to the extrapolate_sources function such that the end result was "sources = ['hash', 'classifier']" (in this case) - a simpler version of the parsing above (appending the name to a list) would do the trick.

  -Reid

On Fri, Jul 2, 2010 at 11:39 PM, Wen-Pei <wen...@networklab.csie.ncu.edu.tw <mailto:wen...@networklab.csie.ncu.edu.tw>> wrote:
> Hi, all:
>
> I found monitor.py in nox/src/scripts/ (not in src/noxcoreapps/examples/
> ) . And I guessed that it can generate a rrd graph. But it can't work
> with many problems. It seems that there are many modifications in the
> output of "dpctl dump-tables nl:0" that cause this script didn't work
> correctly. Is this script just a legacy? How to fix it and generate some
> graph? Or is there any script or tool have the same function and could
> replace this script?
>
> I tried to fix bugs but failed bucuse of unfamiliar with rrdtool...
>
> Thanks for replying.
>
> Wen-Pei


_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

Reply via email to