<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>Please find the details</div>
<div> </div>
<div><u>Sudoers Definition:-</u></div>
<div> </div>
<div>nagios zurich= NOPASSWD: /sbin/iptables, /usr/local/nagios/libexec/check_iptables.sh, /usr/local/nagios/libexec/check_nrpe</div>
<div> </div>
<div><u>/var/log/secure</u><u>:</u></div>
<div> </div>
<div>su: pam_unix(su:session): session opened for user nagios by root(uid=0)</div>
<div>su: pam_unix(su:session): session closed for user nagios</div>
<div> </div>
<div> </div>
<div> </div>
<div>-----Original Message-----<br>

From: C. Bensend [<a href="mailto:benny@bennyvision.com">mailto:benny@bennyvision.com</a>]
<br>

Sent: Wednesday, 29 May 2013 7:59 PM<br>

To: nagios-users@lists.sourceforge.net<br>

Subject: Re: [Nagios-users] Nagios Plugin for IPTABLES Monitoring</div>
<div> </div>
<div> </div>
<div>Where's your sudoers definition that allows the nagios user to run any commands via sudo?</div>
<div> </div>
<div>And what does /var/log/secure (or equivalent) think about the nagios user trying to run sudo?</div>
<div> </div>
<div> </div>
<div>> I have tested with nagios user as well.. still no luck with that.  </div>
<div>> Could you some one update if you have any solution on this case.</div>
<div>></div>
<div>> Kind Regards,</div>
<div>> Thilak</div>
<div>></div>
<div>> From: Deborah Martin [<a href="mailto:Deborah.Martin@kognitio.com">mailto:Deborah.Martin@kognitio.com</a>]</div>
<div>> Sent: Tuesday, 14 May 2013 7:30 PM</div>
<div>> To: Nagios Users List</div>
<div>> Subject: Re: [Nagios-users] Nagios Plugin for IPTABLES Monitoring</div>
<div>></div>
<div>> Ok - if I look at your output, manually,  when the plugin is run as </div>
<div>> the "root" user it produces the correct result.</div>
<div>></div>
<div>> But, you haven't said what the nrpe user is that is running on the </div>
<div>> remote node  and whether the same manual run of the check produces the </div>
<div>> same output.</div>
<div>> For example, I run remote plugins through nrpe as the "nagios" user so </div>
<div>> if I want to manually test a plugin on the remote node, I would first </div>
<div>> login as the nagios user to ensure I've got the same environment that </div>
<div>> would be used when running via nrpe. It might be that the variables </div>
<div>> you have set in the script only work as the root user. It's never a </div>
<div>> good idea to test as the root  user but only as the same user as that used by nagios or nrpe.</div>
<div>></div>
<div>> Regards,</div>
<div>> Deborah</div>
<div>></div>
<div>> From: Thilakraj.Shanmugam [<a href="mailto:Thilakraj.Shanmugam@canberra.edu.au">mailto:Thilakraj.Shanmugam@canberra.edu.au</a>]</div>
<div>> Sent: 14 May 2013 09:58</div>
<div>> To: Nagios Users List</div>
<div>> Subject: Re: [Nagios-users] Nagios Plugin for IPTABLES Monitoring</div>
<div>></div>
<div>> Hi Deborah,  Thanks for the response..  please find the details below.</div>
<div>></div>
<div>></div>
<div>> [root@abc libexec]# pwd</div>
<div>> /usr/local/nagios/libexec</div>
<div>> [root@abc libexec]# ./check_iptables.sh</div>
<div>>                                    <-----  Executing manually script</div>
<div>> + IPT=/sbin/iptables</div>
<div>> + GREP=/bin/grep</div>
<div>> + AWK=/bin/awk</div>
<div>> + EXPR=/usr/bin/expr</div>
<div>> + WC=/usr/bin/wc</div>
<div>> + A=/usr/bin/sudo</div>
<div>> + E_SUCCESS=0</div>
<div>> + E_CRITICAL=2</div>
<div>> + E_UNKNOWN=3</div>
<div>> ++ /usr/bin/sudo /sbin/iptables -nvL</div>
<div>> ++ /bin/grep Chain</div>
<div>> ++ /bin/awk '{ print $2 }'</div>
<div>> ++ /bin/grep Cid</div>
<div>> ++ /usr/bin/wc -l</div>
<div>> + CHAINS=5</div>
<div>> + '[' 5 -ne 0 ']'</div>
<div>> + echo 'Firewall is running!'</div>
<div>> Firewall is running!</div>
<div>> + exit 0</div>
<div>>                                                 <------  it shows firewall</div>
<div>> running   ( correct output )</div>
<div>> [root@abc libexec]#</div>
<div>></div>
<div>></div>
<div>> Client - NRPE config file</div>
<div>></div>
<div>> [root@abc libexec]# cat /usr/local/nagios/etc/nrpe.cfg |grep -i </div>
<div>> iptable </div>
<div>> command[check_iptables]=/usr/local/nagios/libexec/check_iptables.sh</div>
<div>> [root@abc libexec]#</div>
<div>></div>
<div>></div>
<div>> [root@abc libexec]# ./check_nrpe -H localhost -c check_iptables </div>
<div>> Firewall is not running</div>
<div>>                                                     <-----  executing via</div>
<div>> check_nrpe   (  wrong output )</div>
<div>> [root@abc libexec]#</div>
<div>></div>
<div>></div>
<div>> NRPE Logs</div>
<div>> -------------</div>
<div>></div>
<div>> May 14 18:52:28 abc nrpe[31158]: Added </div>
<div>> command[check_Partion_db]=/usr/local/nagios/libexec/check_disk -w 15% </div>
<div>> -c 5% -p /db May 14 18:52:28 abc nrpe[31158]: Added </div>
<div>> command[check_Partion_app]=/usr/local/nagios/libexec/check_disk -w 15% </div>
<div>> -c 5% -p /app May 14 18:52:28 abc nrpe[31158]: Added </div>
<div>> command[check_iptables]=/usr/local/nagios/libexec/check_iptables.sh</div>
<div>> May 14 18:52:28 abc nrpe[31158]: INFO: SSL/TLS initialized. All </div>
<div>> network traffic will be encrypted.</div>
<div>> May 14 18:52:28 abc nrpe[31158]: Handling the connection...</div>
<div>> May 14 18:52:28 abc nrpe[31158]: Host is asking for command </div>
<div>> 'check_iptables' to be run...</div>
<div>> May 14 18:52:28 abc nrpe[31158]: Running command:</div>
<div>> /usr/local/nagios/libexec/check_iptables.sh</div>
<div>> May 14 18:52:28 abc nrpe[31158]: Command completed with return code 2 </div>
<div>> and</div>
<div>> output: Firewall is not running</div>
<div>> May 14 18:52:28 abc nrpe[31158]: Return Code: 2, Output: Firewall is </div>
<div>> not running</div>
<div>></div>
<div>></div>
<div>> Kind Regards,</div>
<div>> Thilak</div>
<div>></div>
<div>></div>
<div>> From: Deborah Martin [<a href="mailto:Deborah.Martin@kognitio.com">mailto:Deborah.Martin@kognitio.com</a>]</div>
<div>> Sent: Tuesday, 14 May 2013 6:44 PM</div>
<div>> To: Nagios Users List</div>
<div>> Subject: Re: [Nagios-users] Nagios Plugin for IPTABLES Monitoring</div>
<div>></div>
<div>> Hi,</div>
<div>> What is the wrong output being returned ? This might give us all a </div>
<div>> clue as to the cause of the problem.</div>
<div>> When you run the check manually, are you doing this as the same user </div>
<div>> that check_nrpe will use ?</div>
<div>></div>
<div>> Regards,</div>
<div>> Deborah</div>
<div>></div>
<div>></div>
<div>></div>
<div>> From: Thilakraj.Shanmugam [<a href="mailto:Thilakraj.Shanmugam@canberra.edu.au">mailto:Thilakraj.Shanmugam@canberra.edu.au</a>]</div>
<div>> Sent: 14 May 2013 08:43</div>
<div>> To:</div>
<div>> <a href="mailto:nagios-users@lists.sourceforge.net<mailto:nagios-users@lists.sourcefor">nagios-users@lists.sourceforge.net<mailto:nagios-users@lists.sourcefor</a></div>
<div>> ge.net></div>
<div>> Subject: [Nagios-users] Nagios Plugin for IPTABLES Monitoring</div>
<div>></div>
<div>> Greetings!</div>
<div>></div>
<div>> Could someone send me nagios plugin which is tested and works well for </div>
<div>> monitoring IPTABLES in Linux.</div>
<div>></div>
<div>> I have tested below script but it is not returning correct output to </div>
<div>> nagios server.</div>
<div>></div>
<div>> If I execute script manually, it shows correct output...</div>
<div>></div>
<div>> But if I execute via  ./check_nrpe - H localhost -c check_iptables,  </div>
<div>> it shows wrong output.</div>
<div>></div>
<div>></div>
<div>></div>
<div>> Below is my plugin</div>
<div>> ------------------------------</div>
<div>></div>
<div>> #!/bin/bash</div>
<div>> set -x</div>
<div>></div>
<div>> IPT='/sbin/iptables'</div>
<div>> GREP='/bin/grep'</div>
<div>> AWK='/bin/awk'</div>
<div>> EXPR='/usr/bin/expr'</div>
<div>> WC='/usr/bin/wc'</div>
<div>> A='/usr/bin/sudo'</div>
<div>></div>
<div>> E_SUCCESS="0"</div>
<div>> E_CRITICAL="2"</div>
<div>> E_UNKNOWN="3"</div>
<div>></div>
<div>> CHAINS=`$A $IPT -nvL | $GREP 'Chain' | $AWK '{ print $2 }'| $GREP Cid </div>
<div>> | $WC -l`</div>
<div>></div>
<div>>                 if [ $CHAINS -ne 0 ] ; then</div>
<div>>                         echo "Firewall is running!"</div>
<div>>                         exit ${E_SUCCESS}</div>
<div>></div>
<div>>                 elif [ $CHAINS -eq 0 ] ; then</div>
<div>>                         echo "Firewall is not running"</div>
<div>>                         exit ${E_CRITICAL}</div>
<div>>                 fi</div>
<div>></div>
<div>></div>
<div>></div>
<div>> This e-mail and any files transmitted with it are strictly </div>
<div>> confidential and intended solely for the use of the individual or </div>
<div>> entity to whom they are addressed. If you are not the intended </div>
<div>> recipient, please delete this e-mail immediately. Any unauthorised </div>
<div>> distribution or copying is strictly prohibited.</div>
<div>></div>
<div>> Whilst Kognitio endeavours to prevent the transmission of viruses via </div>
<div>> e-mail, we cannot guarantee that any e-mail or attachment is free from </div>
<div>> computer viruses and you are strongly advised to undertake your own </div>
<div>> anti-virus precautions. Kognitio grants no warranties regarding </div>
<div>> performance, use or quality of any e-mail or attachment and undertakes </div>
<div>> no liability for loss or damage, howsoever caused.</div>
<div>></div>
<div>></div>
<div>> This e-mail and any files transmitted with it are strictly </div>
<div>> confidential and intended solely for the use of the individual or </div>
<div>> entity to whom they are addressed. If you are not the intended </div>
<div>> recipient, please delete this e-mail immediately. Any unauthorised </div>
<div>> distribution or copying is strictly prohibited.</div>
<div>></div>
<div>> Whilst Kognitio endeavours to prevent the transmission of viruses via </div>
<div>> e-mail, we cannot guarantee that any e-mail or attachment is free from </div>
<div>> computer viruses and you are strongly advised to undertake your own </div>
<div>> anti-virus precautions. Kognitio grants no warranties regarding </div>
<div>> performance, use or quality of any e-mail or attachment and undertakes </div>
<div>> no liability for loss or damage, howsoever caused.</div>
<div>> ----------------------------------------------------------------------</div>
<div>> -------- Introducing AppDynamics Lite, a free troubleshooting tool for </div>
<div>> Java/.NET Get 100% visibility into your production application - at no </div>
<div>> cost.</div>
<div>> Code-level diagnostics for performance bottlenecks with <2% overhead </div>
<div>> Download for free and get started troubleshooting in minutes.</div>
<div>> <a href="http://p.sf.net/sfu/appdyn_d2d_ap1____________________________________">http://p.sf.net/sfu/appdyn_d2d_ap1____________________________________</a></div>
<div>> ___________</div>
<div>> Nagios-users mailing list</div>
<div>> <a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a></div>
<div>> <a href="https://lists.sourceforge.net/lists/listinfo/nagios-users">https://lists.sourceforge.net/lists/listinfo/nagios-users</a></div>
<div>> ::: Please include Nagios version, plugin version (-v) and OS when </div>
<div>> reporting any issue.</div>
<div>> ::: Messages without supporting info will risk being sent to /dev/null</div>
<div> </div>
<div> </div>
<div>--</div>
<div>"The very existence of flamethrowers proves that sometime, somewhere, someone said to themselves, 'You know, I want to set those people over there on fire, but I'm just not close enough to get the job</div>
<div>done.'"                          -- George Carlin</div>
<div> </div>
<div> </div>
<div>------------------------------------------------------------------------------</div>
<div>Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET</div>
<div>Get 100% visibility into your production application - at no cost.</div>
<div>Code-level diagnostics for performance bottlenecks with <2% overhead</div>
<div>Download for free and get started troubleshooting in minutes.</div>
<div><a href="http://p.sf.net/sfu/appdyn_d2d_ap1">http://p.sf.net/sfu/appdyn_d2d_ap1</a></div>
<div>_______________________________________________</div>
<div>Nagios-users mailing list</div>
<div><a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a></div>
<div><a href="https://lists.sourceforge.net/lists/listinfo/nagios-users">https://lists.sourceforge.net/lists/listinfo/nagios-users</a></div>
<div>::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. </div>
<div>::: Messages without supporting info will risk being sent to /dev/null</div>
<div> </div>
</span></font>
</body>
</html>