Memory Usage Linux
Memory Usage Linux
Hello everyone,
Things didn't go too well with my previous attempt of trying to find a check memory service for a Linux server. Does anyone have suggestions or a guide that I can use for a check memory service? thanks in advance
Things didn't go too well with my previous attempt of trying to find a check memory service for a Linux server. Does anyone have suggestions or a guide that I can use for a check memory service? thanks in advance
-
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: Memory Usage Linux
Well the easiest and arguably most used is the check_mem function of check_nrpe. Here, an example is shown of how to properly define it:
http://www.ericmichaelstone.com/?p=3652
http://www.ericmichaelstone.com/?p=3652
Re: Memory Usage Linux
thanks for the guide, but I came across a problem after I finished the guide. I did everything it told me to do, and now on the nagios website, I am getting an unknown error, with this as the explanation..
No output returned from plugin)
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)
Version: 2.12
Last Modified: 03-10-2008
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required
Usage: check_nrpe -H <host> [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]
Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.
-h,--help Print this short help.
-l,--license Print licensing information.
-n,--no-ssl Do not initial an ssl handshake with the server, talk in plaintext.
Note:
This plugin requires that you have the NRPE daemon running on the remote host.
You must also have configured the daemon to associate a specific plugin command
with the [command] option you are specifying here. Upon receipt of the
[command] argument, the NRPE daemon will run the appropriate plugin command and
send the plugin output and return code back to *this* plugin. This allows you
to execute plugins on remote hosts and 'fake' the results to make Nagios think
the plugin is being run locally.
got an idea how to fix this? thanks again
No output returned from plugin)
NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)
Version: 2.12
Last Modified: 03-10-2008
License: GPL v2 with exemptions (-l for more info)
SSL/TLS Available: Anonymous DH Mode, OpenSSL 0.9.6 or higher required
Usage: check_nrpe -H <host> [-n] [-u] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]
Options:
-n = Do no use SSL
-u = Make socket timeouts return an UNKNOWN state instead of CRITICAL
<host> = The address of the host running the NRPE daemon
[port] = The port on which the daemon is running (default=5666)
[timeout] = Number of seconds before connection times out (default=10)
[command] = The name of the command that the remote daemon should run
[arglist] = Optional arguments that should be passed to the command. Multiple
arguments should be separated by a space. If provided, this must be
the last option supplied on the command line.
-h,--help Print this short help.
-l,--license Print licensing information.
-n,--no-ssl Do not initial an ssl handshake with the server, talk in plaintext.
Note:
This plugin requires that you have the NRPE daemon running on the remote host.
You must also have configured the daemon to associate a specific plugin command
with the [command] option you are specifying here. Upon receipt of the
[command] argument, the NRPE daemon will run the appropriate plugin command and
send the plugin output and return code back to *this* plugin. This allows you
to execute plugins on remote hosts and 'fake' the results to make Nagios think
the plugin is being run locally.
got an idea how to fix this? thanks again
Re: Memory Usage Linux
Whenever you are returned usage information, you probably are experiencing a syntax issue.
1. What is the full command of the check?
2. What does the remote host's nrpe.cfg command definition look like?
3. Have you taken a look at the nrpe troubleshooting document?
http://library.nagios.com/library/produ ... -solutions
1. What is the full command of the check?
2. What does the remote host's nrpe.cfg command definition look like?
3. Have you taken a look at the nrpe troubleshooting document?
http://library.nagios.com/library/produ ... -solutions
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Memory Usage Linux
here is the full command of the check:
and here is the command definition:
Code: Select all
command[check_mem]=/usr/lib/nagios/plugins/check_mem.sh 85 95
and here is the command definition:
Code: Select all
#!/bin/ksh
# Determine memory usage percentage on Linux servers.
# Original write for RHEL3 for PC1 Project - jlightner 05-Jul-2005
#
# Modified for RHEL5 on mailservers.
# -Some of the escapes previously required for RHEL3's ksh not needed on RHEL5.
# -Changed comparisons to allow for decimal rather than integer values.
# jlightner 23-Jan-2009
#
# Usage: check_mem.sh WARNING CRITICAL
# Where WARNING and CRITICAL are the integer only portions of the
# percentage for the level desired.
# (i.e. 85% Warning & 95% Critical should be input only as "85 95".)
# Define Levels based on input
#
WARNLEVEL=$1
CRITLEVEL=$2
# Setup standard Nagios/NRPE return codes
#
UNKNOWN_STATE=3
CRITICAL_STATE=2
WARNING_STATE=1
OK_STATE=0
# Give full paths to commands - Nagios can't determine location otherwise
#
BC=/usr/bin/bc
GREP=/bin/grep
AWK=/bin/awk
FREE=/usr/bin/free
TAIL=/usr/bin/tail
HEAD=/usr/bin/head
# total used free shared buffers cached
#Mem: 610612 551608 59004 0 96100 100996
# Get memory information from the "free" command - output of top two lines
# looks like:
# total used free shared buffers cached
# Mem: 8248768 6944444 1304324 0 246164 5647524
# The set command will get everything from the second line and put it into
# posiional variables $1 through $7.
#
set `$FREE |$HEAD -2 |$TAIL -1`
# Now give variable names to the positional variables we set above
#
MEMTOTAL=$2
MEMUSED=$3
MEMFREE=$4
MEMBUFFERS=$6
MEMCACHED=$7
# Do calculations based on what we got from free using the variables defined
#
REALMEMUSED=`echo $MEMUSED - $MEMBUFFERS - $MEMCACHED | $BC`
USEPCT=`echo "scale=3; $REALMEMUSED / $MEMTOTAL * 100" |$BC -l`
#USEPCT=`echo scale=3 "\n" $REALMEMUSED \/ $MEMTOTAL \* 100 |$BC -l |$AWK -F\. '{print $1}'`
# Compare the Used percentage to the Warning and Critical levels input at
# command line. Issue message and set return code as appropriate for each
# level. Nagios web page will use these to determine alarm level and message.
#
#if [ `echo "5.0 > 5" |bc` -eq 1 ]
#then echo it is greater
#else echo it is not greater
#fi
if [ `echo "$USEPCT > $CRITLEVEL" |bc` -eq 1 ]
then echo "CRITICAL - Memory usage is ${USEPCT}% (${REALMEMUSED})"
exit ${CRITICAL_STATE}
elif [ `echo "$USEPCT > $WARNLEVEL" |bc` -eq 1 ]
then echo "WARNING - Memory usage is ${USEPCT}% (${REALMEMUSED})"
exit ${WARNING_STATE}
elif [ `echo "$USEPCT < $WARNLEVEL" |bc` -eq 1 ]
then echo "OK - Memory usage is ${USEPCT}% (${REALMEMUSED})"
exit ${OK_STATE}
else echo "Unable to determine memory usage."
exit ${UNKNOWN_STATE}
fi
echo "Unable to determine memory usage."
exit ${UNKNOWN_STATE}
Last edited by abrist on Wed Jun 12, 2013 11:01 am, edited 2 times in total.
Reason: code wraps!
Reason: code wraps!
Re: Memory Usage Linux
Can we see the service check definition and the command definition on the XI server?
Does the check work when run locally from the remote host?:
Does the check work when run locally from the remote host?:
Code: Select all
/usr/lib/nagios/plugins/check_mem.sh 85 95
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Memory Usage Linux
service definition off the nagios server
define service{
use generic-service
host_name VNAADM642
service_description Memory Usage
check_command check_nrpe!check_mem
}
and the command definition part, I have to define that on the nagios server? like I said I followed the link that was posted here earlier. what I did on that link is that I went on the remote server and added the check_mem definition, then on the same server went into my nrpe.cfg and added this :command[check_mem]=/usr/local/nagios/libexec/check_mem.sh 85 95 then went on my nagios server and added the service as listed above. was I suppose to do something else?
define service{
use generic-service
host_name VNAADM642
service_description Memory Usage
check_command check_nrpe!check_mem
}
and the command definition part, I have to define that on the nagios server? like I said I followed the link that was posted here earlier. what I did on that link is that I went on the remote server and added the check_mem definition, then on the same server went into my nrpe.cfg and added this :command[check_mem]=/usr/local/nagios/libexec/check_mem.sh 85 95 then went on my nagios server and added the service as listed above. was I suppose to do something else?
Re: Memory Usage Linux
I was curious about the check_nrpe command definition on the nagios server. Did the check work when locally run from teh remote host?
Code: Select all
/usr/lib/nagios/plugins/check_mem.sh 85 95
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Memory Usage Linux
how do I run the check?
Re: Memory Usage Linux
Log into the cli on the remote system and run the following commands:
Code: Select all
su nagios
/usr/lib/nagios/plugins/check_mem.sh 85 95
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.