Red Hat NRPE Memory Check Not showing %

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Red Hat NRPE Memory Check Not showing %

Post by jkinning »

I have 6 Red Hat Servers all built the same and the nrpe agent installed the same way. I looked at the configuration file and libexex directory and everything appears to be the same both with user and permissions. When I run

Code: Select all

./check_nrpe -H <host1> -c check_mem -a '-w 20 -c 10'
I get the results I would expect OK - 8665 / 11911 MB (72%) Free Memory, Used: 8027 MB, Shared: 0 MB, Buffers: 304 MB, Cached: 4781 MB | total=11911MB free=8665MB used=8027MB shared=0 buffers=304MB cached=4781MB

When I run the same command on one of the 3 "faulty" RHEL servers I get this - CRITICAL - 10581 / 11911 MB (%) Free Memory, Used: 1851 MB, Shared: 0 MB, Buffers: 40 MB, Cached: 521 MB | total=11911MB free=10581MB used=1851MB shared=0 buffers=40MB cached=521MB and the check is the same

Code: Select all

./check_nrpe -H <host2> -c check_mem -a '-w 20 -c 10'
Trying to figure out why I have 3 out of 7 machines that don't want to show the percentage but just %?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by lmiltchev »

On the "failing" clients (remote machines), run the following command:

Code: Select all

yum install bc -y
Let me know if this fixed your issue.
Be sure to check out our Knowledgebase for helpful articles and solutions!
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by jkinning »

Package bc-1.06.95-1.el6.x86_64 already installed and latest version

Still the same problem
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by lmiltchev »

If you have "bc" installed, you should also have "dc", which is used by the "custom_check_mem". What is the output of the following commands, run on the remote machines? Place the output in code wraps.

Code: Select all

which dc
which sed
which gawk
cat /usr/local/nagios/libexec/custom_check_mem
Be sure to check out our Knowledgebase for helpful articles and solutions!
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by jkinning »

Code: Select all

/usr/bin/dc
/bin/sed
/bin/gawk
#!/bin/bash
# Script to check real memory usage
# L.Gill 02/05/06 - V.1.0
# ------------------------------------------
# ########  Script Modifications  ##########
# ------------------------------------------
# Who    When      What
# ---    ----      ----
# LGill  17/05/06  "$percent" lt 1% fix - sed edits dc result beggining with "."
#
#
#!/bin/bash
USAGE="`basename $0` [-w|--warning]<percent free> [-c|--critical]<percent free>                                      [-n|--nocache]"
THRESHOLD_USAGE="WARNING threshold must be greater than CRITICAL: `basename $0`                                      $*"
calc=/tmp/memcalc
percent_free=/tmp/mempercent
critical=""
warning=""
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
nocache=0
# print usage
if [[ $# -lt 4 ]]
then
        echo ""
        echo "Wrong Syntax: `basename $0` $*"
        echo ""
        echo "Usage: $USAGE"
        echo ""
        exit 0
fi
# read input
while [[ $# -gt 0 ]]
  do
        case "$1" in
               -w|--warning)
               shift
               warning=$1
        ;;
               -c|--critical)
               shift
               critical=$1
        ;;

               -n|--nocache)
               nocache=1
        ;;
        esac
        shift
  done
# verify input
if [[ $warning -eq $critical || $warning -lt $critical ]]
then
        echo ""
        echo "$THRESHOLD_USAGE"
        echo ""
        echo "Usage: $USAGE"
        echo ""
        exit 0
fi

memoutput=`free -m | head -2 | tail -1`

# Total memory available
#total=`free -m | head -2 |tail -1 |gawk '{print $2}'`
total=`echo $memoutput | gawk '{print $2}'`
# Total memory used
#used=`free -m | head -2 |tail -1 |gawk '{print $3}'`
used=`echo $memoutput | gawk '{print $3}'`
# Calc total minus used
#free=`free -m | head -2 |tail -1 |gawk '{print $2-$3}'`
if [ "$nocache" -eq "1" ]; then
    free=`echo $memoutput | gawk '{print $2-$3+$7}'`
else
    free=`echo $memoutput | gawk '{print $2-$3}'`
fi

shared=`echo $memoutput | gawk '{print $5}'`
buffers=`echo $memoutput | gawk '{print $6}'`
cached=`echo $memoutput | gawk '{print $7}'`
# free=$free-$cached
# normal values
#echo "$total"MB total
#echo "$used"MB used
#echo "$free"MB free

# make it into % percent free = ((free mem / total mem) * 100)
echo "5" > $calc # decimal accuracy
echo "k" >> $calc # commit
echo "100" >> $calc # multiply
echo "$free" >> $calc # division integer
echo "$total" >> $calc # division integer
echo "/" >> $calc # division sign
echo "*" >> $calc # multiplication sign
echo "p" >> $calc # print
percent=`/usr/bin/dc $calc|/bin/sed 's/^\./0./'|/usr/bin/tr "." " "|/usr/bin/gaw                                     k {'print $1'}`
#percent1=`/usr/bin/dc $calc`
#echo "$percent1"
if [[ "$percent" -le  $warning ]]
        then
    string="WARNING"
    result=1
fi
if [[ "$percent" -le  $critical ]]
    then
    string="CRITICAL"
    result=2
fi
if [[ "$percent" -gt  $warning ]]
    then
    string="OK"
    result=0
fi

echo "$string - $free / $total MB ($percent%) Free Memory, Used: $used MB, Share                                     d: $shared MB, Buffers: $buffers MB, Cached: $cached MB | total="$total"MB free=                                     "$free"MB used="$used"MB shared="$shared"$MB buffers="$buffers"MB cached="$cache                                     d"MB"
exit $result
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by lmiltchev »

Can you try running the following command on the remote box?

Code: Select all

ln -s /usr/bin/gawk /bin/gawk
Did this fix the issue?

Test it locally (on the client):

Code: Select all

/usr/local/nagios/libexec/custom_check_mem -w 20 -c 10
Be sure to check out our Knowledgebase for helpful articles and solutions!
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by jkinning »

I am not sure what happened, maybe time thing, but these are now reporting the % and not at a critical state.

Bug maybe? It is working correctly now and I did nothing.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by jolson »

Interesting. It started working on all three of your affected boxes at the same time?
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by jkinning »

Not sure if it was exactly the same time but over the weekend they must have started working because I looked at them this Monday morning and they are reporting with the % so I ran the command from the Nagios XI server itself and it shows 73% whereas before it was just showing %

Weird stuff but I am glad it wasn't nothing major but only happened on these 3 hosts running Red Hat.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Red Hat NRPE Memory Check Not showing %

Post by jdalrymple »

Glad it's working, are you OK with us locking the topic?
Locked