Memory usage monitoring for process

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
kalyanpabolu
Posts: 246
Joined: Fri Jul 03, 2020 4:18 am

Memory usage monitoring for process

Post by kalyanpabolu »

Hi Team,

In one of production server, one particular service consuming more memory and crashing application.

We would like to monitor the memory usage of particular service and alert if memory reaches beyond a certain limit.

I checked few plugins for this but it needs NSClient++.

We are monitoring that server using nrpe agent.

Can you please suggest a plugin to use nrpe and monitor the memory usage of that process?
The server is Linux server.

Thanks in advance!!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Memory usage monitoring for process

Post by ssax »

This should work:

https://exchange.nagios.org/directory/P ... ge/details

Installing it:

Code: Select all

curl -k -L 'https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=6147&cf_id=24' -o /usr/local/nagios/libexec/check_proc_mem.sh
chown nagios.nagios /usr/local/nagios/libexec/check_proc_mem.sh
chmod ug+x /usr/local/nagios/libexec/check_proc_mem.sh
nrpe.cfg entry:

Code: Select all

command[check_proc_mem]=/usr/local/nagios/libexec/check_proc_mem.sh $ARG1$
Calling from XI server:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X -c check_proc_mem -a '-w 1024 -c 2048 --cmdpattern "sshd"'
kalyanpabolu
Posts: 246
Joined: Fri Jul 03, 2020 4:18 am

Re: Memory usage monitoring for process

Post by kalyanpabolu »

Hello,

Thank you for your reply!!
The plugin you suggested is working fine.

Can we monitor the memory utilization of a service running on Windows server? We have NSClient++ on the Windows server.
Service name: Infor WM Socket Server wmprd-socket1

I checked the below post and tried to check the memory usage for the service:

https://support.nagios.com/forum/viewto ... 6&start=10

But, I am getting below error:

[root@monprdmgtss03 plugins]# ./check_nrpe -n -H 10.50.10.51 -p 5666 -t 60 -c CheckCounter -a "Counter:InforWMSocketServerwmprd-socket1memusage=\Process(Infor WM Socket Server wmprd-socket1)\Private bytes" ShowAll
CHECK_NRPE: Error receiving data from daemon.
[root@monprdmgtss03 plugins]#

I also tried checing the process which is running in backend of this service. It is JBossService.exe. I tried checking that process as well but got the same error.

[root@monprdmgtss03 plugins]# ./check_nrpe -n -H 10.50.10.51 -p 5666 -t 60 -c CheckCounter -a "Counter:JavaServicememusage=\Process(JavaService)\Private bytes" ShowAll CHECK_NRPE: Error receiving data from daemon.
[root@monprdmgtss03 plugins]#

Fyi, we have already changed below value to 1 in nsclient cfg file.

# COMMAND ALLOW NASTY META CHARS
; This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow_nasty_meta_chars=1

Please let me know if you need any details.
We want to monitor memory usage for a service running on Windows serever, NSClient++ is installed on that Winows server.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Memory usage monitoring for process

Post by ssax »

What version of NSClient++ are you running? You can find it listed next to the program in programs and features in the Control Panel.

Try this:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 10.25.14.2 -c check_process -a process=JavaService.exe 'warn= virtual > 100m' 'crit= virtual > 200M' detail-syntax='${exe} Virtual: ${virtual}' show-all
Taken from here:

https://support.nagios.com/kb/article/p ... _resources
kalyanpabolu
Posts: 246
Joined: Fri Jul 03, 2020 4:18 am

Re: Memory usage monitoring for process

Post by kalyanpabolu »

Hello,

I am getting below error:

[root@monprdmgtss03 plugins]# ./check_nrpe -H 10.50.10.51 -c check_process -a process=JavaService.exe 'warn= virtual > 100m' 'crit= virtual > 200M' detail-syntax='${exe} Virtual: ${virtual}' show-all
UNKNOWN: No handler for that command
[root@monprdmgtss03 plugins]#

