<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matejunkie &#187; pnp template</title>
	<atom:link href="http://www.matejunkie.com/tag/pnp-template/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matejunkie.com</link>
	<description>"Look behind you, a Three-Headed Monkey!"</description>
	<lastBuildDate>Thu, 07 Jan 2010 14:26:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PNP template for check_apache2.sh</title>
		<link>http://www.matejunkie.com/pnp-template-for-check_apache2-sh/</link>
		<comments>http://www.matejunkie.com/pnp-template-for-check_apache2-sh/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 20:07:52 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[apache webserver]]></category>
		<category><![CDATA[gplv2]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[network monitoring]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[pnp template]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.matejunkie.com/?p=1246</guid>
		<description><![CDATA[This is a PNP template which works quite well for me when there&#8217;s need to identify possible bottlenecks or unexpected behavior of the Apache webserver. It shows the CPU usage, req/sec, byte/req and the amount of busy/idle workers in a single graph. Feel free to copy the template from below or head over to Nagios [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.matejunkie.com/wp-content/uploads/2009/09/check_apache2.png"><img class="alignleft size-medium wp-image-1248" title="check_apache2 PNP Template" src="http://www.matejunkie.com/wp-content/uploads/2009/09/check_apache2-300x125.png" alt="check_apache2 PNP Template" width="180" height="75" /></a>This is a PNP template which works quite well for me when there&#8217;s need to identify possible bottlenecks or unexpected behavior of the Apache webserver. It shows the CPU usage, req/sec, byte/req and the amount of busy/idle workers in a single graph. Feel free to copy the template from below or head over <a href="http://exchange.nagios.org/directory/Plugins/Web-Servers/Apache/check_apache2-2Esh/details" title="Nagios Exchange - check_apache2.sh">to Nagios Exchange</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#   This program is free software; you can redistribute it and/or modify
</span><span style="color: #666666; font-style: italic;">#   it under the terms of the GNU General Public License as published by
</span><span style="color: #666666; font-style: italic;">#   the Free Software Foundation; either version 2 of the License, or
</span><span style="color: #666666; font-style: italic;">#   (at your option) any later version.
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#   This program is distributed in the hope that it will be useful,
</span><span style="color: #666666; font-style: italic;">#   but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style="color: #666666; font-style: italic;">#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</span><span style="color: #666666; font-style: italic;">#   GNU General Public License for more details.
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#   You should have received a copy of the GNU General Public License
</span><span style="color: #666666; font-style: italic;">#   along with this program; if not, write to the Free Software
</span><span style="color: #666666; font-style: italic;">#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
</span>
<span style="color: #666666; font-style: italic;">#   PNP Template for check_apache2.sh
</span><span style="color: #666666; font-style: italic;">#   Author: Mike Adolphs (http://www.matejunkie.com/)
</span>
<span style="color: #000088;">$opt</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;--vertical-label <span style="color: #000099; font-weight: bold;">\&quot;</span>Various stats <span style="color: #000099; font-weight: bold;">\&quot;</span> -l 0 -r --title <span style="color: #000099; font-weight: bold;">\&quot;</span>Apache metrics for <span style="color: #006699; font-weight: bold;">$hostname</span> / <span style="color: #006699; font-weight: bold;">$servicedesc</span><span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DEF:cpu=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[1]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;DEF:reqpsec=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[2]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;DEF:bytepreq=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[4]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;DEF:wbusy=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[5]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;DEF:widle=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[6]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$opt</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;--vertical-label <span style="color: #000099; font-weight: bold;">\&quot;</span>Byte/sec <span style="color: #000099; font-weight: bold;">\&quot;</span> -l 0 -r --title <span style="color: #000099; font-weight: bold;">\&quot;</span>Apache metrics for <span style="color: #006699; font-weight: bold;">$hostname</span> / <span style="color: #006699; font-weight: bold;">$servicedesc</span><span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;DEF:bytepsec=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[3]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;COMMENT:<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tLAST<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tAVERAGE<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tMAX<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:cpu#008000:<span style="color: #000099; font-weight: bold;">\&quot;</span>CPU usage [%]<span style="color: #000099; font-weight: bold;">\\</span>t <span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cpu:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cpu:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cpu:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:reqpsec#0C64E8:<span style="color: #000099; font-weight: bold;">\&quot;</span>Requests/sec<span style="color: #000099; font-weight: bold;">\\</span>t <span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:reqpsec:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:reqpsec:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:reqpsec:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:bytepreq#FFA500:<span style="color: #000099; font-weight: bold;">\&quot;</span>Byte/req<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t <span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:bytepreq:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:bytepreq:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:bytepreq:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:wbusy#1CC8E8:<span style="color: #000099; font-weight: bold;">\&quot;</span>Busy workers<span style="color: #000099; font-weight: bold;">\\</span>t <span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:wbusy:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:wbusy:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:wbusy:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:widle#E80C8C:<span style="color: #000099; font-weight: bold;">\&quot;</span>Idle workers<span style="color: #000099; font-weight: bold;">\\</span>t <span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:widle:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:widle:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:widle:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;COMMENT:<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tLAST<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tAVERAGE<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tMAX<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:bytepsec#E80C3E:<span style="color: #000099; font-weight: bold;">\&quot;</span>Byte/sec<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t <span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:bytepsec:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:bytepsec:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:bytepsec:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span> %6.0lf<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/pnp-template-for-check_apache2-sh/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PNP Template for Process Check Plugin</title>
		<link>http://www.matejunkie.com/pnp-template-for-process-check-plugin/</link>
		<comments>http://www.matejunkie.com/pnp-template-for-process-check-plugin/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 12:35:07 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[network monitoring]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[pnp template]]></category>
		<category><![CDATA[rrd]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.matejunkie.com/?p=1103</guid>
		<description><![CDATA[Just a short note: Here&#8217;s the appropriate PNP Template to the process check plugin which I&#8217;ve recently written to create nice and shiny graphs: # 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; [...]]]></description>
			<content:encoded><![CDATA[<p>Just a short note:<br />
Here&#8217;s the appropriate PNP Template to the <a title="Matejunkie - Process Check Plugin for Nagios" href="http://www.matejunkie.com/process-check-plugin-for-nagios/" target="_blank">process check plugin</a> which I&#8217;ve recently written to create nice and shiny graphs:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#   This program is free software; you can redistribute it and/or modify
</span><span style="color: #666666; font-style: italic;">#   it under the terms of the GNU General Public License as published by
</span><span style="color: #666666; font-style: italic;">#   the Free Software Foundation; either version 2 of the License, or
</span><span style="color: #666666; font-style: italic;">#   (at your option) any later version.
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#   This program is distributed in the hope that it will be useful,
</span><span style="color: #666666; font-style: italic;">#   but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style="color: #666666; font-style: italic;">#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</span><span style="color: #666666; font-style: italic;">#   GNU General Public License for more details.
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#   You should have received a copy of the GNU General Public License
</span><span style="color: #666666; font-style: italic;">#   along with this program; if not, write to the Free Software
</span><span style="color: #666666; font-style: italic;">#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
</span>
<span style="color: #666666; font-style: italic;">#   PNP Template for check_ps.sh
</span><span style="color: #666666; font-style: italic;">#   Author: Mike Adolphs (http://www.matejunkie.com/
</span>
<span style="color: #000088;">$opt</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;--vertical-label <span style="color: #000099; font-weight: bold;">\&quot;</span>percent<span style="color: #000099; font-weight: bold;">\&quot;</span> -u 100 -l 0 -r --title <span style="color: #000099; font-weight: bold;">\&quot;</span>CPU/Memory Usage for <span style="color: #006699; font-weight: bold;">$hostname</span> / <span style="color: #006699; font-weight: bold;">$servicedesc</span><span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$opt</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;--vertical-label <span style="color: #000099; font-weight: bold;">\&quot;</span>minutes<span style="color: #000099; font-weight: bold;">\&quot;</span> -u 100 -l 0 -r --title <span style="color: #000099; font-weight: bold;">\&quot;</span>cputime for <span style="color: #006699; font-weight: bold;">$hostname</span> / <span style="color: #006699; font-weight: bold;">$servicedesc</span><span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">&quot;DEF:cpu=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[1]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:memory=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[2]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:cputime=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[3]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;COMMENT:<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tLAST<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tAVERAGE<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tMAX<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;COMMENT:<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tLAST<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tAVERAGE<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tMAX<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:cpu#E80C3E:<span style="color: #000099; font-weight: bold;">\&quot;</span>CPU<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cpu:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cpu:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cpu:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;LINE2:memory#008000:<span style="color: #000099; font-weight: bold;">\&quot;</span>Memory<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:memory:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:memory:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:memory:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:cputime#E80C3E:<span style="color: #000099; font-weight: bold;">\&quot;</span>CPUTime<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cputime:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf min<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cputime:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf min<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:cputime:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf min<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/pnp-template-for-process-check-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CPU check plugin for Nagios</title>
		<link>http://www.matejunkie.com/cpu-check-plugin-for-nagios/</link>
		<comments>http://www.matejunkie.com/cpu-check-plugin-for-nagios/#comments</comments>
		<pubDate>Wed, 13 May 2009 10:48:13 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[gplv2]]></category>
		<category><![CDATA[jiffies]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[network monitoring]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[pnp template]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.matejunkie.com/?p=970</guid>
		<description><![CDATA[I&#8217;ve just finished version 1.0 of a CPU check plugin which is sh-compliant (as always) and calculates utilization through Jiffies rather than using another third party tool like iostat or top. This means it should work on all Linux machines right out of the box without the need to install additional software. Frankly speaking the [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-193" title="logo_nagios" src="http://www.matejunkie.com/wp-content/uploads/2008/05/logo_nagios.gif" alt="logo_nagios" width="150" height="40" />I&#8217;ve just finished version 1.0 of a CPU check plugin which is sh-compliant (as always) and calculates utilization <a title="Wikipedia - Jiffy" href="http://en.wikipedia.org/wiki/Jiffy_(time)#Use_in_computing" target="_blank">through Jiffies</a> rather than using another third party tool like iostat or top. This means it should work on all Linux machines right out of the box without the need to install additional software.<br />
<a href="http://www.matejunkie.com/wp-content/uploads/2009/05/check_cpu_example01.png"><img class="alignright size-thumbnail wp-image-972" title="check_cpu_example01" src="http://www.matejunkie.com/wp-content/uploads/2009/05/check_cpu_example01-150x150.png" alt="check_cpu_example01" width="150" height="150" /></a>Frankly speaking the performance of the script is slightly worse than the performance of most of the other CPU check plugins due to the sacrifice of parsing iostat or top output, but I nevertheless wanted to do this since calculating CPU utilization through Jiffies instead of parsing another tool&#8217;s output is somewhat different and interesting. I didn&#8217;t take a look into iostat&#8217;s or top&#8217;s source code yet, but I guess these tools doesn&#8217;t do it in another way than parsing /proc/stat as well. The difference in performance isn&#8217;t that huge anyway, a double-digit amount of milliseconds, but not more.</p>
<p>For getting along with the Jiffies, I crawled through the web, especially <a title="Paul Colby's weblog - Calculating cpu utilization via /proc/stat" href="http://colby.id.au/node/39" target="_blank">Paul Colby&#8217;s article</a> about calculating CPU utilization through /proc/stat helped a lot!</p>
<h3>The script</h3>
<p>As always, the script is downloadable <a title="Nagiosexchange - check_cpu.sh" href="http://www.monitoringexchange.org/cgi-bin/page.cgi?g=Detailed%2F3077.html" target="_blank">from NagiosExchange</a>, via svn directly from here or the copy&#8217;n'paste way below. A proper PNP template is included as well.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> https:<span style="color: #000000; font-weight: bold;">//</span>svn.matejunkie.com<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>nagios-plugins<span style="color: #000000; font-weight: bold;">/</span>stable<span style="color: #000000; font-weight: bold;">/</span>check_cpu<span style="color: #000000; font-weight: bold;">/</span> check_cpu<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#   This program is free software; you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;">#   it under the terms of the GNU General Public License as published by</span>
<span style="color: #666666; font-style: italic;">#   the Free Software Foundation; either version 2 of the License, or</span>
<span style="color: #666666; font-style: italic;">#   (at your option) any later version.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;">#   but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;">#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;">#   GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   You should have received a copy of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;">#   along with this program; if not, write to the Free Software</span>
<span style="color: #666666; font-style: italic;">#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</span>
&nbsp;
<span style="color: #007800;">PROGNAME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> $<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">VERSION</span>=<span style="color: #ff0000;">&quot;Version 1.0,&quot;</span>
<span style="color: #007800;">AUTHOR</span>=<span style="color: #ff0000;">&quot;2009, Mike Adolphs (http://www.matejunkie.com/)&quot;</span>
&nbsp;
<span style="color: #007800;">ST_OK</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">ST_WR</span>=<span style="color: #000000;">1</span>
<span style="color: #007800;">ST_CR</span>=<span style="color: #000000;">2</span>
<span style="color: #007800;">ST_UK</span>=<span style="color: #000000;">3</span>
&nbsp;
<span style="color: #007800;">interval</span>=<span style="color: #000000;">1</span>
&nbsp;
print_version<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VERSION</span> <span style="color: #007800;">$AUTHOR</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
print_help<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    print_version <span style="color: #007800;">$PROGNAME</span> <span style="color: #007800;">$VERSION</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PROGNAME</span> is a Nagios plugin to monitor CPU utilization. It makes&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;use of /proc/stat and calculates it through Jiffies rather than&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;using another frontend tool like iostat or top.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;When using optional warning/critical thresholds all values except&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;idle are aggregated and compared to the thresholds. There's&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;currently no support for warning/critical thresholds for specific&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage parameters.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$PROGNAME</span> [-i/--interval] [-w/--warning] [-c/--critical]&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Options:&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  --interval|-i)&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    Defines the pause between the two times /proc/stat is being&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    parsed. Higher values could lead to more accurate result.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    Default is: 1 second&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  --warning|-w)&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    Sets a warning level for CPU user. Default is: off&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  --critical|-c)&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    Sets a critical level for CPU user. Default is: off&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_UK</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;$1&quot;</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
        --help<span style="color: #000000; font-weight: bold;">|</span>-h<span style="color: #7a0874; font-weight: bold;">&#41;</span>
            print_help
            <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_UK</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        --version<span style="color: #000000; font-weight: bold;">|</span>-v<span style="color: #7a0874; font-weight: bold;">&#41;</span>
            print_version <span style="color: #007800;">$PROGNAME</span> <span style="color: #007800;">$VERSION</span>
            <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_UK</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        --interval<span style="color: #000000; font-weight: bold;">|</span>-i<span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #007800;">interval</span>=$<span style="color: #000000;">2</span>
            <span style="color: #7a0874; font-weight: bold;">shift</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        --warning<span style="color: #000000; font-weight: bold;">|</span>-w<span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #007800;">warn</span>=$<span style="color: #000000;">2</span>
            <span style="color: #7a0874; font-weight: bold;">shift</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        --critical<span style="color: #000000; font-weight: bold;">|</span>-c<span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #007800;">crit</span>=$<span style="color: #000000;">2</span>
            <span style="color: #7a0874; font-weight: bold;">shift</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown argument: $1&quot;</span>
            print_help
            <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_UK</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">esac</span>
    <span style="color: #7a0874; font-weight: bold;">shift</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
val_wcdiff<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${warn}</span> <span style="color: #660033;">-gt</span> <span style="color: #800000;">${crit}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">wcdiff</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
get_cpuvals<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">tmp1_cpu_user</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp1_cpu_nice</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp1_cpu_sys</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp1_cpu_idle</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $5}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp1_cpu_iowait</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $6}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp1_cpu_irq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $7}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp1_cpu_softirq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $8}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp1_cpu_total</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$tmp1_cpu_user</span> + <span style="color: #007800;">$tmp1_cpu_nice</span> + <span style="color: #007800;">$tmp1_cpu_sys</span> + \
<span style="color: #007800;">$tmp1_cpu_idle</span> + <span style="color: #007800;">$tmp1_cpu_iowait</span> + <span style="color: #007800;">$tmp1_cpu_irq</span> + <span style="color: #007800;">$tmp1_cpu_softirq</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #007800;">$interval</span>
&nbsp;
    <span style="color: #007800;">tmp2_cpu_user</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp2_cpu_nice</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp2_cpu_sys</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $4}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp2_cpu_idle</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $5}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp2_cpu_iowait</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $6}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp2_cpu_irq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $7}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp2_cpu_softirq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-m1</span> <span style="color: #ff0000;">'^cpu'</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">stat</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $8}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">tmp2_cpu_total</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$tmp2_cpu_user</span> + <span style="color: #007800;">$tmp2_cpu_nice</span> + <span style="color: #007800;">$tmp2_cpu_sys</span> + \
<span style="color: #007800;">$tmp2_cpu_idle</span> + <span style="color: #007800;">$tmp2_cpu_iowait</span> + <span style="color: #007800;">$tmp2_cpu_irq</span> + <span style="color: #007800;">$tmp2_cpu_softirq</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #007800;">diff_cpu_user</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_user}</span> - <span style="color: #007800;">${tmp1_cpu_user}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">diff_cpu_nice</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_nice}</span> - <span style="color: #007800;">${tmp1_cpu_nice}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">diff_cpu_sys</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_sys}</span> - <span style="color: #007800;">${tmp1_cpu_sys}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">diff_cpu_idle</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_idle}</span> - <span style="color: #007800;">${tmp1_cpu_idle}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">diff_cpu_iowait</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_iowait}</span> - <span style="color: #007800;">${tmp1_cpu_iowait}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">diff_cpu_irq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_irq}</span> - <span style="color: #007800;">${tmp1_cpu_irq}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">diff_cpu_softirq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_softirq}</span> - <span style="color: #007800;">${tmp1_cpu_softirq}</span>&quot;</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">diff_cpu_total</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${tmp2_cpu_total}</span> - <span style="color: #007800;">${tmp1_cpu_total}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
    <span style="color: #007800;">cpu_user</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_user}</span>/<span style="color: #007800;">${diff_cpu_total}</span>+5)/10&quot;</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_nice</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_nice}</span>/<span style="color: #007800;">${diff_cpu_total}</span>+5)/10&quot;</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_sys</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_sys}</span>/<span style="color: #007800;">${diff_cpu_total}</span>+5)/10&quot;</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_idle</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_idle}</span>/<span style="color: #007800;">${diff_cpu_total}</span>+5)/10&quot;</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_iowait</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_iowait}</span>/<span style="color: #007800;">${diff_cpu_total}</span>+5)\<span style="color: #000099; font-weight: bold;">\
