Plugin runs on core and locally but fails over NRPE

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Plugin runs on core and locally but fails over NRPE

Postby AnudeepReddy » Wed Oct 25, 2017 6:35 pm

Hello,

I wrote the following plugin which alerts on Available Memory on FreeBSD. It runs locally on remote machine and its nagios status is ok on the core. But it fails over NRPE. I don't see any errors in the NRPE log file.

Code: Select all
#!/usr/local/bin/bash

if [ "$1" = "-w" ] && [ "$2" -lt "101" ] && [ "$3" = "-c" ] && [ "$4" -lt "101" ] ; then
  warn=$2
  crit=$4

  AVAILMEMPERC=$(free -m | grep 'mem_avail' | sed 's/.*\[ \(.*\)\]/\1/' | awk '{print $1}' | tr -d %)

  if [ ${AVAILMEMPERC} -gt $warn ] && [ ${AVAILMEMPERC} -gt $crit ];then
    echo "OK - Available Memory = $AVAILMEMPERC% | Available memory=$AVAILMEMPERC%;$warn;$crit;0;100"
    exit 0
  elif [ ${AVAILMEMPERC} -lt $warn ] && [ ${AVAILMEMPERC} -gt $crit ]; then
    echo "WARNING - Available Memory = $AVAILMEMPERC% | Available memory=$AVAILMEMPERC%;$warn;$crit;0;100"
    exit 1
  else
    echo "CRITICAL - Available Memory = $AVAILMEMPERC% | Available memory=$AVAILMEMPERC%;$warn;$crit;0;100"
    exit 2
  fi
else
  echo "$0 - Nagios Plugin for checking the available memory in a Linux system"
  echo ""
  echo "Usage:    $0 -w <warnlevel> -c <critlevel>"
  echo "  = warnlevel and critlevel is warning and critical value for alerts."
  echo ""
  echo "EXAMPLE:  $0 -w 10 -c 5 "
  echo "  = This will send warning alert when available memory is less than 10%, and send critical when it is less than 5%"
  echo ""
  exit 3
fi


Output when I run locally:
OK - Available Memory = 88% | Available memory=88%;20;10;0;100

On web gui:
CRITICAL - Available Memory = %

From the GUI output, it looks like the variable value hasn't been grabbed but I am not sure what the issue is. All the other plugins are running fine.
AnudeepReddy
 
Posts: 8
Joined: Wed Oct 25, 2017 6:03 pm

Re: Plugin runs on core and locally but fails over NRPE

Postby kyang » Thu Oct 26, 2017 9:53 am

Hey @AnudeepReddy,

What OS and version is your Core on?

What version of NRPE? Source install?
Code: Select all
./check_nrpe -V


Is it working locally?
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1


Can you show us the command you are using with NRPE to check your FreeBSD server. Is it hardcoded inside your nrpe.cfg? Or you could post your nrpe.cfg.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
kyang
 
Posts: 673
Joined: Tue Jul 25, 2017 3:35 pm

Re: Plugin runs on core and locally but fails over NRPE

Postby AnudeepReddy » Thu Oct 26, 2017 3:05 pm

Hello @kyang,

Yes. Check_nrpe is working fine.

I kinda figured out the issue. Using the absolute path for the command `free -m` resolved the problem. i.e `/usr/local/bin/free -m`
Not sure why I need the full path though. It runs fine on the core without absolute path.
AnudeepReddy
 
Posts: 8
Joined: Wed Oct 25, 2017 6:03 pm

Re: Plugin runs on core and locally but fails over NRPE

Postby kyang » Thu Oct 26, 2017 4:23 pm

Good to hear, did you have more questions or are we okay to close this thread?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
kyang
 
Posts: 673
Joined: Tue Jul 25, 2017 3:35 pm

Re: Plugin runs on core and locally but fails over NRPE

Postby AnudeepReddy » Thu Oct 26, 2017 4:53 pm

Yes, you can close the thread. Thanks!
AnudeepReddy
 
Posts: 8
Joined: Wed Oct 25, 2017 6:03 pm

Re: Plugin runs on core and locally but fails over NRPE

Postby kyang » Thu Oct 26, 2017 4:55 pm

Sounds great! I'll be closing this topic!

If you have any more questions, feel free to create another thread!

Thank you for using the Nagios Support Forum!
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
kyang
 
Posts: 673
Joined: Tue Jul 25, 2017 3:35 pm


Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 1 guest