<?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; icinga</title>
	<atom:link href="http://www.matejunkie.com/tag/icinga/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>howto: Let nginx serve the Nagios web-interface</title>
		<link>http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/</link>
		<comments>http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/#comments</comments>
		<pubDate>Thu, 21 May 2009 15:33:45 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[apache webserver]]></category>
		<category><![CDATA[fcgiwrap]]></category>
		<category><![CDATA[icinga]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[network monitoring]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[spawn_fcgi]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.matejunkie.com/?p=1045</guid>
		<description><![CDATA[For serving the Nagios web-interface it&#8217;s not necessary to run an Apache webserver. It also works quite well with others like lighttpd or nginx. Here&#8217;s how to configure nginx with basic auth so that Nagios knows who you are. Prerequisites Almost any package management system like apt pulls the Apache webserver as a dependency. I [...]]]></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" />For serving the <a title="Nagios - Official Website" href="http://www.nagios.org/" target="_blank">Nagios</a> web-interface it&#8217;s not necessary to run an Apache webserver. It also works quite well with others like <a title="Lighttpd - Official website" href="http://www.lighttpd.net/" target="_blank">lighttpd</a> or <a title="Nginx - Official website" href="http://nginx.net/" target="_blank">nginx</a>. Here&#8217;s how to configure nginx with basic auth so that Nagios knows who you are.</p>
<h3>Prerequisites</h3>
<p>Almost any package management system like apt pulls the Apache webserver as a dependency. I therefore strongly suggest you to compile and install Nagios manually since then you&#8217;ve got way more options to play with. Stick to the official documentation if you consider to do so. The following config files are all based on Nagios&#8217; default configure options.</p>
<h3>Get CGI going</h3>
<p>nginx isn&#8217;t capable to serve dynamic content by default. You have to send this through a wrapper like we did in the last <a title="Matejunkie - Howto nginx with php and passenger at once" href="http://www.matejunkie.com/howto-nginx-with-php-and-passenger-mod_rails-at-once/" target="_blank">howto to get PHP and Passenger going</a>. Therefore download a copy of the lighttpd source, unpack, configure and make it. Then copy the spawn-fcgi from the src directory to a local directory, e.g. /usr/bin:</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;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.lighttpd.net<span style="color: #000000; font-weight: bold;">/</span>download<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18.tar.bz2
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">tar</span> xvjf lighttpd-1.4.18.tar.bz2
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #7a0874; font-weight: bold;">cd</span> lighttpd-1.4.18<span style="color: #000000; font-weight: bold;">/</span>
user<span style="color: #000000; font-weight: bold;">@</span>host ~<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18 $ .<span style="color: #000000; font-weight: bold;">/</span>configure
user<span style="color: #000000; font-weight: bold;">@</span>host ~<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18 $ <span style="color: #c20cb9; font-weight: bold;">make</span>
user<span style="color: #000000; font-weight: bold;">@</span>host ~<span style="color: #000000; font-weight: bold;">/</span>lighttpd-1.4.18 $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> src<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi</pre></div></div>

<p>Then download the actual fcgiwrapper from github, unpack and make it. Afterwards copy the binary to a local directory, e.g. /usr/bin, 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;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>gnosek<span style="color: #000000; font-weight: bold;">/</span>fcgiwrap<span style="color: #000000; font-weight: bold;">/</span>tarball<span style="color: #000000; font-weight: bold;">/</span>master
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf gnosek-fcgiwrap-cdd6b8475744989940f9ce8322999e9ed4f0a6ec.tar.gz
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #7a0874; font-weight: bold;">cd</span> gnosek-fcgiwrap-cdd6b8475744989940f9ce8322999e9ed4f0a6ec<span style="color: #000000; font-weight: bold;">/</span>
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">make</span>
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> fcgiwrap <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> root:root <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>fcgiwrap</pre></div></div>

<p>Create a wrapper script to let the spawn-fcgi binary run a fcgiwrap instance and make it executable.</p>
<h4>/usr/bin/c-fcgi.sh</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>fcgiwrap <span style="color: #660033;">-a</span> 127.0.0.1 <span style="color: #660033;">-p</span> <span style="color: #000000;">49233</span> <span style="color: #660033;">-P</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>fastcgi-c.pid <span style="color: #660033;">-u</span> www-data <span style="color: #660033;">-g</span> www-data</pre></div></div>


<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;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>c-fcgi.sh</pre></div></div>

<p>You may also create an init script to let the spawner run the fcgiwrap instance during boot.</p>
<h4>/etc/init.d/c-fcgi</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">C_SCRIPT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>c-fcgi
<span style="color: #007800;">RETVAL</span>=<span style="color: #000000;">0</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>
	start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting fastcgi&quot;</span>
		<span style="color: #007800;">$C_SCRIPT</span>
		<span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
	stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping fastcgi&quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> fcgiwrap
		<span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
	restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Restarting fastcgi&quot;</span>
		<span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> fcgiwrap
		<span style="color: #007800;">$C_SCRIPT</span>
		<span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</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;Usage: c-fastcgi {start|stop|restart}&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</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;">exit</span> <span style="color: #007800;">$RETVAL</span></pre></div></div>

<p>Then start the spawner and put it in the default runlevel:</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;">sudo</span> update-rc.d c-fcgi defaults
user<span style="color: #000000; font-weight: bold;">@</span>host ~ $ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>c-fcgi start</pre></div></div>

<h3>Configuring nginx</h3>
<p>Assuming Nagios&#8217; static html files reside in /usr/local/nagios/share and its cgi&#8217;s in /usr/local/nagios/sbin the configuration for an nginx vhost looks like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">server <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	listen   <span style="color: #000000;">80</span>;
	server_name  www.example.com;
&nbsp;
	access_log  <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>example.com<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>access.log;
&nbsp;
	location <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
		root   <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>nagios<span style="color: #000000; font-weight: bold;">/</span>share;
		index  index.html;
&nbsp;
		rewrite	^<span style="color: #000000; font-weight: bold;">/</span>nagios<span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>\.png <span style="color: #000000; font-weight: bold;">/</span>images<span style="color: #000000; font-weight: bold;">/</span>$1.png <span style="color: #7a0874; font-weight: bold;">break</span>;
&nbsp;
		auth_basic		<span style="color: #ff0000;">&quot;Restricted&quot;</span>;
		auth_basic_user_file	conf<span style="color: #000000; font-weight: bold;">/</span>htpasswd;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
	location ~ \.cgi$ <span style="color: #7a0874; font-weight: bold;">&#123;</span>
		root	<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>nagios<span style="color: #000000; font-weight: bold;">/</span>sbin;
		rewrite	^<span style="color: #000000; font-weight: bold;">/</span>nagios<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>\.cgi <span style="color: #000000; font-weight: bold;">/</span>$1.cgi <span style="color: #7a0874; font-weight: bold;">break</span>;
&nbsp;
		include <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fastcgi_params;
&nbsp;
        	fastcgi_pass   127.0.0.1:<span style="color: #000000;">49233</span>;
	        fastcgi_param  SCRIPT_FILENAME  <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>nagios<span style="color: #007800;">$fastcgi_script_name</span>;  <span style="color: #666666; font-style: italic;"># same path as above</span>
&nbsp;
		auth_basic		<span style="color: #ff0000;">&quot;Restricted&quot;</span>;
		auth_basic_user_file	conf<span style="color: #000000; font-weight: bold;">/</span>htpasswd;
&nbsp;
		fastcgi_param  AUTH_USER          <span style="color: #007800;">$remote_user</span>;
		fastcgi_param  REMOTE_USER	  <span style="color: #007800;">$remote_user</span>;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Be sure to have the following fastcgi parameters configured in /etc/nginx/fastcgi_params.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">fastcgi_param  QUERY_STRING       <span style="color: #007800;">$query_string</span>;
fastcgi_param  REQUEST_METHOD     <span style="color: #007800;">$request_method</span>;
fastcgi_param  CONTENT_TYPE       <span style="color: #007800;">$content_type</span>;
fastcgi_param  CONTENT_LENGTH     <span style="color: #007800;">$content_length</span>;
&nbsp;
fastcgi_param  SCRIPT_NAME        <span style="color: #007800;">$fastcgi_script_name</span>;
fastcgi_param  REQUEST_URI        <span style="color: #007800;">$request_uri</span>;
fastcgi_param  DOCUMENT_URI       <span style="color: #007800;">$document_uri</span>;
fastcgi_param  DOCUMENT_ROOT      <span style="color: #007800;">$document_root</span>;
fastcgi_param  SERVER_PROTOCOL    <span style="color: #007800;">$server_protocol</span>;
&nbsp;
fastcgi_param  GATEWAY_INTERFACE  CGI<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.1</span>;
fastcgi_param  SERVER_SOFTWARE    nginx<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$nginx_version</span>;
&nbsp;
fastcgi_param  REMOTE_ADDR        <span style="color: #007800;">$remote_addr</span>;
fastcgi_param  REMOTE_PORT        <span style="color: #007800;">$remote_port</span>;
fastcgi_param  SERVER_ADDR        <span style="color: #007800;">$server_addr</span>;
fastcgi_param  SERVER_PORT        <span style="color: #007800;">$server_port</span>;
fastcgi_param  SERVER_NAME        <span style="color: #007800;">$server_name</span>;
&nbsp;
<span style="color: #666666; font-style: italic;"># PHP only, required if PHP was built with --enable-force-cgi-redirect</span>
<span style="color: #666666; font-style: italic;">#fastcgi_param  REDIRECT_STATUS    200;</span></pre></div></div>

<h3>Configuring Nagios</h3>
<p>In /usr/local/nagios/etc/cgi.cfg you should turn use_authentication on:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">use_authentication</span>=<span style="color: #000000;">1</span></pre></div></div>

<h3>Almost finished</h3>
<p>After starting Nagios via its init script and a reload of your nginx webserver. it should show you an authentification dialogue window when you point your browser to the server&#8217;s url. To get authentication going, you need to provide credentials in /etc/nginx/conf/htpasswd in the following format:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">user:password</pre></div></div>

<p><a href="http://www.matejunkie.com/wp-content/uploads/2009/05/icinga_service-detail.png"><img class="alignright size-thumbnail wp-image-1059" title="Icinga - Service detail" src="http://www.matejunkie.com/wp-content/uploads/2009/05/icinga_service-detail-150x150.png" alt="Icinga - Service detail" width="150" height="150" /></a>Note that the password must be encrypted, plain text in this file wouldn&#8217;t work (for good reasons). You may want to have an Apache webserver around to use the htpasswd binary for that or you could use a solution from the web like <a title="htaccesstools.com - htpasswd Generator" href="http://www.htaccesstools.com/htpasswd-generator/" target="_blank">the htpasswd generator</a>, but keep in mind that using a service in the web may cause security troubles.</p>
<p>That should do the job. You&#8217;re now able to access your Nagios web-interface via nginx with proper authentication.</p>
<p>This guide also works for <a title="Icinga - Official website" href="http://www.icinga.org/" target="_blank">Icinga</a>, a nice and shiny Nagios fork which came up two weeks ago. Simply change all names from nagios to icinga and you&#8217;re good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Update 1.1: UDP Packet Loss Check Plugin for Nagios</title>
		<link>http://www.matejunkie.com/update-11-udp-packet-loss-check-plugin-for-nagios/</link>
		<comments>http://www.matejunkie.com/update-11-udp-packet-loss-check-plugin-for-nagios/#comments</comments>
		<pubDate>Mon, 11 May 2009 09:36:39 +0000</pubDate>
		<dc:creator>Mike Adolphs</dc:creator>
				<category><![CDATA[Binary Talks]]></category>
		<category><![CDATA[gplv2]]></category>
		<category><![CDATA[icinga]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[netstat]]></category>
		<category><![CDATA[network monitoring]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[udp]]></category>

		<guid isPermaLink="false">http://www.matejunkie.com/?p=966</guid>
		<description><![CDATA[I&#8217;ve changed the small UDP packet loss script yesterday so that it&#8217;s now showing the total requests, requests sent to an unknown port and receive errors per check interval. That means, if you&#8217;d choose a check interval of 5 minutes, the script shows the amount of the previous mentioned for this time frame. It now [...]]]></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 changed the small UDP packet loss script yesterday so that it&#8217;s now showing the total requests, requests sent to an unknown port and receive errors per check interval. That means, if you&#8217;d choose a check interval of 5 minutes, the script shows the amount of the previous mentioned for this time frame. It now creates two temporary files in a directory which you may define via -t/&#8211;path-tmp. The file is automatically deleted when it&#8217;s size got over 32Kb.<br />
Feel free to grab it <a title="MonitoringExchange - check_udp-packet-loss.sh" href="http://www.monitoringexchange.org/cgi-bin/page.cgi?g=Detailed%2F3063.html" target="_blank">from MonitoringExchange</a> (they&#8217;ve changed their name due to legal problems with <a title="Nagios Enterprises" href="http://www.nagios.com/" target="_blank">Nagios Enterprises</a> and because of Nagios&#8217; <a title="Icinga" href="http://www.icinga.org/" target="_blank">new fork Icinga</a>), via svn or copy&#8217;n'paste below.</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_udp-packet-loss<span style="color: #000000; font-weight: bold;">/</span> check_udp-packet-loss<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.1,&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;">path_tmp</span>=<span style="color: #ff0000;">&quot;/tmp&quot;</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 the UDP packet&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;loss via netstat. It writes a temporary file to a configurable&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;directory and compares it's values against the ones from the check&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;before.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;That means the actual result shows the amount of overall packets,&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;received, receive errors and/or packets recieved to unknown port&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;for the last check interval you've chosen.&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> check_udp-packet-loss.sh&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;  --warning|-w)&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    Sets a warning level for packet receive errors. Default is:&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    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 packet receive errors. Default is:&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    off&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  --path-tmp|-t)&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    Sets the path for the temporary file. Default is: /tmp&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>
        --path-tmp<span style="color: #000000; font-weight: bold;">|</span>-t<span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #007800;">path_tmp</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;
check_filesize<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: #660033;">-f</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">size</span></span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$size</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">32</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
            <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
        <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
    <span style="color: #000000; font-weight: bold;">fi</span>   
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
get_packet_loss<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;">date_beg</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</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;">$date_beg</span> +++&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
    <span style="color: #c20cb9; font-weight: bold;">netstat</span> -us<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'packets received'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
    <span style="color: #c20cb9; font-weight: bold;">netstat</span> -us<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'to unknown port'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
    <span style="color: #c20cb9; font-weight: bold;">netstat</span> -us<span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'packet receive errors'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
	<span style="color: #007800;">date_end</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</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;">$date_end</span> ---&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log
	<span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>udp-errors.log <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'/---/{p=1} p{print} /+++/{p=0;if \
(count++==1) exit}'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log.tmp
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
chk_packet_loss<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;">p_receive_1st</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log.tmp <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;">'packets \
received'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">p_receive_2nd</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'packets \
received'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</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;">'packets received'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">p_unknown_1st</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log.tmp <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;">'to unknown \
port'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">p_unknown_2nd</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'to unknown \
port'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</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;">'to unknown port'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">p_errors_1st</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log.tmp <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;">'receive \
errors'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #007800;">p_errors_2nd</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">tac</span> <span style="color: #007800;">$path_tmp</span><span style="color: #000000; font-weight: bold;">/</span>udp-errors.log.tmp <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'receive errors'</span> \
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-r</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;">'receive errors'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$p_receive_2nd</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">p_receive</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$p_receive_2nd</span> - <span style="color: #007800;">$p_receive_1st</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">p_receive</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$p_unknown_2nd</span>&quot;</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">p_unknown</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$p_unknown_2nd</span> - <span style="color: #007800;">$p_unknown_1st</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">p_unknown</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$p_errors_2nd</span>&quot;</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">p_errors</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$p_errors_2nd</span> - <span style="color: #007800;">$p_errors_1st</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">p_errors</span>=<span style="color: #000000;">0</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</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;
check_filesize
get_packet_loss
chk_packet_loss
&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;The warning level should be lower than the critical level. <span style="color: #000099; font-weight: bold;">\
</span>Please adjust them.&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;
<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;">$p_unknown</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;">$p_unknown</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;">$p_receive</span> total packets received, <span style="color: #007800;">$p_unknown</span> \ 
went to unknown port, <span style="color: #007800;">$p_errors</span> receive errors! | <span style="color: #000099; font-weight: bold;">\
</span>'received'=<span style="color: #007800;">$p_receive</span> 'unknown_port'=<span style="color: #007800;">$p_unknown</span> 'errors'=<span style="color: #007800;">$p_errors</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;">$p_unknown</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;">$p_receive</span> total packets received, <span style="color: #007800;">$p_unknown</span> <span style="color: #000099; font-weight: bold;">\
</span>went to unknown port, <span style="color: #007800;">$p_errors</span> receive errors! | <span style="color: #000099; font-weight: bold;">\
</span>'received'=<span style="color: #007800;">$p_receive</span> 'unknown_port'=<span style="color: #007800;">$p_unknown</span> 'errors'=<span style="color: #007800;">$p_errors</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;">$p_receive</span> total packets received, <span style="color: #007800;">$p_unknown</span> <span style="color: #000099; font-weight: bold;">\
</span>went to unknown port, <span style="color: #007800;">$p_errors</span> receive errors! | <span style="color: #000099; font-weight: bold;">\
</span>'received'=<span style="color: #007800;">$p_receive</span> 'unknown_port'=<span style="color: #007800;">$p_unknown</span> 'errors'=<span style="color: #007800;">$p_errors</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;">$p_receive</span> total packets received, <span style="color: #007800;">$p_unknown</span> went to unknown <span style="color: #000099; font-weight: bold;">\
</span>port, <span style="color: #007800;">$p_errors</span> receive errors! | 'received'=<span style="color: #007800;">$p_receive</span> <span style="color: #000099; font-weight: bold;">\
</span>'unknown_port'=<span style="color: #007800;">$p_unknown</span> 'errors'=<span style="color: #007800;">$p_errors</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>

]]></content:encoded>
			<wfw:commentRss>http://www.matejunkie.com/update-11-udp-packet-loss-check-plugin-for-nagios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