</span>/10&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_irq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_irq}</span>/<span style="color: #007800;">${diff_cpu_total}</span>+5)/10&quot;</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_softirq</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_softirq}</span>/<span style="color: #007800;">${diff_cpu_total}</span>\<span style="color: #000099; font-weight: bold;">\
</span>+5)/10&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_total</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;scale=2; (1000*<span style="color: #007800;">${diff_cpu_total}</span>/<span style="color: #007800;">${diff_cpu_total}</span>+5)\<span style="color: #000099; font-weight: bold;">\
</span>/10&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/^\./0./'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #007800;">cpu_usage</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;(<span style="color: #007800;">${cpu_user}</span>+<span style="color: #007800;">${cpu_nice}</span>+<span style="color: #007800;">${cpu_sys}</span>+<span style="color: #007800;">${cpu_iowait}</span>+\<span style="color: #000099; font-weight: bold;">\
</span><span style="color: #007800;">${cpu_irq}</span>+<span style="color: #007800;">${cpu_softirq}</span>)/1&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">bc</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
do_output<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">output</span>=<span style="color: #ff0000;">&quot;user: <span style="color: #007800;">${cpu_user}</span>, nice: <span style="color: #007800;">${cpu_nice}</span>, sys: <span style="color: #007800;">${cpu_sys}</span>, <span style="color: #000099; font-weight: bold;">\
</span>iowait: <span style="color: #007800;">${cpu_iowait}</span>, irq: <span style="color: #007800;">${cpu_irq}</span>, softirq: <span style="color: #007800;">${cpu_softirq}</span> <span style="color: #000099; font-weight: bold;">\
</span>idle: <span style="color: #007800;">${cpu_idle}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
do_perfdata<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">perfdata</span>=<span style="color: #ff0000;">&quot;'user'=<span style="color: #007800;">${cpu_user}</span> 'nice'=<span style="color: #007800;">${cpu_nice}</span> 'sys'=<span style="color: #007800;">${cpu_sys}</span> <span style="color: #000099; font-weight: bold;">\
</span>'softirq'=<span style="color: #007800;">${cpu_softirq}</span> 'iowait'=<span style="color: #007800;">${cpu_iowait}</span> 'irq'=<span style="color: #007800;">${cpu_irq}</span> <span style="color: #000099; font-weight: bold;">\
</span>'idle'=<span style="color: #007800;">${cpu_idle}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$warn</span>&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$crit</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    val_wcdiff
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$wcdiff</span>&quot;</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Please adjust your warning/critical thresholds. The warning\<span style="color: #000099; font-weight: bold;">\
</span>must be lower than the critical level!&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_UK</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
get_cpuvals
do_output
do_perfdata
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$warn</span>&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$crit</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$cpu_usage</span>&quot;</span> <span style="color: #660033;">-ge</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$warn</span>&quot;</span> <span style="color: #660033;">-a</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$cpu_usage</span>&quot;</span> <span style="color: #660033;">-lt</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$crit</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;WARNING - <span style="color: #007800;">${output}</span> | <span style="color: #007800;">${perfdata}</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_WR</span>
    <span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$cpu_usage</span>&quot;</span> <span style="color: #660033;">-ge</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$crit</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;CRITICAL - <span style="color: #007800;">${output}</span> | <span style="color: #007800;">${perfdata}</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_CR</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;OK - <span style="color: #007800;">${output}</span> | <span style="color: #007800;">${perfdata}</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_OK</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;OK - <span style="color: #007800;">${output}</span> | <span style="color: #007800;">${perfdata}</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$ST_OK</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#   This program is free software; you can redistribute it and/or modify
