I am new to bro and I am writing a plugin. How does one go about adding counters.
In my c++ code, I want to add counters, for things like number connections, bytes rcvd/sent,
protocol parsing errors etc. I want to access them on demand i.e. this is mainly for debugging.
I don’t want to write disk. I couldn’t find any examples that do this and my google search didn’t
yield any satisfactory answers either. Would appreciate it if someone can point me the correct
direction on how to do this in bro. Thanks.


Most of the things you mentioned are already available to scriptland from the C++ core. A little Bro script can accomplish what you are asking. For example, declare a global variable and increment it inside a new_connection event, then periodically print to screen.