This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Trend log of the bus traffic
#1
Hi

Is there a way to get the bus traffic value and write this to an object and then have a trend on it?

I would like to have this to be able to monitor the bus traffic for longer period of time than the log already existing.
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#2
knxlib.getstats()
------------------------------
Ctrl+F5
Reply
#3
(30.03.2020, 14:15)Daniel. Wrote: knxlib.getstats()

OK, so I got this working. I made a small resident script that tracks the busload and then writes the value to a group address. Then one can add a trend for the busload and see the bus load in % over time.

As the getstats() is not giving the load as a percentage, but rather the number of telegrams in total, I have added a paramter for the number of telegrams pr second. This is of course not an exact value, as the length of the telegrams will vary. Normally, an average telegram time is 25ms, so that should give a theoretical max of 40/s.I have used a lower value in my script.

The getstats() is also only updated every minute, so the values we get from it is only to be seen as an indication of the bus load. The trend will be able to give you a hint that there might be too high bus load, and then you will have to do a more detailed analyze of this in another tool.

As the values are somewhat uncertain when it comes to actual bus load I have not seen the value in creating seperate GA for send, receive and repeats. I have only added them all together. If one want to split it, it should be fairly easy to modify the script accordingly.

Anyways.. the code is as follows:

Code:
maxS = 30  --Highest accepted telegram rate pr second
GAtraffic = '32/1/3'  --Must be set to desired GA

-------------------------------------------------------------------------
--No changes below the line
maxM = maxS*60
stats = knxlib.getstats()

sent = stats.tptx
received = stats.tprx
repeats = stats.repeats

traffic = sent + received + repeats
prev = storage.get('Previous', 0)


if prev ~= 0 then
  bLoad = ((traffic - prev)*100)/ maxM
  if bLoad > 0 then
    grp.write(GAtraffic, bLoad)
    log(prev, traffic, bLoad)
  end
end

storage.set('Previous', traffic)
There are 10 kinds of people in the world; those who can read binary and those who don't  Cool
Reply
#4
Hi.

I found that error appear from this script after rebooting of LM:

Resident script:9: attempt to index global 'stats' (a nil value)
stack traceback:

What it could be? I think I can start this script not automatically but from init with delay, but may be other better solution?

BR,

Alex
Reply
#5
Stats are not available when system starts, add this to remove the error:
Code:
stats = knxlib.getstats()
if not stats then
  return
end

There's no point in running this script very often as trends values are updated once a minute. Use a scheduled script that runs every minute.
Reply
#6
admin,

thank you for correcting mistakes and improving scripts!!
Reply
#7
Hello admin,

I have tried this script and compared the loged value with the KNX Stats in the system page but it seems that the calculated value by the script is around half of the value is displayed in the KNX stats.

For the virtual object a datatype 1byte scale is used. Is this normal?

Is there a better way to calculate the knx bus load in percentage?

Thank you in advance for you reply.
Reply
#8
In KNX stats the maximum is set to 15 telegrams per second instead of 30 as in the example above. Repeats should not be counted as they are included in the received telegram count.
Reply
#9
Hello admin,

Thanks for the quick help.

After adjusting the parameters the values are the same.

Smile Smile Smile
Reply


Forum Jump: