Monitoring Java Program on a Windows PC

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Nisbo
Posts: 8
Joined: Sun Jun 04, 2017 7:50 am

Monitoring Java Program on a Windows PC

Post by Nisbo »

Hello,

I am new to Nagios and a Linux Noob and I want to check if a Java Program (RepeaterReader.jar) is running on a Windows 10 PC
NSCP-0.5.0.62-x64.msi is running on this PC, the DiskSpace, CPU etc check works fine

I added this service to my windows.cfg
define service{
use generic-service
host_name Intel-NUC
service_description RepeaterReader
check_command check_nt!PROCSTATE!-d SHOWALL -l RepeaterReader.jar
}
but it did not work.
mdomanski
Posts: 23
Joined: Thu Dec 15, 2016 11:17 am

Re: Monitoring Java Program on a Windows PC

Post by mdomanski »

Could You please show also command definition of check_nt

Example usage for procstate based on check_nt:

Code: Select all

./check_nt -H $HOSTADDRESS$ -p 12489 -s password -v PROCSTATE -l explorer.exe -d SHOWALL
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Monitoring Java Program on a Windows PC

Post by dwhitfield »

Thanks for the assist @mdomanski!
Nisbo
Posts: 8
Joined: Sun Jun 04, 2017 7:50 am

Re: Monitoring Java Program on a Windows PC

Post by Nisbo »

mdomanski wrote:Could You please show also command definition of check_nt

Example usage for procstate based on check_nt:

Code: Select all

./check_nt -H $HOSTADDRESS$ -p 12489 -s password -v PROCSTATE -l explorer.exe -d SHOWALL
Sorry I am unable to understand what you are talking about.
Currently I am using this service definition
define service{
use generic-service
host_name Intel-NUC
service_description RepeaterReader
check_command check_nt!PROCSTATE!-d SHOWALL -l javaw.exe
}
this works fine but it monitors only Java, I want to monitor a Java Program
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Monitoring Java Program on a Windows PC

Post by mcapra »

I can almost guarantee you'll need to be using check_nrpe instead of check_nt. Here's some documentation about how to enable your NSClient++ setup to allow check_nrpe connections (it says "Nagios XI" but this is applicable to Core):
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Once NSClient++ is ready for check_nrpe connections, you need to be looking at the command line arguments for the Java processes to identify a specific JAR file. In the Windows Task Manager, it might look similar to like this:
2017_06_05_11_55_27_Windows_Task_Manager.png
You can do this with a NSClient++ filter rule. Something like this might be a good place to start:

Code: Select all

/path/to/check_nrpe -H 192.168.142.137 -t 30 -c check_process -a process="javaw.exe" "filter=command_line like 'my_program.jar'"
I haven't tested the above though, so the syntax might be a bit dodgy.
Former Nagios employee
https://www.mcapra.com/
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Monitoring Java Program on a Windows PC

Post by avandemore »

Very insightful @mcapra!
@Nisbo does this answer your question?
Previous Nagios employee
Nisbo
Posts: 8
Joined: Sun Jun 04, 2017 7:50 am

Re: Monitoring Java Program on a Windows PC

Post by Nisbo »

I have to try it later, I will keep you informed :)
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Monitoring Java Program on a Windows PC

Post by avandemore »

Sounds good, we'll leave this open for now.
Previous Nagios employee
Nisbo
Posts: 8
Joined: Sun Jun 04, 2017 7:50 am

Re: Monitoring Java Program on a Windows PC

Post by Nisbo »

The Windows part works fine, the shell command reports: File or Folder not found
Screenshot_255.jpg
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Monitoring Java Program on a Windows PC

Post by avandemore »

What is the output of:

Code: Select all

# stat /usr/local/nagios/libexec/check_nrpe
# ldd /usr/local/nagios/libexec/check_nrpe
# /usr/local/nagios/libexec/check_nrpe -h | head -n 4
Previous Nagios employee
Locked