Page 1 of 1

check_process - working set in gigabytes

Posted: Mon Oct 17, 2016 3:13 am
by warnox
Hi,

I'm wondering if there is a way to perform a calculation on the value returned by %(working_set) (or any variable really) as having the value displayed in bytes isn't very useful?

Looking at, http://docs.nsclient.org/0.4.3/referenc ... ail-syntax, and running the command below shows bytes in detailed syntax but somehow GB in perf syntax.

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H host1 -c check_process -a process=java.exe "crit=working_set > 3072M" "detail-syntax=%(exe) %(working_set)"

Code: Select all

CRITICAL: java.exe 3872395264|'java.exe ws_size'=3.60644GB;0;3
Any help appreciated.

Re: check_process - working set in gigabytes

Posted: Mon Oct 17, 2016 4:18 pm
by rkennedy
I looked around and couldn't seem to find a way to pull ws_size into the detail-syntax part. (which, you should be able to in my mind) The reason I'm after ws_size, is it seems to calculate properly in this field.

Code: Select all

[root@localhost libexec]# /usr/local/nagios/libexec/check_nrpe -H 192.168.5.47 -c check_process -a process=firefox.exe "crit=working_set > 32M" "detail-syntax=%(exe) %(working_set)"
CRITICAL: firefox.exe 537579520|'firefox.exe ws_size'=512.67578MB;0;32
(GB in your case, MB in mine)

What you could do, is write a wrapper script to sit in front of it and re-write $3 with math done, to correct the output. Something like this could be modified (would need to run the command again to generate the exit code, and modify for perfdata) -

Code: Select all

#!/bin/bash
#set vars
memory=$(/usr/local/nagios/libexec/check_nrpe -H 192.168.5.47 -c check_process -a process=firefox.exe "crit=working_set > 32M" "detail-syntax=%(working_set) %(exe)" | awk '{print $2}')
memmb=$(($memory/1024/1024))

echo Memory usage is $memmb MB
Which will return -

Code: Select all

[root@localhost libexec]# ./wrapper.sh
Memory usage is 515 MB

Re: check_process - working set in gigabytes

Posted: Tue Oct 18, 2016 2:37 am
by warnox
It's never easy :)

Thanks for your help, I'll have a play around with this.

Re: check_process - working set in gigabytes

Posted: Tue Oct 18, 2016 10:26 am
by rkennedy
Let me know if you have any further questions about it!