<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Memory check plugin for Nagios</title>
	<atom:link href="http://www.matejunkie.com/memory-check-plugin-for-nagios/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matejunkie.com/memory-check-plugin-for-nagios/</link>
	<description>"Look behind you, a Three-Headed Monkey!"</description>
	<lastBuildDate>Tue, 25 May 2010 09:39:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Asier</title>
		<link>http://www.matejunkie.com/memory-check-plugin-for-nagios/comment-page-1/#comment-5996</link>
		<dc:creator>Asier</dc:creator>
		<pubDate>Mon, 01 Mar 2010 15:00:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.matejunkie.net//?p=752#comment-5996</guid>
		<description>Works great! Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Works great! Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeo</title>
		<link>http://www.matejunkie.com/memory-check-plugin-for-nagios/comment-page-1/#comment-5924</link>
		<dc:creator>Jeo</dc:creator>
		<pubDate>Thu, 25 Feb 2010 07:32:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.matejunkie.net//?p=752#comment-5924</guid>
		<description>Thanks a lot !
It works perfectly !</description>
		<content:encoded><![CDATA[<p>Thanks a lot !<br />
It works perfectly !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Westgaard</title>
		<link>http://www.matejunkie.com/memory-check-plugin-for-nagios/comment-page-1/#comment-5753</link>
		<dc:creator>Christian Westgaard</dc:creator>
		<pubDate>Thu, 28 Jan 2010 13:31:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.matejunkie.net//?p=752#comment-5753</guid>
		<description>Added possibility for VSZ and RSS

#!/bin/sh
 
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
PROGNAME=`basename $0`
VERSION=&quot;Version 1.0,&quot;
AUTHOR=&quot;2009, Mike Adolphs (http://www.matejunkie.com/)&quot;

# 2010-01-28 Christian Westgaard 
#            Added target vsz and rss
 
ST_OK=0
ST_WR=1
ST_CR=2
ST_UK=3
 
process=&quot;cron&quot;
target=&quot;mem&quot;
 
print_version() {
    echo &quot;$VERSION $AUTHOR&quot;
}
 
print_help() {
    print_version $PROGNAME $VERSION
    echo &quot;&quot;
    echo &quot;$PROGNAME is a Nagios plugin to check a specific process via ps.&quot;
    echo &quot;You may provide any string as an argument to match a specific&quot;
    echo &quot;process. Please note that the output could be distorted if the&quot;
    echo &quot;argument matches various processes, so please make sure to use&quot;
    echo &quot;unique strings to match a process.&quot;
    echo &quot;&quot;
    echo &quot;$PROGNAME -p firefox [-w 10] [-c 20] [-t cpu]&quot;
    echo &quot;&quot;
    echo &quot;Options:&quot;
    echo &quot;  -p/--process)&quot;
    echo &quot;     You need to provide a string for which the ps output is then&quot;
    echo &quot;     then \&quot;greped\&quot;.&quot;
    echo &quot;  -w/--warning)&quot;
    echo &quot;     Defines a warning level for a target which is explained&quot;
    echo &quot;     below. Default is: off&quot;
    echo &quot;  -c/--critical)&quot;
    echo &quot;     Defines a critical level for a target which is explained&quot;
    echo &quot;     below. Default is: off&quot;
    echo &quot;  -t/--target)&quot;
    echo &quot;     A target can be defined via -t. Choose between cpu, mem, vsz and rss.&quot;
    echo &quot;     Default is: mem&quot;
    exit $ST_UK
}
 
while test -n &quot;$1&quot;; do
    case &quot;$1&quot; in
        --help&#124;-h)
            print_help
            exit $ST_UK
            ;;
        --version&#124;-v)
            print_version $PROGNAME $VERSION
            exit $ST_UK
            ;;
        --process&#124;-p)
            process=$2
            shift
            ;;
        --target&#124;-t)
            target=$2
            shift
            ;;
        --warning&#124;-w)
            warning=$2
            shift
            ;;
        --critical&#124;-c)
            critical=$2
            shift
            ;;
        *)
            echo &quot;Unknown argument: $1&quot;
            print_help
            exit $ST_UK
            ;;
        esac
    shift
done
 
get_wcdiff() {
    if [ ! -z &quot;$warning&quot; -a ! -z &quot;$critical&quot; ]
    then
        wclvls=1
        if [ ${warning} -gt ${critical} ]
        then
            wcdiff=1
        fi
    elif [ ! -z &quot;$warning&quot; -a -z &quot;$critical&quot; ]
    then
        wcdiff=2
    elif [ -z &quot;$warning&quot; -a ! -z &quot;$critical&quot; ]
    then
        wcdiff=3
    fi
}
 
