Page 1 of 2
Graph not generate. JMXEval plugin used by nrpe
Posted: Mon Apr 07, 2014 6:30 am
by edwardzg
Hello,
I have a problem with jmxeval ver.1.2.6. from
https://code.google.com/p/jmxeval/wiki/GettingStarted
I used this extension to checking how much memory actually used java. I get some output from windows host, Nagios server stands on CentOS 6.5. but loose part of data which Nagios need for graphs.
For example when I run “check_jmxeval.bat jmxeval_jb.xml” in windows host I get:
JMXEval MemHeap OK - heapMemoryUsedPercent is 30.5 | heapMemoryUsedPercent=30.5;92;95 time=0.0s
But when I run “check_nrpe -H WinHost -c check_jmxeval” from Nagios serwer by nrpe I get:
JMXEval MemHeap OK - heapMemoryUsedPercent is 30.9
…without this „| heapMemoryUsedPercent=30.5;92;95 time=0.0s”
In file nsclient.log I found something like this:
e:d:\source\nscp\trunk\modules\checkexternalscripts\commands.hpp:91: Failed to parse arguments for command 'check_jmxeval', using old split string method: unknown escape sequence: scripts\check_jmxeval.bat scripts\jmxeval_jb.xml
I found some ideas that adding allow arguments=true in [/settings/external scripts] can help with that but when I add this to nsclient.ini it doesn’t change anything with output. Only new info in .log file: ..\..\..\..\trunk\modules\CheckExternalScripts\CheckExternalScripts.cpp:229: Arguments: scripts\jmxeval_jb.xml
Anybody used this extension and have that kind of problem? Or any idea how to find solution because graphs can be realy useful
Regards,
Jan
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Mon Apr 07, 2014 2:59 pm
by sreinhardt
Could you post the nsc.ini\nsclient.ini file? Also could you run the command you are attempting to execute via nrpe, directly from a cmd process, and send us the output? (something like ./check_jmxeval.bat ./jmxeval_jb.xml )
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Tue Apr 08, 2014 4:01 am
by edwardzg
nsclient.ini:
Code: Select all
[/modules]
; CheckDisk - CheckDisk can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckDisk = 1
; Event log Checker. - Check for errors and warnings in the event log. This is only supported through NRPE so if you plan to use only NSClient this wont help you at all.
CheckEventLog = 1
; Check External Scripts - A simple wrapper to run external scripts and batch files.
CheckExternalScripts = 1
; Helper function - Various helper function to extend other checks. This is also only supported through NRPE.
CheckHelpers = 1
; Check NSCP - Checkes the state of the agent
CheckNSCP = 1
; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1
; CheckWMI - CheckWMI can check various file and disk related things. The current version has commands to check Size of hard drives and directories.
CheckWMI = 1
; NRPE server - A simple server that listens for incoming NRPE connection and handles them. NRPE is preferred over NSClient as it is more flexible. You can of cource use both NSClient and NRPE.
NRPEServer = 1
; NSCAClient - Passive check support (needs NSCA on nagios server). Avalible crypto are: {0=No Encryption (not safe), 1=XOR, 2=DES, 3=DES-EDE3, 4=CAST-128, 6=XTEA, 8=Blowfish, 9=Twofish, 11=RC2, 14=AES, 15=AES, 16=AES, 20=Serpent, 23=GOST}
NSCAClient = 1
; NSClient server - A simple server that listens for incoming NSClient (check_nt) connection and handles them. Although NRPE is the preferred method NSClient is fully supported and can be used for simplicity or for compatibility.
NSClientServer = 1
; Undocumented section
[/settings/default]
; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = ............
; Section for NRPE (NRPEListener.dll) (check_nrpe) protocol options.
[/settings/NRPE/server]
; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true
; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true
; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges. parent for this key is found under: /settings/default this is marked as advanced in favour of the parent.
#allowed hosts = ..........
; PORT NUMBER - Port to use for NRPE.
port = 5666
.
.
.
[/settings/external scripts]
#allow arguments=true
#allow nasty characters = true
; A list of aliases available. An alias is an internal command that has been "wrapped" (to add arguments). Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)
[/settings/external scripts/alias]
; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]
check_jmxeval = scripts\check_jmxeval.bat scripts\jmxeval_jb.xml
runcmd = "scripts\runcmd.bat"
; A list of wrappped scripts (ie. using the template mechanism)
[/settings/external scripts/wrapped scripts]
; A list of templates for wrapped scripts
[/settings/external scripts/wrappings]
Also could you run the command you are attempting to execute via nrpe, directly from a cmd process, and send us the output? (something like ./check_jmxeval.bat ./jmxeval_jb.xml )
If I understood you right I wrote about in previous post. When I run “check_jmxeval.bat jmxeval_jb.xml” directly in cmd on windows host I get:
JMXEval MemHeap OK - heapMemoryUsedPercent is 30.5 | heapMemoryUsedPercent=30.5;92;95 time=0.0s
Regards,
Jan
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Tue Apr 08, 2014 5:05 pm
by tmcdonald
You might need to modify the command in NRPE to evoke cmd with the /c parameter
http://nsclient.org/nscp/wiki/guides/na ... al_scripts
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Wed Apr 09, 2014 5:40 am
by edwardzg
Ok, I change external script from
Code: Select all
check_jmxeval = "scripts\\check_jmxeval.bat" "scripts\\jmxeval_jb.xml"
to
Code: Select all
check_jmxeval = cmd /c echo “scripts\\check_jmxeval.bat" "scripts\\jmxeval_jb.xml" ; exit($lastexitcode) | powershell.exe -command –
but I got the same output
Code: Select all
JMXEval MemHeap OK - heapMemoryUsedPercent is 21.24
Info from nsclient.log:
Code: Select all
..\..\..\..\trunk\modules\CheckExternalScripts\CheckExternalScripts.cpp:229: Arguments: /c echo scripts\check_jmxeval.bat scripts\jmxeval_jb.xml ; exit($lastexitcode) | powershell.exe -command –
What is interesting, when I add
to external script and run jmxeval by nrpe. In file log.txt I got right output
Code: Select all
JMXEval MemHeap OK - heapMemoryUsedPercent is 18.41 | heapMemoryUsedPercent=18.41;90;95 time=0.0s
The same output I got when I used this with the old version external script (without cmd /c echo)
With info from nsclient.log:
Code: Select all
..\..\..\..\trunk\modules\CheckExternalScripts\CheckExternalScripts.cpp:229: Arguments: scripts\jmxeval_jb.xml
Any idea?
P.S. Change scripts\check_jmxeval.bat to "scripts\\check_jmxeval.bat" is the solution for that: e:d:\source\nscp\trunk\modules\checkexternalscripts\commands.hpp:91: Failed to parse arguments for command 'check_jmxeval', using old split string method: unknown escape sequence: scripts\check_jmxeval.bat scripts\jmxeval_jb.xml
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Wed Apr 09, 2014 4:35 pm
by slansing
We might actually be going about this the wrong way, you mentioned you changed:
Code: Select all
check_jmxeval = "scripts\\check_jmxeval.bat" "scripts\\jmxeval_jb.xml"
Was that how you originally defined it? the quotes and double slashes may be causing problems try this one:
Code: Select all
check_jmxeval = scripts\check_jmxeval.bat
You may need to explicitly call the .xml file from within the plugin instead of passing it along side, that may be freaking nsclient out a bit. When check_jmxeval is called from the nagios server, what does it output? And what does the NSClient log output? Don't forget to restart nsclient when making these changes. The main problem here is, I think the plugin is working fine with the exception of missing performance data. In your original post, how you had it defined there, should be fine. We might need to target why exactly the perf data is not being wrapped up too... which should not have to do with passing the .xml file.
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Wed Apr 09, 2014 7:11 pm
by edwardzg
Adding quotes and double slashes removes that kind of info from nsclient.log:
Code: Select all
e:d:\source\nscp\trunk\modules\checkexternalscripts\commands.hpp:91: Failed to parse arguments for command 'check_jmxeval', using old split string method: unknown escape sequence: scripts\check_jmxeval.bat scripts\jmxeval_jb.xml
I don't see any differences about output data when I use
Code: Select all
check_jmxeval = scripts\check_jmxeval.bat scripts\jmxeval_jb.xml
or
Code: Select all
check_jmxeval = "scripts\\check_jmxeval.bat" "scripts\\jmxeval_jb.xml"
. Only that quotes and double slashes removes above info from nsclient.log
You may need to explicitly call the .xml file from within the plugin instead of passing it along side, that may be freaking nsclient out a bit.
Ok, any idea how to do it?
When check_jmxeval is called from the nagios server, what does it output? And what does the NSClient log output?
When I called from nagios server i see
Code: Select all
JMXEval MemHeap OK - heapMemoryUsedPercent is 18.41
NSClient log output
Code: Select all
..\..\..\..\trunk\modules\CheckExternalScripts\CheckExternalScripts.cpp:229: Arguments: scripts\jmxeval_jb.xml
Don't forget to restart nsclient when making these changes.
Yeah, I remember about it
I wrote in earlier post:
What is interesting, when I add
to external script like:
Code: Select all
check_jmxeval = scripts\check_jmxeval.bat scripts\jmxeval_jb.xml >> C:\log.txt
and run check_jmxeval by nrpe. In file log.txt I got right output
JMXEval MemHeap OK - heapMemoryUsedPercent is 18.41 | heapMemoryUsedPercent=18.41;90;95 time=0.0s
This is maybe some clue
It's litle complicated

Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Thu Apr 10, 2014 11:16 am
by sreinhardt
Could you post the check_jmxeval.bat please? I think its easiest to modify that batch file so that it no longer needs the additional xml file as an argument within the nsclient configuration.
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Fri Apr 11, 2014 9:57 am
by edwardzg
check_jmxeval.bat:
Code: Select all
@echo off
@if "%OS%" == "Windows_NT" setlocal
@pushd %~dp0
@set BASE_DIR=%cd%
@popd
set BASE_DIR=%BASE_DIR%\lib\jmxeval-1.2.6
set LIB_DIR=%BASE_DIR%\lib
call C:\jboss-as-7.1.1.Final\bin\jmx_setup.bat
set CLASSPATH=%CLASSPATH%;%BASE_DIR%\jmxeval-1.2.6.jar;%LIB_DIR%\args4j-2.0.16.jar
rem echo %CLASSPATH%
%JAVA_HOME%\bin\java -classpath "%CLASSPATH%" com.adahas.tools.jmxeval.App %*
and jmxeval_jb.xml:
Code: Select all
<?xml version="1.0"?>
<jmxeval:jmxeval xmlns:jmxeval="http://www.adahas.com/schema/jmxeval-1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
connect to Java process running on 'localhost' having JMX agent exposed on port '9010'
using username 'myUser' and password 'myPassword'
-->
<connection url="service:jmx:remoting-jmx://localhost:xxxx"
username="xxx" password="xxx">
<eval name="MemHeap">
<query var="heapMemoryUsed" objectName="java.lang:type=Memory" compositeAttribute="HeapMemoryUsage" attribute="used" />
<query var="heapMemoryMax" objectName="java.lang:type=Memory" compositeAttribute="HeapMemoryUsage" attribute="max" />
<expr var="heapMemoryUsedPercent" expression="${heapMemoryUsed}/${heapMemoryMax}*100" />
<check useVar="heapMemoryUsedPercent" warning="92" critical="95" message="heapMemoryUsedPercent is ${heapMemoryUsedPercent}">
<perf />
</check>
</eval>
</connection>
</jmxeval:jmxeval>
Re: Graph not generate. JMXEval plugin used by nrpe
Posted: Fri Apr 11, 2014 2:54 pm
by sreinhardt
Considering the only place the xml file is placed in that script is at the very end, I think its best if we simply hardcode the path to it. So try these:
Without scripts\
Code: Select all
@echo off
@if "%OS%" == "Windows_NT" setlocal
@pushd %~dp0
@set BASE_DIR=%cd%
@popd
set BASE_DIR=%BASE_DIR%\lib\jmxeval-1.2.6
set LIB_DIR=%BASE_DIR%\lib
call C:\jboss-as-7.1.1.Final\bin\jmx_setup.bat
set CLASSPATH=%CLASSPATH%;%BASE_DIR%\jmxeval-1.2.6.jar;%LIB_DIR%\args4j-2.0.16.jar
rem echo %CLASSPATH%
%JAVA_HOME%\bin\java -classpath "%CLASSPATH%" com.adahas.tools.jmxeval.App .\jmxeval_jb.xml
With scripts
Code: Select all
@echo off
@if "%OS%" == "Windows_NT" setlocal
@pushd %~dp0
@set BASE_DIR=%cd%
@popd
set BASE_DIR=%BASE_DIR%\lib\jmxeval-1.2.6
set LIB_DIR=%BASE_DIR%\lib
call C:\jboss-as-7.1.1.Final\bin\jmx_setup.bat
set CLASSPATH=%CLASSPATH%;%BASE_DIR%\jmxeval-1.2.6.jar;%LIB_DIR%\args4j-2.0.16.jar
rem echo %CLASSPATH%
%JAVA_HOME%\bin\java -classpath "%CLASSPATH%" com.adahas.tools.jmxeval.App scripts\jmxeval_jb.xml
Full path - May need to be changed for different OS architecure or nsclient arch
Code: Select all
@echo off
@if "%OS%" == "Windows_NT" setlocal
@pushd %~dp0
@set BASE_DIR=%cd%
@popd
set BASE_DIR=%BASE_DIR%\lib\jmxeval-1.2.6
set LIB_DIR=%BASE_DIR%\lib
call C:\jboss-as-7.1.1.Final\bin\jmx_setup.bat
set CLASSPATH=%CLASSPATH%;%BASE_DIR%\jmxeval-1.2.6.jar;%LIB_DIR%\args4j-2.0.16.jar
rem echo %CLASSPATH%
%JAVA_HOME%\bin\java -classpath "%CLASSPATH%" com.adahas.tools.jmxeval.App "C:\program files\nsclient\scripts\jmxeval_jb.xml"
Try those from the command line, find one that works, then change your nsclient config to have:
Code: Select all
check_jmxeval = scripts\check_jmxeval.bat
instead of:
check_jmxeval = scripts\check_jmxeval.bat scripts\jmxeval_jb.xml