florentchauveau / kamailio_exporter

Prometheus exporter for Kamailio SIP server
MIT License
58 stars 19 forks source link

Feature: add rpc methods with parameters #10

Open fnurglewitz opened 5 years ago

fnurglewitz commented 5 years ago

Hi, would it be possible to add rpc methods which need parameters?

Adding methods without parameters is quite easy but I'm not sure how I should proceed (I suppose some changes on the binrpc library are needed)

florentchauveau commented 5 years ago

Hello!

Could you give me an example of RPC method with parameters so I can make some tests?

Best

fnurglewitz commented 5 years ago

hello, here's an example:

mod.stats core shm

Thank you

vishal-yadav commented 5 years ago

Below case is in particular useful where you can scrape any specific (group) statistics listed in kamcmd stats. For example: kamcmd stats.get_statistics <statistics_name> kamcmd stats.get_statistics <group:>

florentchauveau commented 5 years ago

Hello guys,

The binrpc package can already handle this, command args need to be appended to the WritePacket function.

Like this:

cookie, err := binrpc.WritePacket(conn, "stats.fetch", "current_opened_connections")

Implementing this in the exporter would be trivial, we could split a command by " "(space) in the fetchBINRPC function.

However, it would be interesting to have a more dynamic list of commands I think. Or maybe we just need to implement stats.fetch all that is available since Kamailio 5.X.