</span><span style="color: #666666; font-style: italic;">#   it under the terms of the GNU General Public License as published by
</span><span style="color: #666666; font-style: italic;">#   the Free Software Foundation; either version 2 of the License, or
</span><span style="color: #666666; font-style: italic;">#   (at your option) any later version.
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#   This program is distributed in the hope that it will be useful,
</span><span style="color: #666666; font-style: italic;">#   but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span style="color: #666666; font-style: italic;">#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</span><span style="color: #666666; font-style: italic;">#   GNU General Public License for more details.
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;">#   You should have received a copy of the GNU General Public License
</span><span style="color: #666666; font-style: italic;">#   along with this program; if not, write to the Free Software
</span><span style="color: #666666; font-style: italic;">#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
</span>
<span style="color: #666666; font-style: italic;">#   PNP Template for check_cpu.sh
</span><span style="color: #666666; font-style: italic;">#   Author: Mike Adolphs (http://www.matejunkie.com/
</span>
<span style="color: #000088;">$opt</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;--vertical-label <span style="color: #000099; font-weight: bold;">\&quot;</span>CPU [%]<span style="color: #000099; font-weight: bold;">\&quot;</span> -u 100 -l 0 -r --title <span style="color: #000099; font-weight: bold;">\&quot;</span>CPU Usage for <span style="color: #006699; font-weight: bold;">$hostname</span> / <span style="color: #006699; font-weight: bold;">$servicedesc</span><span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>  <span style="color: #0000ff;">&quot;DEF:used=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[1]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:nice=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[2]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:sys=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[3]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:iowait=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[4]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:irq=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[5]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:softirq=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[6]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">&quot;DEF:idle=<span style="color: #006699; font-weight: bold;">$rrdfile</span>:<span style="color: #006699; font-weight: bold;">$DS[7]</span>:AVERAGE &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;COMMENT:<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tLAST<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tAVERAGE<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>tMAX<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:used#E80C3E:<span style="color: #000099; font-weight: bold;">\&quot;</span>user<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span>:STACK &quot;</span> <span style="color: #339933;">;</span> 
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:used:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:used:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:used:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:nice#E8630C:<span style="color: #000099; font-weight: bold;">\&quot;</span>nice<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span>:STACK &quot;</span> <span style="color: #339933;">;</span> 
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:nice:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:nice:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:nice:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:sys#008000:<span style="color: #000099; font-weight: bold;">\&quot;</span>sys<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\&quot;</span>:STACK &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:sys:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:sys:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:sys:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:iowait#0CE84D:<span style="color: #000099; font-weight: bold;">\&quot;</span>iowait<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span>:STACK &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:iowait:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:iowait:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:iowait:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:irq#3E00FF:<span style="color: #000099; font-weight: bold;">\&quot;</span>irq<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\&quot;</span>:STACK &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:irq:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:irq:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:irq:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:softirq#1CC8E8:<span style="color: #000099; font-weight: bold;">\&quot;</span>softirq<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span>:STACK &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:softirq:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:softirq:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:softirq:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AREA:idle#FFFF00:<span style="color: #000099; font-weight: bold;">\&quot;</span>idle<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span>:STACK &quot;</span> <span style="color: #339933;">;</span> 
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:idle:LAST:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #009933; font-weight: bold;">%%</span><span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:idle:AVERAGE:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\\</span>t<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$def</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;GPRINT:idle:MAX:<span style="color: #000099; font-weight: bold;">\&quot;</span>%6.2lf <span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\&quot;</span> &quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>The License</h3>
<p><a href="http://www.matejunkie.com/wp-content/uploads/2009/05/check_cpu_example02.png"><img class="alignright size-thumbnail wp-image-973" title="check_cpu_example02" src="http://www.matejunkie.com/wp-content/uploads/2009/05/check_cpu_example02-150x150.png" alt="check_cpu_example02" width="150" height="150" /></a>As always this little script is ment to be sh-compliant and released under the terms of the GPL Version 2 only. Feel free to subscribe via rss to get updates on this one. More options will be added in the future.<br />
I&#8217;ll probably add an option to make use of iostat or top and to calculate utilization per CPU soon so that you&#8217;re able to choose your own way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/cpu-check-plugin-for-nagios/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
