<?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>Difficiles Nugae Labs</title>
	<atom:link href="http://www.nic-nac-project.de/~jose/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nic-nac-project.de/~jose</link>
	<description>mainly unuseful technical notes</description>
	<lastBuildDate>Wed, 25 Jan 2012 10:46:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>NO_PUBKEY error in apt-get update</title>
		<link>http://www.nic-nac-project.de/~jose/260/notes/no_pubkey-error-in-apt-get-update/</link>
		<comments>http://www.nic-nac-project.de/~jose/260/notes/no_pubkey-error-in-apt-get-update/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 10:39:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[debian]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=260</guid>
		<description><![CDATA[After editing Your /etc/apt/sources.list file, probably you will get a warning message in the output of the apt-get update command. The warning message will be like this: W: GPG error: http://ppa.launchpad.net natty Release: The following signatures couldn&#8217;t be verified because the public key is not available: NO_PUBKEY E9DDA5AAC586799E You can remove this message in two [...]]]></description>
			<content:encoded><![CDATA[<p>After editing Your /etc/apt/sources.list file, probably you will get a warning message in the output of the <em>apt-get update</em> command. The warning message will be like this:</p>
<blockquote><p><em>W: GPG error: http://ppa.launchpad.net natty Release: The following signatures couldn&#8217;t be verified because the public key is not available: NO_PUBKEY E9DDA5AAC586799E</em></p>
</blockquote>
<p>You can remove this message in two step: </p>
<blockquote><p><em>root@myhost:~# gpg &#8212;-keyserver pgpkeys.mit.edu &#8212;-recv-key 2E2BCDBCB38A8516</p>
<p>gpg: requesting key B38A8516 from hkp server pgpkeys.mit.edu</p>
<p>gpg: /root/.gnupg/trustdb.gpg: trustdb created</p>
<p>gpg: key B38A8516: public key &#8220;Oracle OSS group (Open Source Software group) <build@oss.oracle.com>&#8221; imported</p>
<p>gpg: Total number processed: 1</p>
<p>gpg:               imported: 1</p>
<p>root@myhost:~# gpg -a &#8212;-export 2E2BCDBCB38A8516 | sudo apt-key add -</p>
<p>OK</em></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/260/notes/no_pubkey-error-in-apt-get-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>winexe to interact from linux to windows hosts</title>
		<link>http://www.nic-nac-project.de/~jose/254/notes/winexe-to-interact-from-linux-to-windows-hosts/</link>
		<comments>http://www.nic-nac-project.de/~jose/254/notes/winexe-to-interact-from-linux-to-windows-hosts/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 11:01:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[winexe]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=254</guid>
		<description><![CDATA[With pstools You can run any command from your Windows PC to any other one. A valid command line alternative to pstools for the linux operating system is winexe. To install winexe un a natty-ubuntu host (maybe it will work on a quite new debian too), You can add theese twho lines to your sources.list [...]]]></description>
			<content:encoded><![CDATA[<p>With <a href="http://pstools.en.softonic.com/">pstools</a> You can run any command from your Windows PC to any other one. A valid command line alternative to pstools for the linux operating system is <strong>winexe</strong>.</p>
<p>To install winexe un a natty-ubuntu host (maybe it will work on a quite new debian too), You can add theese twho lines to your sources.list file:</p>
<blockquote><p><em>deb http://ppa.launchpad.net/jdthood/winexe/ubuntu natty main</p>
<p>deb-src http://ppa.launchpad.net/jdthood/winexe/ubuntu natty main</em></p>
</blockquote>
<p>then</p>
<blockquote><p><em>apt-get update &#038;&#038; apt-get install winexe</em></p></blockquote>
<p>Once installed winexe, you can do useful things like</p>
<blockquote><p><em>winexe //myserver1 &#8211;user &#8220;DOMAIN\\user&#8221; &#8220;tasklist /FI \&#8221;CPUTIME gt 00:00:10\&#8221;"</em></p>
</blockquote>
<p>or simply</p>
<blockquote><p><em>winexe //myserver2 &#8211;user &#8220;Administrator&#8221; cmd</em></p>
</blockquote>
<p>and many others! <img src='http://www.nic-nac-project.de/~jose/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/254/notes/winexe-to-interact-from-linux-to-windows-hosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shrew, an alternative to Cisco VPN Client</title>
		<link>http://www.nic-nac-project.de/~jose/241/notes/shrew-an-alternative-to-cisco-vpn-client/</link>
		<comments>http://www.nic-nac-project.de/~jose/241/notes/shrew-an-alternative-to-cisco-vpn-client/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 16:50:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[shrew]]></category>
		<category><![CDATA[vpn]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=241</guid>
		<description><![CDATA[Recently I had to install an IPsec Remote Access VPN client on a Windows7 64-bit system. If You are looking for an alternative to the usual Cisco client, in my opinion shrew is a good alternative. You can download the client software for free (obviously donations are welcome). Yesterday I get the error &#8220;session terminated [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had to install an IPsec Remote Access VPN client on a Windows7 64-bit system.</p>
<p>If You are looking for an alternative to the usual Cisco client, in my opinion <strong>shrew</strong> is a good alternative. You can <a href="http://www.shrew.net/download">download the client software</a> for free (obviously donations are welcome).</p>
<p>Yesterday I get the error <br />
<em>&#8220;session terminated by the gateway&#8221;</em><br />
and my end-point logged a<br />
<br /><em>&#8220;Mismatch: Overriding phase 2 DH Group(DH group 0) with phase 1 group(DH group 2)&#8221;</em><br />
<br />after giving my username/password<br />
<img src="http://www.nic-nac-project.de/~jose/wp-content/uploads/2011/11/error_session_terminated.png" alt="" title="error_session_terminated" width="296" height="290" class="aligncenter size-full wp-image-244" /><br />
I solved this issue setting to &#8220;group 2&#8243; the Phase 2->PFS exchange value in my settings.</p>
<p><img src="http://www.nic-nac-project.de/~jose/wp-content/uploads/2011/11/err_session_terminated_solved-249x300.png" alt="" title="err_session_terminated_solved" width="249" height="300" class="aligncenter size-medium wp-image-242" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/241/notes/shrew-an-alternative-to-cisco-vpn-client/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DHCP available address value monitored with nagios</title>
		<link>http://www.nic-nac-project.de/~jose/233/notes/dhcp-available-address-value-monitored-with-nagios/</link>
		<comments>http://www.nic-nac-project.de/~jose/233/notes/dhcp-available-address-value-monitored-with-nagios/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 11:55:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[dhcp]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[NSCLient++]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=233</guid>
		<description><![CDATA[I have a DHCP server that sometime has no free IP addresses to assign. What can I do to monitor how many IP are still available? Well, perl and NSClient++ installed on my Micro$oft DHCP server, I wrote a simple program to execute and parse the command netsh dhcp server show mibinfo that gives some [...]]]></description>
			<content:encoded><![CDATA[<p>I have a DHCP server that sometime has no free IP addresses to assign. What can I do to monitor how many IP are still available?</p>
<p>Well, perl and NSClient++ installed on my Micro$oft DHCP server, I wrote a simple program to execute and parse the command</p>
<blockquote><p><em>netsh dhcp server show mibinfo</em></p>
</blockquote>
<p>that gives some output containing the data I need. The source is quite simple: it assume the DHCP server is on a 10.20.x.y network and prints a list of comma separated numbers: the network (30 means 10.20.30.0/24), the assigned address number, the free address number.</p>
<blockquote><p><em>#!/bin/perl</em><br />
<em> # the output will be a list like this:</em><br />
<em> #       (30,74,95) (31,139,7) (32,110,1)</em></p>
<p><em>$mystr=&#8221;";</em><br />
<em> @myoutput=`netsh dhcp server show mibinfo`;</em><br />
<em> foreach $myrow (@myoutput) {</em><br />
<em> if ( $myrow =~ /Subnet = 10\.20\.(.*)\.0\./ ) {</em><br />
<em> $mystr = $mystr . &#8220;($1,&#8221;;</em><br />
<em> }</em><br />
<em> if ( $myrow =~ /(.*) Addresses in use = (.*)\./ ) {</em><br />
<em> $mystr = $mystr . &#8220;$2,&#8221;;</em><br />
<em> }</em><br />
<em> if ( $myrow =~ /(.*) free Addresses = (.*)\./ ) {</em><br />
<em> $mystr = $mystr . &#8220;$2) &#8220;;</em><br />
<em> }</em><br />
<em> }</em><br />
<em> print &#8220;$mystr&#8221;;</em></p>
</blockquote>
<p>Then I needed to add this line to the nsc.ini file, in order to run my perl script remotely</p>
<blockquote><p><em>check_dhcp=C:\NSClient++\scripts\check_dhcp.pl</em></p>
</blockquote>
<p>Once restarted the NSClient service, from my nagios server it&#8217;s possible to get the result from command line:</p>
<blockquote><p><em>$ /usr/lib/nagios/plugins/check_nrpe -H myserverdhcp -c check_dhcp</em><br />
<em>(31,75,94) (32,144,2) (33,111,0)</em></p>
</blockquote>
<p>A simple bash script plugin can be written to parse the result and getting nagios able to monitor the DHCP free address number value. E.g. this</p>
<blockquote><p><em>#!/bin/bash</em><br />
<em>MYHOST=$1</em><br />
<em>MYNET=$2</em><br />
<em>ThresholdWARN=$3</em><br />
<em>ThresholdCRIT=$4</em><br />
<em># Return values</em><br />
<em>RET_OK=&#8221;0&#8243;</em><br />
<em>RET_WARN=&#8221;1&#8243;</em><br />
<em>RET_CRIT=&#8221;2&#8243;</em><br />
<em>RET_UNKN=&#8221;3&#8243;</em></p>
<p><em>checkdata () {</em><br />
<em> VAL=`echo $2 | wc | awk &#8216;{print $2}&#8217;`</em><br />
<em> if [ $VAL -eq 0 ]; then</em><br />
<em> echo $1 is not set</em><br />
<em> exit $RET_UNKN</em><br />
<em> fi</em><br />
<em>}</em></p>
<p><em># MAIN</em><br />
<em>checkdata &#8220;Remote IP&#8221; $MYHOST</em><br />
<em>checkdata &#8220;Network number&#8221; $MYNET</em><br />
<em>checkdata &#8220;Threshold WARN&#8221; $ThresholdWARN</em><br />
<em>checkdata &#8220;Threshold CRIT&#8221; $ThresholdCRIT</em></p>
<p><em>MYRETSTRING=`/usr/lib/nagios/plugins/check_nrpe -H $MYHOST -c check_dhcp`</em><br />
<em>MYFREEADDR=`echo $MYRETSTRING | sed -e &#8220;s/.*($MYNET,//&#8221; | sed -e &#8220;s/).*//&#8221; | sed -e &#8220;s/.*,//&#8221;`</em><br />
<em>checkdata &#8220;IP number&#8221; $MYFREEADDR</em></p>
<p><em>EXTRAMESSG=&#8221;|&#8217;DHCPfreeAddr&#8217;=$MYFREEADDR$MYNET&#8221;";$ThresholdWARN;$ThresholdCRIT&#8221;</em><br />
<em>if [ $MYFREEADDR -lt $ThresholdCRIT ]; then</em><br />
<em> echo &#8220;CRITICAL &#8211; Only $MYFREEADDR IP Available for $MYNET network$EXTRAMESSG&#8221;</em><br />
<em> exit $RET_CRIT</em><br />
<em>fi</em><br />
<em>if [ $MYFREEADDR -lt $ThresholdWARN ]; then</em><br />
<em> echo &#8220;WARNING &#8211; Only $MYFREEADDR IP Available for $MYNET network$EXTRAMESSG&#8221;</em><br />
<em> exit $RET_WARN</em><br />
<em>fi</em><br />
<em>echo &#8220;OK &#8211; $MYFREEADDR IP Available for $MYNET network$EXTRAMESSG&#8221;</em><br />
<em>exit $RET_OK</em></p>
</blockquote>
<p>Then nagios has to be set up with the usual lines in the command configuration file</p>
<blockquote><p><em>define command{</em><br />
<em> command_name check_nt_dhcp</em><br />
<em> command_line /usr/lib/nagios/plugins/check_nt_dhcp.sh $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$</em></p>
</blockquote>
<p>And in the services file:</p>
<blockquote><p><em>define service{</em><br />
<em> use                             generic-service         ; Name of service template to use</em></p>
<p><em> host_name                       dhcpserver</em><br />
<em> service_description             Free IP on 10.20.33.0</em> network<br />
<em> is_volatile                     0</em><br />
<em> check_period                    24&#215;7</em><br />
<em> max_check_attempts              10</em><br />
<em> normal_check_interval           30</em><br />
<em> retry_check_interval            30</em><br />
<em> contact_groups                  admins</em><br />
<em> notification_interval           240</em><br />
<em> notification_period             24&#215;7</em><br />
<em> notification_options            c,r</em><br />
<em> check_command                   check_nt_dhcp!33!10!5</em><br />
<em> }</em></p>
</blockquote>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/233/notes/dhcp-available-address-value-monitored-with-nagios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to mount a windows share under AIX</title>
		<link>http://www.nic-nac-project.de/~jose/229/notes/how-to-mount-a-windows-share-under-aix/</link>
		<comments>http://www.nic-nac-project.de/~jose/229/notes/how-to-mount-a-windows-share-under-aix/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 13:27:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[aix]]></category>
		<category><![CDATA[samba]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=229</guid>
		<description><![CDATA[To mount a windows share from an AIX server it&#8217;s needed the CIFS support to be installed. If Your server /sbin/helpers directory contains a file called mount_cifs no problem ls -l /sbin/helpers total 488 -r-xr-xr-x    1 root     system        33198 Jul 13 2010  aufsmnthelp drwxrwxr-x    2 root     system         4096 Apr 15 2010  jfs2 -r-xr-xr-x    1 root     [...]]]></description>
			<content:encoded><![CDATA[<p>To mount a windows share from an AIX server it&#8217;s needed the CIFS support to be installed.</p>
<p>If Your server /sbin/helpers directory contains a file called mount_cifs no problem</p>
<blockquote><p><em>ls -l /sbin/helpers</em><br />
<em>total 488</em><br />
<em>-r-xr-xr-x    1 root     system        33198 Jul 13 2010  aufsmnthelp</em><br />
<em>drwxrwxr-x    2 root     system         4096 Apr 15 2010  jfs2</em><br />
<strong><em>-r-xr-xr-x    1 root     system        23224 Jul 13 2010  mount_cifs</em></strong><br />
<em>-r-xr-xr-x    1 root     system        35638 Jul 13 2010  nfsmnthelp</em><br />
<em>-r-xr-xr-x    1 bin      bin            6268 Dec 18 2009  udfmnthelp</em><br />
<em>-r-xr-xr-x    1 bin      bin          138292 Dec 18 2009  v3fshelper</em></p></blockquote>
<p>Otherwise You need to install it.</p>
<p>Then You can try to mount the Windows share using the mount command, specifying the cifs filesystem, the node name/IP, username, password and so on&#8230;</p>
<blockquote><p><em>mount -v cifs -n node/username/passw [-o options] /winshare /directory</em></p></blockquote>
<p>e.g.</p>
<blockquote><p><em>mount -v cifs -n 192.168.1.28/george/HareKrishna \<br />
-o wrkgrp=BEATLES,fmode=755 \<br />
IndiaPics /opt/holidays/meditation/india1967</em></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/229/notes/how-to-mount-a-windows-share-under-aix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A sort of diff implementation in the MS-DOS world</title>
		<link>http://www.nic-nac-project.de/~jose/224/kludges/a-sort-of-diff-implementation-in-the-ms-dos-world/</link>
		<comments>http://www.nic-nac-project.de/~jose/224/kludges/a-sort-of-diff-implementation-in-the-ms-dos-world/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 09:59:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[kludges]]></category>
		<category><![CDATA[DOS]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=224</guid>
		<description><![CDATA[The MS-DOS FC.EXE programs is useful to compare two files. Differences between files are shown introduced by the string &#8220;*****&#8221; otherwise, if the files are equal, no asterisks will are displayed. Redirecting the output on a temporary file, using SET /P it&#8217;s possible to define a variable in order to handle both the cases (the [...]]]></description>
			<content:encoded><![CDATA[<p>The MS-DOS <em>FC.EXE</em> programs is useful to compare two files. Differences between files are shown introduced by the string <em>&#8220;*****&#8221; </em>otherwise, if the files are equal, no asterisks will are displayed.<br />
Redirecting the output on a temporary file, using <em>SET /P</em> it&#8217;s possible to define a variable in order to handle both the cases (the files are different or the files are equals).</p>
<p>A sort of *nix <em>diff </em>implementation made by a batch script may be the following:</p>
<blockquote><p><em>@echo off</em><br />
<em>fc %1 %2|find /c &#8220;*****&#8221; &gt; tempfile.out</em><br />
<em>SET /P TestVar=&lt;tempfile.out</em><br />
<em>del tempfile.out</em><br />
<em>echo TestVar=%TestVar%</em><br />
<em>if %TestVar% == 0 GOTO:FEQUALS</em><br />
<em>echo %1 and %2 are different</em><br />
<em>GOTO:EOF</em><br />
<em>:FEQUALS</em><br />
<em>echo %1 and %2 are equals</em></p></blockquote>
<p>Off corse if You need something better of this silly diff version, You may find useful <a href="http://www.delorie.com/djgpp/v2/">djcpp</a>, <a href="http://www.cygwin.com/">cygwin</a> or other unix-like platforms<em><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/224/kludges/a-sort-of-diff-implementation-in-the-ms-dos-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios monitoring imap active connections</title>
		<link>http://www.nic-nac-project.de/~jose/214/notes/nagios-monitoring-imap-active-connections/</link>
		<comments>http://www.nic-nac-project.de/~jose/214/notes/nagios-monitoring-imap-active-connections/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 16:01:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[SNMP]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=214</guid>
		<description><![CDATA[To monitor with nagios the number of imap sessions running on a mail server, I used this way. First, the command definition define command { command_name  check_imapd_conn command_line  /usr/lib/nagios/plugins/check_imap_conn $HOSTADDRESS$ $ARG1$ } Second, the check definition define service{ use                             generic-service host_name                       myimapserver service_description             IMAP Connections is_volatile                     0 check_period                    24&#215;7 max_check_attempts              3 normal_check_interval           5 retry_check_interval            1 [...]]]></description>
			<content:encoded><![CDATA[<p>To monitor with nagios the number of imap sessions running on a mail server, I used this way.</p>
<p>First, the command definition</p>
<blockquote><p><em>define command {</em><br />
<em> command_name  check_imapd_conn</em><br />
<em> command_line  /usr/lib/nagios/plugins/check_imap_conn $HOSTADDRESS$ $ARG1$</em><br />
<em> }</em></p></blockquote>
<p>Second, the check definition</p>
<blockquote><p><em>define service{</em><br />
<em> use                             generic-service</em><br />
<em>host_name                       myimapserver</em><br />
<em> service_description             IMAP Connections</em><br />
<em> is_volatile                     0</em><br />
<em> check_period                    24&#215;7</em><br />
<em> max_check_attempts              3</em><br />
<em> normal_check_interval           5</em><br />
<em> retry_check_interval            1</em><br />
<em> contact_groups                  admins</em><br />
<em> notification_interval           240</em><br />
<em> notification_period             24&#215;7</em><br />
<em> notification_options            c,r</em><br />
<em> check_command                   check_imapd_conn!public</em><br />
<em> process_perf_data               1</em><br />
<em> }</em></p></blockquote>
<p>The script is this:</p>
<blockquote><p><em>#!/bin/bash</em></p>
<p><em>HOSTNAME=$1</em><br />
<em>COMMUNITY=$2</em></p>
<p><em>RET_OK=&#8221;0&#8243;</em><br />
<em>RET_WARN=&#8221;1&#8243;</em><br />
<em>RET_CRIT=&#8221;2&#8243;</em><br />
<em>RET_UNKN=&#8221;3&#8243;</em></p>
<p><em>checkdata () {</em><br />
<em> VAL=`echo $2 | wc | awk &#8216;{print $2}&#8217;`</em><br />
<em> if [ $VAL -eq 0 ]; then</em><br />
<em> echo $1 is not set</em><br />
<em> exit $RET_UNKN</em><br />
<em> fi</em><br />
<em>}</em></p>
<p><em># MAIN</em><br />
<em>checkdata &#8220;HOSTNAME&#8221; $HOSTNAME</em><br />
<em>checkdata &#8220;COMMUNITY&#8221; $COMMUNITY</em></p>
<p><em>STR=`/usr/bin/snmpget -v 2c -c $COMMUNITY $HOSTNAME .1.3.6.1.4.1.2021.8.1.101.5 | sed -e &#8220;s/.*STRING: //&#8221; | awk &#8216;{print $1}&#8217;`</em><br />
<em>NCONN=`echo $STR|sed -e &#8220;s/of.*//&#8221;`</em></p>
<p><em># The Maximum number taken from imap configuration file</em> after the &#8220;of&#8221; in output string<br />
<em>CRITVAL=`echo $STR|sed -e &#8220;s/.*of//&#8221;`</em></p>
<p><em># warning at the 85%</em><br />
<em>WARNVAL=`expr $CRITVAL \* 85 / 100`</em></p>
<p><em>PERFSTR=&#8221;&#8216;IMAP Connections&#8217;=$NCONN;$WARNVAL;$CRITVAL&#8221;</em><br />
<em>if [ "$NCONN" -gt "$CRITVAL" ]; then</em><br />
<em> echo &#8220;ERROR: Too much IMAPD connections ($NCONN) max is $CRITVAL.|&#8221;$PERFSTR</em><br />
<em> exit $RET_CRIT</em><br />
<em>fi</em></p>
<p><em>if [ "$NCONN" -gt "$WARNVAL" ]; then</em><br />
<em> echo &#8220;WARNING: $NCONN IMAP connections (max is $CRITVAL).|&#8221;$PERFSTR</em><br />
<em> exit $RET_WARN</em><br />
<em>else</em><br />
<em> echo &#8220;$NCONN concurrent IMAP connections (max is $CRITVAL).|&#8221;$PERFSTR</em><br />
<em> exit $RET_OK</em><br />
<em>fi</em></p></blockquote>
<p>on my IMAP server I wrote this simple script:</p>
<blockquote><p><em>#!/bin/sh</em><br />
<em>IMAPSRVIP=10.11.12.13</em><br />
<em>CONNATT=`sudo netstat -natp|grep $IMAPSRVIP:143|wc -l`</em><br />
<em>CONNMAX=`grep imap /etc/cyrus.conf|grep -v \#|sed -e &#8220;s/.*maxchild=//&#8221;|awk &#8216;{print $1}&#8217;`</em></p>
<p><em> RETVAL=&#8221;$CONNATT&#8221;of&#8221;$CONNMAX&#8221;</em><br />
<em> echo $RETVAL</em></p></blockquote>
<p>the script full path is in the server snmpd.conf</p>
<blockquote><p><em>#  Arbitrary extension commands</em><br />
<em>exec IMAPConn /bin/sh /usr/local/snmpd-scripts/cnt_imap.sh</em></p></blockquote>
<p>The sudo for netstat command in the script is needed to avoid an output line this</p>
<blockquote><p><em>(No info could be read for &#8220;-p&#8221;: geteuid()=2002 but you should be root.)</em></p></blockquote>
<p>Off corse, to make the sudo works as expected it&#8217;s needed to add a line like</p>
<blockquote><p><em>snmp    ALL=NOPASSWD:   /bin/netstat</em></p></blockquote>
<p>in sudo configuration.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/214/notes/nagios-monitoring-imap-active-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The best website in the world&#8230;</title>
		<link>http://www.nic-nac-project.de/~jose/210/a-nerd-amusement/the-best-website-in-the-world/</link>
		<comments>http://www.nic-nac-project.de/~jose/210/a-nerd-amusement/the-best-website-in-the-world/#comments</comments>
		<pubDate>Fri, 20 May 2011 10:12:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=210</guid>
		<description><![CDATA[&#8230;is commandlinefu.com. Just to remind me that all can be done with a command line]]></description>
			<content:encoded><![CDATA[<p>&#8230;is <a href="http://www.commandlinefu.com/commands/browse">commandlinefu.com</a>. Just to remind me that all can be done with a command line <img src='http://www.nic-nac-project.de/~jose/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/210/a-nerd-amusement/the-best-website-in-the-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command Line Interface to enable SNMP on a VMWare ESXI server</title>
		<link>http://www.nic-nac-project.de/~jose/206/drafts/command-line-interface-to-enable-snmp/</link>
		<comments>http://www.nic-nac-project.de/~jose/206/drafts/command-line-interface-to-enable-snmp/#comments</comments>
		<pubDate>Thu, 19 May 2011 12:26:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drafts]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[WMware]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=206</guid>
		<description><![CDATA[Maybe You like to enable SNMP on Your VMware ESXI server. Recently I used some suggestions from this page. Install the VMware vSphere CLI interface andi issue commands like vicfg-snmp &#8211;server &#60;ESXi_ip&#62; -c &#60;communityname&#62; -p 161 -t &#60;destination_host&#62;@161/&#60;community name&#62; vicfg-snmp &#8211;server &#60;ESXi_ip&#62; -E or (a bad but working way) just edit the file /etc/vmware/snmp.xml]]></description>
			<content:encoded><![CDATA[<p>Maybe You like to enable SNMP on Your VMware ESXI server.<br />
Recently I used some suggestions from <a href="http://www.fatmin.com/2010/08/enabling-snmp-in-esxi-41-using-the-remote-cli.html">this page</a>.<br />
Install the <a href="http://downloads.vmware.com/d/details/vcli41/ZHcqYmRoaCpiZHdlZQ==">VMware vSphere CLI</a> interface andi issue commands like</p>
<blockquote><p><em>vicfg-snmp &#8211;server &lt;ESXi_ip&gt; -c &lt;communityname&gt; -p 161 -t &lt;destination_host&gt;@161/&lt;community name&gt;</em></p>
<p><em> vicfg-snmp  &#8211;server &lt;ESXi_ip&gt; -E</em></p></blockquote>
<p>or (a bad but working way) just edit the file /etc/vmware/snmp.xml</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/206/drafts/command-line-interface-to-enable-snmp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>a nagios plugin to monitor clamav status</title>
		<link>http://www.nic-nac-project.de/~jose/203/notes/a-nagios-plugin-to-monitor-clamav-status/</link>
		<comments>http://www.nic-nac-project.de/~jose/203/notes/a-nagios-plugin-to-monitor-clamav-status/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 11:04:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[clamav]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://www.nic-nac-project.de/~jose/?p=203</guid>
		<description><![CDATA[To monitor if a clam-av program on my mailserver is up to date, I set up the following trick. first: I redirected on a file the freshclam output: # 6 hours period virus definition update 7 1,7,13,19 * * * /usr/local/bin/freshclam &#62; /var/log/clamav/freshcron.latest 2&#62;&#38;1 In case of out of date version, my file should looks [...]]]></description>
			<content:encoded><![CDATA[<p>To monitor if a clam-av program on my mailserver is up to date, I set up the following trick.</p>
<p>first: I redirected on a file the freshclam output:</p>
<blockquote><p><em># 6 hours period virus definition update</em><br />
<em>7 1,7,13,19 * * * /usr/local/bin/freshclam &gt; /var/log/clamav/freshcron.latest 2&gt;&amp;1</em></p></blockquote>
<p>In case of out of date version, my file should looks like</p>
<blockquote><p><em># cat /var/log/clamav/freshcron.latest</em><br />
<em>ClamAV update process started at Wed Feb  9 07:07:01 2011</em><br />
<em>WARNING: Your ClamAV installation is OUTDATED!</em><br />
<em>WARNING: Local version: 0.96.5 Recommended version: 0.97</em><br />
<em>DON&#8217;T PANIC! Read http://www.clamav.net/support/faq</em><br />
<em>Connecting via &#8230;&#8230; etc.</em></p></blockquote>
<p>otherwise no line starting with the word worning in uppercase or the string recommended is present.<br />
Second step: a script called by SNMP has set on my mailserver by adding the following line to /etc/snmp/snmpd.conf:</p>
<blockquote><p>exec ClamVrfy /bin/sh /usr/lib/nagios/plugins/clamd_check.sh</p></blockquote>
<p>the script source is</p>
<blockquote><p><em>#!/bin/sh</em><br />
<em>PROCRUNNING=`ps -C clamd | wc -l`</em><br />
<em>VERSIONUPD=`grep Recommended /var/log/clamav/freshcron.latest`</em><br />
<em>echo $PROCRUNNING \&#8221;$VERSIONUPD\&#8221;</em></p></blockquote>
<p>Third step: congiguration of my nagios setup adding</p>
<blockquote><p><em>define command {</em><br />
<em> command_name  check_update_clamd</em><br />
<em> command_line  /usr/lib/nagios/plugins/check_clam_update $HOSTADDRESS$ $ARG1$ $ARG2$ $ARG3$</em><br />
<em> }</em></p></blockquote>
<p>to command definitions, and</p>
<blockquote><p><em>define service{</em><br />
<em> use                             generic-service</em></p>
<p><em> host_name                       mymailserver</em><br />
<em> service_description             CLAM-AV DEFS UPDATE</em><br />
<em> is_volatile                     0</em><br />
<em> check_period                    24&#215;7</em><br />
<em> max_check_attempts              3</em><br />
<em> normal_check_interval           5</em><br />
<em> retry_check_interval            1</em><br />
<em> contact_groups                  admins</em><br />
<em> notification_interval           240</em><br />
<em> notification_period             24&#215;7</em><br />
<em> notification_options            c,r</em><br />
<em> check_command                   check_update_clamd!public!2!5</em><br />
<em> process_perf_data               1</em><br />
<em> }</em></p></blockquote>
<p>to services.<br />
My plugin script is:</p>
<blockquote><p><em># cat /usr/lib/nagios/plugins/check_clam_update</em><br />
<em>#!/bin/bash</em></p>
<p><em># Input parameters</em><br />
<em>HOSTNAME=$1</em><br />
<em>COMMUNITY=$2</em><br />
<em>MYVALWARN=$3</em><br />
<em>MYVALCRIT=$4</em></p>
<p><em># Return Values</em><br />
<em>RET_OK=&#8221;0&#8243;</em><br />
<em>RET_WARN=&#8221;1&#8243;</em><br />
<em>RET_CRIT=&#8221;2&#8243;</em><br />
<em>RET_UNKN=&#8221;3&#8243;</em></p>
<p><em>checkdata () {</em><br />
<em> VAL=`echo $2 | wc | awk &#8216;{print $2}&#8217;`</em><br />
<em> if [ $VAL -eq 0 ]; then</em><br />
<em> echo $1 is not set</em><br />
<em> exit $RET_UNKN</em><br />
<em> fi</em><br />
<em>}</em></p>
<p><em># MAIN</em><br />
<em>checkdata &#8220;HOSTNAME&#8221; $HOSTNAME</em><br />
<em>checkdata &#8220;COMMUNITY&#8221; $COMMUNITY</em></p>
<p><em>STR=`/usr/bin/snmpget -v 2c -c $COMMUNITY $HOSTNAME .1.3.6.1.4.1.2021.8.1.101.3 | sed -e &#8220;s/.*STRING: //&#8221;`</em></p>
<p><em>if [ "$STR" -ge "$MYVALCRIT" ]; then</em><br />
<em> echo &#8220;Clamd Antivirus Definition DB is Out of Date&#8221;</em><br />
<em> exit $RET_CRIT</em><br />
<em>else</em><br />
<em>if [ "$STR" -ge "$MYVALWARN" ]; then</em><br />
<em> echo &#8220;Clamd Antivirus Definition DB is Quite Old&#8221;</em><br />
<em> exit $RET_WARN</em><br />
<em>else</em><br />
<em> echo &#8220;Clamd Antivirus Definition DB is Up to Date&#8221;</em><br />
<em> exit $RET_OK</em><br />
<em>fi</em><br />
<em>fi</em></p>
<p>&nbsp;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.nic-nac-project.de/~jose/203/notes/a-nagios-plugin-to-monitor-clamav-status/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	<img style='margin:0;padding:0;border:0;' width='1px' height='1px' src="http://www.nic-nac-project.de/~jose/wp-content/plugins/mystat/mystat.php?act=time_load&id=69130&rnd=1612136155" /></channel>
</rss>