PFA the nsclient file for your reference.

NSClient++ version: 0.3.9

I also tried other plugin - check_process_memory.sh
I am getting OK in output but no values returned.

[root@monprdmgtss03 plugins]# ./check_process_memory.sh -H 10.50.10.51 -p 12489 -P JavaService.exe -w 50000 -c 100000
OK: Used Memory of JavaService.exe: 0 MB|UsedMemory=0;50000;100000;;
[root@monprdmgtss03 plugins]#

I can confirm its not 0 MB.

Can you please help us on the same.
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Memory usage monitoring for process

Post by ssax »

Are there multiple JavaService running on that system? Does this one work for you?

Code: Select all

[root@xid libexec]# ./check_nrpe -2 -H X.X.X.X -p 5666 -t 60 -c CheckCounter -a 'Counter:TEST=\Process(spoolsv)\Private bytes'
OK all counters within bounds.|'TEST'=7733248
Please send me your check_process_memory.sh file so I can see what it supports.
kalyanpabolu
Posts: 246
Joined: Fri Jul 03, 2020 4:18 am

Re: Memory usage monitoring for process

Post by kalyanpabolu »

Hello,
Yes, there are multiple JavaService running. The command provided by you works fine.

[root@monprdmgtss03 plugins]# ./check_nrpe -H 10.50.10.51 -p 5666 -t 60 -c CheckCounter -a 'Counter:TEST=\Process(spoolsv)\Private bytes'
OK all counters within bounds.|'TEST'=17088512
[root@monprdmgtss03 plugins]#

Also, I tried replacing the process with JavaService as bellow:

[root@monprdmgtss03 plugins]# ./check_nrpe -H 10.50.10.51 -p 5666 -t 60 -c CheckCounter -a 'Counter:JavaService=\Process(JavaService)\Private bytes' ShowAll
OK: JavaService: 9.44071e+008|'JavaService'=944070656


I did not understand what above command is doing. Could you please explain?
I am attaching check_process_memory.sh file for your reference.
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Memory usage monitoring for process

Post by ssax »

[root@monprdmgtss03 plugins]# ./check_nrpe -H 10.50.10.51 -p 5666 -t 60 -c CheckCounter -a 'Counter:JavaService=\Process(JavaService)\Private bytes' ShowAll
OK: JavaService: 9.44071e+008|'JavaService'=944070656

I did not understand what above command is doing. Could you please explain?
It's checking the Private bytes performance counter through NRPE to NSClient++ that Windows is reporting. It's returning whatever the counter is returning, you can see a good description of what private bytes is here:

https://stackoverflow.com/a/1986486

Does this one work for you?

Code: Select all

./check_process_memory.sh -H 10.50.10.51 -p 12489 -P JavaService -w 50000 -c 100000
If not, it looks like you would need to modify the check_nt line in there and add -s 'yournsclientpassword' to it.
kalyanpabolu
Posts: 246
Joined: Fri Jul 03, 2020 4:18 am

Re: Memory usage monitoring for process

Post by kalyanpabolu »

Hello,

This is working fine for me. The only thing I am unable to understand is there is approx 10 MB difference in output. If you see the output below:

[root@monprdmgtss03 plugins]# ./check_process_memory.sh -H 10.50.10.51 -p 12489 -P JavaService -w 1000 -c 5000
WARNING: Used Memory of JavaService: 1232 MB|UsedMemory=1232;1000;5000;;
[root@monprdmgtss03 plugins]#

The output shows 1232 MB usage. At the same time, I checked in server and it shows different output. I am attaching the screenshot of the same for your reference.
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Memory usage monitoring for process

Post by ssax »

The plugin is looking at the working set, task manager is using private bytes:

I guess you could try changing this line in the plugin:

Code: Select all

	perfcount_value="Working Set"
To this:

Code: Select all

	perfcount_value="Private Bytes"
And see if that now matches.
Locked