Page 1 of 1

Monitor SHMALL value

Posted: Mon Apr 22, 2019 8:37 pm
by anthonywong
Hi Support,
There is a request came in to monitor "SHMALL" value. Is this possible for Nagios?

Following is SHMALL in Linux box:

a1383660@HKLPAPISI005[~] $ lsipc
RESOURCE DESCRIPTION LIMIT USED USE%
MSGMNI Number of message queues 1024 1 0.10%
MSGMAX Max size of message (bytes) 131072 - -
MSGMNB Default max size of queue (bytes) 131072 - -
SHMMNI Shared memory segments 4096 39 0.95%
SHMALL Shared memory pages 2097152 198537 9.47%
SHMMAX Max size of shared memory segment (bytes) 68719476736 - -
SHMMIN Min size of shared memory segment (bytes) 1 - -
SEMMNI Number of semaphore identifiers 1024 32 3.12%
SEMMNS Total number of semaphores 256000 32 0.01%
SEMMSL Max semaphores per semaphore set. 500 - -
SEMOPM Max number of operations per semop(2) 250 - -
SEMVMX Semaphore max value 32767 - -
a1383660@HKLPAPISI005[~] $ lsipc

Thanks and Regards,
Anthony

Re: Monitor SHMALL value

Posted: Tue Apr 23, 2019 12:22 pm
by lmiltchev
You will need to write a custom script by following the Nagios Plugins Development Guidelines.

Here's a "sample" script that can get you started.

SHMALL.sh

Code: Select all

#!/bin/bash

output=`lsipc | grep SHMALL | awk '{print $6}'`
warn=$1
crit=$2

if [ $output -gt $crit ]; then
  echo "CRITICAL: Shared memory pages: $output | 'Used'=$output;$warn;$crit"
  exit 2
elif [ $output -gt $warn ]; then
  echo "WARNING: Shared memory pages: $output | 'Used'=$output;$warn;$crit"
  exit 1
else
  echo "OK: Shared memory pages: $output | 'Used'=$output;$warn;$crit"
  exit 0
fi
Place the script into the nagios plugins directory, and create a command in the nrpe.cfg file, for example:

Code: Select all

command[check_SHMALL]=/usr/local/nagios/libexec/SHMALL.sh $ARG1$ $ARG2$
Save, exit and restart NRPE, so that changes can take effect.

Test the check by running the following command from the command line on the Nagios server:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <client ip> -c check_SHMALL -a <warning> <critical>
where you substitute <warning> and <critical> with actual values for warning and critical thresholds.

Note: In the example above, I am looking into the "USED Shared memory pages". If you wanted to monitor "USE%" instead, you would need to modify the script.

Hope this helps.

Re: Monitor SHMALL value

Posted: Mon Jun 03, 2019 1:15 am
by anthonywong
thanks for your assistance and pointer.

Re: Monitor SHMALL value

Posted: Mon Jun 03, 2019 7:59 am
by lmiltchev
You are welcome! Let us know if it is OK to close this topic. Thank you!