Ask a question

1802 questions

2189 answers

2855 comments

1464 members

Ask a question
0 votes
348 views
asked in Networking by

Hi,

I would like to get some logs from the event log from json-rpc, I'm able to get the full log with

eventslog -p -t EVENTS

my problem is I only want some part of it, i.e: SMS (to check an SMS as been sent), so in my logs, I've the line

24|1544016560|SMS|SMS was sent to +XXXXXXXXXX

from the help of eventslog, I see

  -t, --table                   <table> tables (CONNECTIONS, EVENTS, ALL)
  -q, --query                   <query>
...
  -n, --type                    <type> event type
  -e, --text                    <text> event text

So, I expect something like

eventslog -p -t EVENTS -q -n SMS

or

eventslog -p -t EVENTS -q NAME=SMS

could do it, but nothing is output, how this command is working ?

PS: if there is a better way to do that with json-rpc, tell it, please.

1 Answer

0 votes
answered by

Hi, Nicolas,

Try to use this command.

eventslog -p -t EVENTS | grep "|SMS|"

commented by

Hello,

Thx for your answer but it does not seems to work the way I expected.

By doing the json-rpc call without the grep, I have no result (or, to be precise, I've a result, but not the output from the command):

{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "32db4317b6559122de0a43bd9b082958", "file", "exec", { "command":  "eventslog", "params": ["-p", "-t", "EVENTS"] } ] }

This gives me :

{
"jsonrpc": "2.0",
"id": 1,
"result": [
  0,
  {
   "code": 0
  }
]
}

And, even if this was working, I wonder how to pass the second command ("pipe" and grep)

{ "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "c3c0f060994fc8307897e154d81048c9", "file", "exec", { "command":  "eventslog", "params": ["-p", "-t", "EVENTS", "|", "grep", "|SMS|"] } ] }

This gives me the same:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        0,
        {
            "code": 0
        }
    ]
}

Thx a lot

commented by

Hello,

You can use this command to filter eventslog:

eventslog -p -t EVENTS -d 1 -q " WHERE NAME = 'SMS'"

But we found an issue  wth JSON and RND team is working to fix.

commented by

Hi,

should this JSON-RPC issue be fixed in latest firmware (06.02)?

I'm not getting output from eventslog either (other than the help/usage print).

Unless I direct the eventslog output to a file and then use another RPC to read that file. But if I don't limit the number of lines to e.g. 10, I don't get output again.

And I can't get the query string working over JSON-RPC. How should the request parameters be formed, given that there are double quote chars and spaces in the query string? I've tried e.g.

            "params":

            [

                "-p","-t","EVENTS","-l","10","-f","/tmp/koe","-q","\"WHERE","ID=5697\""

            ]

and

            "params":

            [

                "-p","-t","EVENTS","-l","10","-f","/tmp/koe","-q","\"WHERE ID=5697\""

            ]

but neither form works, an empty file is created. From CLI this creates a file of one line.
commented by

Ok, after trial and error, I came up with this request pair (reading SMS events in the example).

The single quotes must be escaped with \u0027 and double quotes NOT escaped, the whole db query string must be in single parameter.

It's dirty but it works. I found no way to get the output directly from stdout by a single request.

[ { "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "f0b75a3b2d1425d7e3f09824ddd5ae3f", "file", "exec", { "command":"eventslog", "params": [ "-p","-t","EVENTS","-f","/tmp/koe","-q","WHERE NAME=\u0027SMS\u0027" ] } ] } , { "jsonrpc": "2.0", "id": 1, "method": "call", "params": [ "f0b75a3b2d1425d7e3f09824ddd5ae3f", "file", "read", { "path":"/tmp/koe" } ] } ]