<div dir="ltr"><div><span style="color:rgb(0,0,0);font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Looking to get usrloc stats in pure json format. </span><br></div><div><span style="color:rgb(0,0,0);font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div>When trying to run from the example above:<div><br></div><div> kamctl rpc stats.fetch shmem:<br></div><div><br></div><div>I get a message of <font color="#000000"><span style="font-size:12.8px">Method Not Found</span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><br></div><div><font color="#000000"><span style="font-size:12.8px"><span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Was this command not released, or is there another way to do this?</span><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">Thanks</span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 21, 2017 at 10:53 AM, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
jsonrcps is the module required by kamctl starting with version 5.0<br>
(being the module renamed from jsonrpc-s).<br>
<br>
Then, back to the main topic here -- the output for 'kamctl stats' was<br>
inherited from old times when MI (with no standard format in its output)<br>
was used to interact with kamailio and it was like a printed string in<br>
the form of "<a href="http://group.name" rel="noreferrer" target="_blank">group.name</a> = value" for each of the available statistics.<br>
<br>
As I also wanted for quite long time to get a more json friendly output<br>
for stats, this discussion brought it back in my attention and I just<br>
added the rpc command stats.fetch. This one returns a json structure<br>
like in next example for getting shared memory stats:<br>
<br>
# kamctl rpc stats.fetch shmem:<br>
{<br>
  "jsonrpc":  "2.0",<br>
  "result": {<br>
    "shmem.fragments":  "1",<br>
    "shmem.free_size":  "64288976",<br>
    "shmem.max_used_size":  "2819888",<br>
    "shmem.real_used_size": "2819888",<br>
    "shmem.total_size": "67108864",<br>
    "shmem.used_size":  "2578288"<br>
  },<br>
  "id": 44590<br>
}<br>
<br>
I left the value as string in order to accommodate large numbers (as the<br>
rpc interface works usually with integers), but if people finds it<br>
inconvenient, I can look at seeing if large numbers are actually needed<br>
here.<br>
<br>
Cheers,<br>
Daniel<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On 20.09.17 19:34, Noah Mehl wrote:<br>
> Alex,<br>
><br>
> We are using this for time series monitoring (e.g. Zabbix).  It doesn’t make sense, at least to me, to implement jsonrpc-s just to get the kamctl stats output.  I mean, currently I’m just chaining the output with cut and tr, and that’s fine.  I just suggest utilizing JSON a bit better here.<br>
><br>
> Thanks!<br>
><br>
> ~Noah<br>
><br>
>> On Sep 20, 2017, at 1:17 PM, Alex Balashov <<a href="mailto:abalashov@evaristesys.com">abalashov@evaristesys.com</a>> wrote:<br>
>><br>
>> You may want to consider an alternate and more streamlined method of pulling these. <br>
>><br>
>> On September 20, 2017 1:16:49 PM EDT, Noah Mehl <<a href="mailto:noahmehl@gmail.com">noahmehl@gmail.com</a>> wrote:<br>
>>> Alex,<br>
>>><br>
>>> This is how that output was generated:<br>
>>><br>
>>> # kamctl stats shmem | jq .<br>
>>><br>
>>> Thanks!<br>
>>><br>
>>> ~Noah<br>
>>><br>
>>>> On Sep 20, 2017, at 1:14 PM, Alex Balashov<br>
>>> <<a href="mailto:abalashov@evaristesys.com">abalashov@evaristesys.com</a>> wrote:<br>
>>>> Hello,<br>
>>>><br>
>>>> The jsonrpc-s module has a pretty_print option. Or is that not where<br>
>>> you're dispatching this JSON output from?<br>
>>>><br>
>>>> -- Alex<br>
>>>><br>
>>>> --<br>
>>>> Sent via mobile, please forgive typos and brevity. <br>
>>>><br>
>>>> ______________________________<wbr>_________________<br>
>>>> Kamailio (SER) - Users Mailing List<br>
>>>> <a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
>>>> <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
>>><br>
>>> ______________________________<wbr>_________________<br>
>>> Kamailio (SER) - Users Mailing List<br>
>>> <a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
>>> <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
>><br>
>> -- Alex<br>
>><br>
>> --<br>
>> Sent via mobile, please forgive typos and brevity. <br>
>><br>
>> ______________________________<wbr>_________________<br>
>> Kamailio (SER) - Users Mailing List<br>
>> <a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
>> <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
><br>
> ______________________________<wbr>_________________<br>
> Kamailio (SER) - Users Mailing List<br>
> <a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
> <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">-- <br>
Daniel-Constantin Mierla<br>
<a href="http://www.twitter.com/miconda" rel="noreferrer" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" rel="noreferrer" target="_blank">www.linkedin.com/in/miconda</a><br>
Kamailio Advanced Training - <a href="http://www.asipto.com" rel="noreferrer" target="_blank">www.asipto.com</a><br>
Kamailio World Conference - <a href="http://www.kamailioworld.com" rel="noreferrer" target="_blank">www.kamailioworld.com</a><br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
</div></div></blockquote></div><br></div>