RUTX50 - How to get monthly data usage via jsonrpc?

how to get via jsonrpc this?


I tried commands:

{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"$session\", \"file\", \"exec\", { \"command\":\"gsmctl\", \"params\": [\"-r\", \"wwan0\"] } ] }
{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"$session\", \"file\", \"exec\", { \"command\":\"gsmctl\", \"params\": [\"-e\", \"wwan0\"] } ] }

…but it returns me only for the active connection, not for this month.

I also tried it for the mob1s1a1 interface, but it returned an error:

gsmctl -r mob1s1a1
gsmctl -e mob1s1a1


Thanks :slight_smile:


You can use ubus commands to get bytes sent/received on the mobile interface:

ubus call mdcollect get '{"period":"month","interface":"mob1s1a1", "sim":1}'
ubus call mdcollect get '{"period":"day","interface":"mob1s1a1", "sim":1}'

Or you can get total:

ubus call mdcollect get_raw_total '{"interface":"mob1s1a1", "sim":1}'

You can then use an online calculator like the one here to convert to MB (in binary).

You can see the format and other mdcollect calls via:

ubus -v list mdcollect

Kind Regards,

Thank you,
works great over SSH.

How to format this into CURL jsonrpc and have it work?

I tried the example:

{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"call\", \"params\": [\"$session\", \"file\", \"exec\", { \"command\":\"mdcollect\", \"params\": [\"get\",{\"period\":\"month\",\"interface\":\"mob1s1a1\", \"sim\":1}] } ] }

But CURL returns this:




  "jsonrpc": "2.0",
  "id": 1,
  "method": "call",
  "params": [
      "period": "month",
      "interface": "mob1s1a1",
      "sim": 1

Or with Curl:

curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "id": 1, "method": "call", "params": ["yourtoken", "mdcollect", "get", {"period": "month", "interface": "mob1s1a1", "sim": 1}]}'

Just replace yourtoken and the IP address.

Kind Regards,

Thank you very much, everything works :+1:

This topic was automatically closed after 15 days. New replies are no longer allowed.