I'm looking to run a script so I can post some passive check status to
nagios via send_nsca and found the d-fens ExecScript AlarmCallback plugin.
After building the jar file and placing it in
graylog-server/plugins/alarm_callback dir I can select the "d-fens SCRIPT
AlarmCallback" plugin.
The doc says that it supports java and python natively (shame it doesn't
allow just simple shell commands or supply perl engine as well which would
make my life easier).
With these settings however, I'm getting an error as follows -
- DF_SCRIPT_ENGINE: python
- DF_SCRIPT_CACHE_CONTENTS: true
- DF_SCRIPT_PATH_AND_NAME: /tmp/nagiosScript.py
- DF_DISPLAY_SCRIPT_OUTPUT:false
cat /tmp/nagiosScript.py
*#!/usr/bin/pythonimport osos.system("touch /tmp/abc")*
Error log -
2016-03-17T16:33:09.372-04:00 ERROR [dfchBizExecScript] *** d-fens SCRIPT
AlarmCallback::write() - Exception
2016-03-17T16:33:09.374-04:00 WARN [AlertScannerThread] Alarm callback
with id 56eb0d74e4b03d13f5b1d7c9 failed. Skipping.
org.graylog2.plugin.alarms.callbacks.AlarmCallbackConfigurationException:
python:
Unsupported script engine.
at
biz.dfch.j.graylog2.plugin.alarm.dfchBizExecScript.initialize(dfchBizExecScript.java:75)
at
org.graylog2.alarmcallbacks.AlarmCallbackFactory.create(AlarmCallbackFactory.java:43)
at
org.graylog2.periodical.AlertScannerThread.doRun(AlertScannerThread.java:112)
at org.graylog2.plugin.periodical.Periodical.run(Periodical.java:83)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Question - how can I get python to be a supported script engine? Or am I
stuck with javascript engine alone?
I'm not familiar with java. How would I call an external send_nsca script
from Java? I saw the blurb about RhinoShell but it did not work when I
tried it.
The test java program I used was -
"
*// prints the whole messageprint("AlarmCallback: Now this is a message: "
+ message + "\r\n");// printing the message sourceprint("AlarmCallback:
message.source: " + message.getSource() + "\r\n");// printing the message
sourceprint("AlarmCallback: message.timestamp: " + message.getTimestamp() +
"\r\n");// printing the stream titleprint("AlarmCallback: stream.title: " +
stream.getTitle() + "\r\n");// printing the description of the alarm
conditionprint("AlarmCallback: result.description: " +
result.getResultDescription() + "\r\n");// now you can invoke arbitrary
system commands via //
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino/Shell#runCommandrunCommand('date
> /tmp/abc');*
"
However, this fails with -
2016-03-18T10:45:09.374-04:00 ERROR [dfchBizExecScript] *** d-fens SCRIPT
AlarmCallback::write() - ScriptException
2016-03-18T10:45:09.377-04:00 WARN [AlertScannerThread] Alarm callback
<d-fens SCRIPT AlarmCallback> failed. Skipping.
org.graylog2.plugin.alarms.callbacks.AlarmCallbackException: *** d-fens
SCRIPT AlarmCallback::write() - ScriptException
at
biz.dfch.j.graylog2.plugin.alarm.dfchBizExecScript.call(dfchBizExecScript.java:232)
at
org.graylog2.periodical.AlertScannerThread.doRun(AlertScannerThread.java:113)
at org.graylog2.plugin.periodical.Periodical.run(Periodical.java:83)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.script.ScriptException: TypeError: null has no such
function "getSource" in <eval> at line number 13
at
jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
at
jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:150)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
at
biz.dfch.j.graylog2.plugin.alarm.dfchBizExecScript.call(dfchBizExecScript.java:213)
... 9 more
Caused by: <eval>:13 TypeError: null has no such function "getSource"
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
at
jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
at
jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
at
jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
at
jdk.nashorn.internal.runtime.linker.NashornBottomLinker.linkNull(NashornBottomLinker.java:175)
at
jdk.nashorn.internal.runtime.linker.NashornBottomLinker.getGuardedInvocation(NashornBottomLinker.java:64)
at
jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at
jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:13)
at
jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
at
jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228)
at
jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
at
jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)
... 14 more
Any help is much appreciated.
Thanks,
--
You received this message because you are subscribed to the Google Groups
"Graylog Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/graylog2/8bab069e-aedd-4a0d-b520-133a9366c41c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.