val_wcdiff() {
    if [ &quot;$wcdiff&quot; = 1 ]
    then
        echo &quot;Please adjust your warning/critical thresholds. The warning \
must be lower than the critical level!&quot;
        exit $ST_UK
    elif [ &quot;$wcdiff&quot; = 2 ]
    then
        echo &quot;Please also set a critical value when you want to use \
warning/critical thresholds!&quot;
        exit $ST_UK
    elif [ &quot;$wcdiff&quot; = 3 ]
    then
        echo &quot;Please also set a warning value when you want to use \
warning/critical thresholds!&quot;
        exit $ST_UK
    fi
}
 
get_vals() {
    process=`echo ${process} &#124; sed &#039;s/^.\&#124;[a-z][A-Z] /\[&amp;]/g&#039;`
 
    tmp_output=`ps aux &#124; grep &quot;$process&quot; &#124; grep -v $0`
 
    if [ -z &quot;$tmp_output&quot; ]
    then
        echo &quot;CRITICAL - Process is not running!&quot;
        exit $ST_CR
    fi
 
    ps_user=`echo ${tmp_output} &#124; awk &#039;{print $1}&#039;`
    ps_pid=`echo ${tmp_output} &#124; awk &#039;{print $2}&#039; `
    ps_cpu=`echo ${tmp_output} &#124; awk &#039;{print $3}&#039;`
    ps_mem=`echo ${tmp_output} &#124; awk &#039;{print $4}&#039; `
    ps_vsz=`echo ${tmp_output} &#124; awk &#039;{print $5}&#039; ` # total VM size in kB
    ps_rss=`echo ${tmp_output} &#124; awk &#039;{print $6}&#039; ` # resident set size
    ps_start=`echo ${tmp_output} &#124; awk &#039;{print $9}&#039; `
 
    tmp_ps_cputime=`echo ${tmp_output} &#124; awk &#039;{print $10}&#039;`
    tmp_ps_cpuhours=`echo ${tmp_ps_cputime} &#124; awk -F \: &#039;{print $1}&#039;`
    tmp_ps_cpumin=`echo ${tmp_ps_cputime} &#124; awk -F \: &#039;{print $2}&#039;`
    ps_cputime=`echo &quot;scale=0; (${tmp_ps_cpuhours} * 60) + \
${tmp_ps_cpumin}&quot; &#124; bc -l`
}
 
do_wccalc() {
    if [ -n &quot;$warning&quot; -a -n &quot;$critical&quot; ]
    then
        if [ &quot;$target&quot; = &quot;cpu&quot; ]; then
            tmp_wc_target=`echo ${ps_cpu} &#124; awk -F \. &#039;{print $2}&#039;`
            if [ &quot;$tmp_wc_target&quot; -ge 5 ]
            then
                wc_target=`echo ${ps_cpu} &#124; awk -F \. &#039;{print $1}&#039;`
                wc_target=`expr ${wc_target} + 1`
            else
                wc_target=`echo ${ps_cpu} &#124; awk -F \. &#039;{print $1}&#039;`
            fi
        elif [ &quot;$target&quot; = &quot;mem&quot; ]; then
            tmp_wc_target=`echo ${ps_mem} &#124; awk -F \. &#039;{print $2}&#039;`
            if [ &quot;$tmp_wc_target&quot; -ge 5 ]
            then
                wc_target=`echo ${ps_mem} &#124; awk -F \. &#039;{print $1}&#039;`
                wc_target=`expr ${wc_target} + 1`
            else
                wc_target=`echo ${ps_mem} &#124; awk -F \. &#039;{print $1}&#039;`
            fi
        elif [ &quot;$target&quot; = &quot;vsz&quot; ]; then
	    wc_target=${ps_vsz}
        elif [ &quot;$target&quot; = &quot;rss&quot; ]; then
	    wc_target=${ps_rss}
        fi
    fi
}
 
do_output() {
    process=`echo ${process} &#124; sed &#039;s/\[//g&#039; &#124;  sed &#039;s/\]//g&#039;`
    output=&quot;Process: ${process}, User: ${ps_user}, CPU: ${ps_cpu}%, \
RAM: ${ps_mem}%, VSZ: ${ps_vsz}kB, RSS: ${ps_rss}kB, Start: ${ps_start}, CPU Time: ${ps_cputime} min&quot;
}
 
