How to call a method of ksh file(shell script) from a conf file(logstash file)


(Prashansa Rani) #1

How to call a method of external ksh file(shell script) from a conf file(logstash file).

Shell script (ksh file)
a.ksh

Test()
{
x ="$1"
if (x > 10 )
return x;
}

Logstash Script (conf file)
acon.conf

I want to call Test method ( i.e. Test )of above a.ksh file from filter block(of ruby code) of acon.conf conf file


(Magnus Bäck) #2

This is a shell script question and not a Logstash question.

You can't invoke shell script functions directly from the outside. You'd have to write a.ksh in such a way that running ./a.ksh or ksh a.ksh (possibly with arguments) invokes the Test function.


(Prashansa Rani) #3

I am using ruby code in logstash file.
How to execute shell command from logstash file(conf file ) inside the filter block of ruby code.


(Magnus Bäck) #4

Ruby code executing from a ruby filter is just ordinary Ruby code, it's just that it also has access to the Logstash event currently being processed. There must be a million examples out there of how to run a program from Ruby code.

If you explain what your end goal is we might be able to suggest something that doesn't involve running a shell interpreter for each message (since doing so can improve the event processing rate quite dramatically).


(Prashansa Rani) #5

*** List item**

How to call a method of external ksh file(shell script) from filter block(of ruby code) of conf file(logstash file).

We need to pass an argument (i.e: count) from logstash file (This count variable will be used in Test( ) function ), to ksh file(shell script)'s function (i.e: Test () ).

After it, Test( ) function will return a value that value will be used in logstash file(conf file).

  1. Shell script (ksh file)

Test()
{
x ="$1"
y=100
if (x > 10 )
return y;
}

  1. Logstash Script (conf file)

Test 25


(Magnus Bäck) #6

That's not an end goal. You're repeating your description of the means to reach your goal.


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.