check_process - working set in gigabytes

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.
Locked
warnox
Posts: 39
Joined: Thu Nov 20, 2014 5:22 am

check_process - working set in gigabytes

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_process - working set in gigabytes

Post 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
Former Nagios Employee
warnox
Posts: 39
Joined: Thu Nov 20, 2014 5:22 am

Re: check_process - working set in gigabytes

Post by warnox »

It's never easy :)

Thanks for your help, I'll have a play around with this.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_process - working set in gigabytes

Post by rkennedy »

Let me know if you have any further questions about it!
Former Nagios Employee
Locked