do_perfdata() {
    perfdata=&quot;&#039;cpu&#039;=${ps_cpu} &#039;memory&#039;=${ps_mem} &#039;vsz&#039;=${ps_vsz} &#039;rss&#039;=${ps_rss} cputime&#039;=${ps_cputime}&quot;
}
 
# Here we go!
get_wcdiff
val_wcdiff
 
get_vals
do_wccalc
do_output
do_perfdata
 
if [ -n &quot;$warning&quot; -a -n &quot;$critical&quot; ]
then
    if [ &quot;$wc_target&quot; -ge &quot;$warning&quot; -a &quot;$wc_target&quot; -lt &quot;$critical&quot; ]
    then
        echo &quot;WARNING - ${output} &#124; ${perfdata}&quot;
        exit $ST_WR
    elif [ &quot;$wc_target&quot; -ge &quot;$critical&quot; ]
    then
        echo &quot;CRITICAL - ${output} &#124; ${perfdata}&quot;
        exit $ST_CR
    else
        echo &quot;OK - ${output} &#124; ${perfdata}&quot;
        exit $ST_OK
    fi
else
    echo &quot;OK - ${output} &#124; ${perfdata}&quot;
    exit $ST_OK
fi</description>
		<content:encoded><![CDATA[<p>Added possibility for VSZ and RSS</p>
<p>#!/bin/sh</p>
<p>#   This program is free software; you can redistribute it and/or modify<br />
#   it under the terms of the GNU General Public License as published by<br />
#   the Free Software Foundation; either version 2 of the License, or<br />
#   (at your option) any later version.<br />
#<br />
#   This program is distributed in the hope that it will be useful,<br />
#   but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br />
#   GNU General Public License for more details.<br />
#<br />
#   You should have received a copy of the GNU General Public License<br />
#   along with this program; if not, write to the Free Software<br />
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</p>
<p>PROGNAME=`basename $0`<br />
VERSION=&#8221;Version 1.0,&#8221;<br />
AUTHOR=&#8221;2009, Mike Adolphs (<a href="http://www.matejunkie.com/)" rel="nofollow">http://www.matejunkie.com/)</a>&#8221;</p>
<p># 2010-01-28 Christian Westgaard<br />
#            Added target vsz and rss</p>
<p>ST_OK=0<br />
ST_WR=1<br />
ST_CR=2<br />
ST_UK=3</p>
<p>process=&#8221;cron&#8221;<br />
target=&#8221;mem&#8221;</p>
<p>print_version() {<br />
    echo &#8220;$VERSION $AUTHOR&#8221;<br />
}</p>
<p>print_help() {<br />
    print_version $PROGNAME $VERSION<br />
    echo &#8220;&#8221;<br />
    echo &#8220;$PROGNAME is a Nagios plugin to check a specific process via ps.&#8221;<br />
    echo &#8220;You may provide any string as an argument to match a specific&#8221;<br />
    echo &#8220;process. Please note that the output could be distorted if the&#8221;<br />
    echo &#8220;argument matches various processes, so please make sure to use&#8221;<br />
    echo &#8220;unique strings to match a process.&#8221;<br />
    echo &#8220;&#8221;<br />
    echo &#8220;$PROGNAME -p firefox [-w 10] [-c 20] [-t cpu]&#8221;<br />
    echo &#8220;&#8221;<br />
    echo &#8220;Options:&#8221;<br />
    echo &#8221;  -p/&#8211;process)&#8221;<br />
    echo &#8221;     You need to provide a string for which the ps output is then&#8221;<br />
    echo &#8221;     then \&#8221;greped\&#8221;.&#8221;<br />
    echo &#8221;  -w/&#8211;warning)&#8221;<br />
    echo &#8221;     Defines a warning level for a target which is explained&#8221;<br />
    echo &#8221;     below. Default is: off&#8221;<br />
    echo &#8221;  -c/&#8211;critical)&#8221;<br />
    echo &#8221;     Defines a critical level for a target which is explained&#8221;<br />
    echo &#8221;     below. Default is: off&#8221;<br />
    echo &#8221;  -t/&#8211;target)&#8221;<br />
    echo &#8221;     A target can be defined via -t. Choose between cpu, mem, vsz and rss.&#8221;<br />
    echo &#8221;     Default is: mem&#8221;<br />
    exit $ST_UK<br />
}</p>
<p>while test -n &#8220;$1&#8243;; do<br />
    case &#8220;$1&#8243; in<br />
        &#8211;help|-h)<br />
            print_help<br />
            exit $ST_UK<br />
            ;;<br />
        &#8211;version|-v)<br />
            print_version $PROGNAME $VERSION<br />
            exit $ST_UK<br />
            ;;<br />
        &#8211;process|-p)<br />
            process=$2<br />
            shift<br />
            ;;<br />
        &#8211;target|-t)<br />
            target=$2<br />
            shift<br />
            ;;<br />
        &#8211;warning|-w)<br />
            warning=$2<br />
            shift<br />
            ;;<br />
        &#8211;critical|-c)<br />
            critical=$2<br />
            shift<br />
            ;;<br />
        *)<br />
            echo &#8220;Unknown argument: $1&#8243;<br />
            print_help<br />
            exit $ST_UK<br />
            ;;<br />
        esac<br />
    shift<br />
done</p>
<p>get_wcdiff() {<br />
    if [ ! -z "$warning" -a ! -z "$critical" ]<br />
    then<br />
        wclvls=1<br />
        if [ ${warning} -gt ${critical} ]<br />
        then<br />
            wcdiff=1<br />
        fi<br />
    elif [ ! -z "$warning" -a -z "$critical" ]<br />
    then<br />
        wcdiff=2<br />
    elif [ -z "$warning" -a ! -z "$critical" ]<br />
    then<br />
        wcdiff=3<br />
    fi<br />
}</p>
<p>val_wcdiff() {<br />
    if [ "$wcdiff" = 1 ]<br />
    then<br />
        echo &#8220;Please adjust your warning/critical thresholds. The warning \<br />
must be lower than the critical level!&#8221;<br />
        exit $ST_UK<br />
    elif [ "$wcdiff" = 2 ]<br />
    then<br />
        echo &#8220;Please also set a critical value when you want to use \<br />
warning/critical thresholds!&#8221;<br />
        exit $ST_UK<br />
    elif [ "$wcdiff" = 3 ]<br />
    then<br />
        echo &#8220;Please also set a warning value when you want to use \<br />
warning/critical thresholds!&#8221;<br />
        exit $ST_UK<br />
    fi<br />
}</p>
<p>get_vals() {<br />
    process=`echo ${process} | sed &#8216;s/^.\|[a-z][A-Z] /\[&amp;]/g&#8217;`</p>
<p>    tmp_output=`ps aux | grep &#8220;$process&#8221; | grep -v $0`</p>
<p>    if [ -z "$tmp_output" ]<br />
    then<br />
        echo &#8220;CRITICAL &#8211; Process is not running!&#8221;<br />
        exit $ST_CR<br />
    fi</p>
<p>    ps_user=`echo ${tmp_output} | awk &#8216;{print $1}&#8217;`<br />
    ps_pid=`echo ${tmp_output} | awk &#8216;{print $2}&#8217; `<br />
    ps_cpu=`echo ${tmp_output} | awk &#8216;{print $3}&#8217;`<br />
    ps_mem=`echo ${tmp_output} | awk &#8216;{print $4}&#8217; `<br />
    ps_vsz=`echo ${tmp_output} | awk &#8216;{print $5}&#8217; ` # total VM size in kB<br />
    ps_rss=`echo ${tmp_output} | awk &#8216;{print $6}&#8217; ` # resident set size<br />
    ps_start=`echo ${tmp_output} | awk &#8216;{print $9}&#8217; `</p>
<p>    tmp_ps_cputime=`echo ${tmp_output} | awk &#8216;{print $10}&#8217;`<br />
    tmp_ps_cpuhours=`echo ${tmp_ps_cputime} | awk -F \: &#8216;{print $1}&#8217;`<br />
    tmp_ps_cpumin=`echo ${tmp_ps_cputime} | awk -F \: &#8216;{print $2}&#8217;`<br />
    ps_cputime=`echo &#8220;scale=0; (${tmp_ps_cpuhours} * 60) + \<br />
${tmp_ps_cpumin}&#8221; | bc -l`<br />
}</p>
<p>do_wccalc() {<br />
    if [ -n "$warning" -a -n "$critical" ]<br />
    then<br />
        if [ "$target" = "cpu" ]; then<br />
            tmp_wc_target=`echo ${ps_cpu} | awk -F \. &#8216;{print $2}&#8217;`<br />
            if [ "$tmp_wc_target" -ge 5 ]<br />
            then<br />
                wc_target=`echo ${ps_cpu} | awk -F \. &#8216;{print $1}&#8217;`<br />
                wc_target=`expr ${wc_target} + 1`<br />
            else<br />
                wc_target=`echo ${ps_cpu} | awk -F \. &#8216;{print $1}&#8217;`<br />
            fi<br />
        elif [ "$target" = "mem" ]; then<br />
            tmp_wc_target=`echo ${ps_mem} | awk -F \. &#8216;{print $2}&#8217;`<br />
            if [ "$tmp_wc_target" -ge 5 ]<br />
            then<br />
                wc_target=`echo ${ps_mem} | awk -F \. &#8216;{print $1}&#8217;`<br />
                wc_target=`expr ${wc_target} + 1`<br />
            else<br />
                wc_target=`echo ${ps_mem} | awk -F \. &#8216;{print $1}&#8217;`<br />
            fi<br />
        elif [ "$target" = "vsz" ]; then<br />
	    wc_target=${ps_vsz}<br />
        elif [ "$target" = "rss" ]; then<br />
	    wc_target=${ps_rss}<br />
        fi<br />
    fi<br />
}</p>
<p>do_output() {<br />
    process=`echo ${process} | sed &#8216;s/\[//g' |  sed 's/\]//g&#8217;`<br />
    output=&#8221;Process: ${process}, User: ${ps_user}, CPU: ${ps_cpu}%, \<br />
RAM: ${ps_mem}%, VSZ: ${ps_vsz}kB, RSS: ${ps_rss}kB, Start: ${ps_start}, CPU Time: ${ps_cputime} min&#8221;<br />
}</p>
<p>do_perfdata() {<br />
    perfdata=&#8221;&#8216;cpu&#8217;=${ps_cpu} &#8216;memory&#8217;=${ps_mem} &#8216;vsz&#8217;=${ps_vsz} &#8216;rss&#8217;=${ps_rss} cputime&#8217;=${ps_cputime}&#8221;<br />
}</p>
<p># Here we go!<br />
get_wcdiff<br />
val_wcdiff</p>
<p>get_vals<br />
do_wccalc<br />
do_output<br />
do_perfdata</p>
<p>if [ -n "$warning" -a -n "$critical" ]<br />
then<br />
    if [ "$wc_target" -ge "$warning" -a "$wc_target" -lt "$critical" ]<br />
    then<br />
        echo &#8220;WARNING &#8211; ${output} | ${perfdata}&#8221;<br />
        exit $ST_WR<br />
    elif [ "$wc_target" -ge "$critical" ]<br />
    then<br />
        echo &#8220;CRITICAL &#8211; ${output} | ${perfdata}&#8221;<br />
        exit $ST_CR<br />
    else<br />
        echo &#8220;OK &#8211; ${output} | ${perfdata}&#8221;<br />
        exit $ST_OK<br />
    fi<br />
else<br />
    echo &#8220;OK &#8211; ${output} | ${perfdata}&#8221;<br />
    exit $ST_OK<br />
fi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benedicte</title>
		<link>http://www.matejunkie.com/memory-check-plugin-for-nagios/comment-page-1/#comment-4094</link>
		<dc:creator>Benedicte</dc:creator>
		<pubDate>Fri, 10 Jul 2009 12:35:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.matejunkie.net//?p=752#comment-4094</guid>
		<description>Thanks a lot, it&#039;s perfect !</description>
		<content:encoded><![CDATA[<p>Thanks a lot, it&#8217;s perfect !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Adolphs</title>
		<link>http://www.matejunkie.com/memory-check-plugin-for-nagios/comment-page-1/#comment-3916</link>
		<dc:creator>Mike Adolphs</dc:creator>
		<pubDate>Tue, 23 Jun 2009 10:37:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.matejunkie.net//?p=752#comment-3916</guid>
		<description>Thanks Andrew, I just deleted the possibility to download the script since it&#039;ll be reworked at the beginning of July. This was one of the first checks I&#039;ve written and it could definitely use some improvements.
It&#039;ll then be uploaded to Nagios and MonitoringExchange afterwards where it can be downloaded as well.</description>
		<content:encoded><![CDATA[<p>Thanks Andrew, I just deleted the possibility to download the script since it&#8217;ll be reworked at the beginning of July. This was one of the first checks I&#8217;ve written and it could definitely use some improvements.<br />
It&#8217;ll then be uploaded to Nagios and MonitoringExchange afterwards where it can be downloaded as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Watkins</title>
		<link>http://www.matejunkie.com/memory-check-plugin-for-nagios/comment-page-1/#comment-3913</link>
		<dc:creator>Andrew Watkins</dc:creator>
		<pubDate>Mon, 22 Jun 2009 23:18:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.matejunkie.net//?p=752#comment-3913</guid>
		<description>the link ot hte scripts is broken, though I really like the script...</description>
		<content:encoded><![CDATA[<p>the link ot hte scripts is broken, though I really like the script&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
