<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Because the user on shell is "root" and you have rights to process
/etc/passwd, but the user of NAGIOS doesn´t have rights to read
/etc/passwd<br>
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Aritz.Lazkano@DaimlerChrysler.com">Aritz.Lazkano@DaimlerChrysler.com</a> escribió:
<blockquote
 cite="mid:OF88B1009D.5B097741-ONC12572EC.002A8B99-C12572EC.002AD936@dcx.dcx"
 type="cite"><br>
  <font face="sans-serif" size="2">Hi Nagiosexchange users!!!</font>
  <br>
  <br>
  <font face="sans-serif" size="2">I have some problems with this  bash
script. The objetive is to monitor all the incorrect logins to the
sistem
so I created this script.</font>
  <br>
  <br>
  <br>
  <font face="sans-serif" size="2">check_acces </font>
  <br>
  <font face="sans-serif" size="2">-----------------------</font>
  <br>
  <font face="sans-serif" size="2">#!/bin/bash</font>
  <br>
  <br>
  <font face="sans-serif" size="2">di=`date '+%B %d'`</font>
  <br>
  <font face="sans-serif" size="2">for i in `cut -f1 -d: /etc/passwd`;</font>
  <br>
  <font face="sans-serif" size="2">do</font>
  <br>
  <font face="sans-serif" size="2">kkY=`grep  \Failed\
\keyboard-interactive/pam\
\for\ \$i /var/log/messages |cut -c1-15|awk "/$di/"`</font>
  <br>
  <font face="sans-serif" size="2">if [ "$kkY" != ""
]</font>
  <br>
  <font face="sans-serif" size="2">then</font>
  <br>
  <font face="sans-serif" size="2">sa1="$sa1 User: $i Date of
Attempts:$kkY"</font>
  <br>
  <font face="sans-serif" size="2">fi</font>
  <br>
  <font face="sans-serif" size="2">done</font>
  <br>
  <br>
  <font face="sans-serif" size="2">kk6=`grep  \Failed\
\keyboard-interactive/pam\
\for\ \illegal\ \user /var/log/messages |cut -c1-15 |awk "/$di/"`</font>
  <br>
  <br>
  <font face="sans-serif" size="2">sal2="EXISTING USERS:$sa1 NO
EXISTING
USERS: Date of Attempts:$kk6"</font>
  <br>
  <br>
  <font face="sans-serif" size="2">sal3=`echo $sal2`</font>
  <br>
  <font face="sans-serif" size="2">echo $sal3</font>
  <br>
  <br>
  <br>
  <font face="sans-serif" size="2">The script works fine on shell, I
execute
the script  like this   ./check_acces and it returns this </font>
  <br>
  <br>
  <br>
  <font face="sans-serif" size="2">EXISTING USERS: User: root Date of
Attempts:May
31 08:40:03 May 31 08:40:04 May 31 08:40:15 May 31 08:40:17 May 31
08:40:18
User: jon Date of Attempts:May 31 08:40:33 May 31 08:40:34 May 31
08:40:35
May 31 08:40:36 May 31 08:40:38 NO EXISTING USERS: Date of Attempts:May
31 08:40:54 May 31 08:40:56 May 31 08:40:57 May 31 08:40:59 May 31
08:41:01
May 31 08:41:02 May 31 08:41:04 May 31 08:41:14 May 31 08:41:15 May 31
08:41:16 May 31 08:41:17 May 31 08:41:19 May 31 08:41:20 May 31 08:41:23</font>
  <br>
  <br>
  <font face="sans-serif" size="2">this is ok, it works fine.</font>
  <br>
  <br>
  <font face="sans-serif" size="2"> But when I declare a service and
a command on Nagios with this script something extrange happends, only
appears this on Nagios, where are the incorect logins? They doesn´t
appear.
  </font><br>
  <table width="100%">
    <tbody>
      <tr>
        <td width="11%">
        <br>
        </td>
        <td width="13%">
        <div align="center"><font size="3"><b> </b></font></div>
        </td>
        <td width="13%">
        <div align="center"><font size="3"><b> </b></font></div>
        </td>
        <td width="17%">
        <div align="center"><font size="3"><b> </b></font></div>
        </td>
        <td width="14%">
        <div align="center"><font size="3"><b> </b></font></div>
        </td>
        <td width="14%">
        <br>
        </td>
        <td width="14%"><br>
        </td>
      </tr>
    </tbody>
  </table>
  <br>
  <font face="sans-serif" size="2">Service        
                     Status
          Last Check        
             Duration    
            Attempt      
             Status information  
               </font>
  <br>
  <table width="100%">
    <tbody>
      <tr>
        <td width="16%"><font size="2">   </font>
        <table width="100%">
          <tbody>
            <tr>
              <td width="87%"><font size="2">Incorrect Access </font>
              <table width="100%">
                <tbody>
                  <tr>
                    <td width="100%"><br>
                    </td>
                  </tr>
                </tbody>
              </table>
              <br>
              </td>
              <td width="12%"><br>
              <font size="2"><br>
              </font>
              <div align="right">
              <table width="100%">
                <tbody>
                  <tr>
                    <td width="100%"><br>
                    </td>
                  </tr>
                </tbody>
              </table>
              </div>
              <br>
              </td>
            </tr>
          </tbody>
        </table>
        <br>
        </td>
        <td width="3%"><font size="3">OK</font>
        </td>
        <td width="16%"><font size="3">05-31-2007 09:30:46</font>
        </td>
        <td width="12%"><font size="3">2d 23h 30m 55s</font>
        </td>
        <td width="2%"><font size="3">1/4</font>
        </td>
        <td width="48%"><font size="3">EXISTING USERS: NO EXISTING
USERS: Date of Attempts: </font></td>
      </tr>
    </tbody>
  </table>
  <br>
  <br>
  <font face="sans-serif" size="2">I dont know why when the script is
executed
by nagios it doesn´t return anything and it works fine on shell. The
script
 executed by nagios it doesn´t return the same as when you executed
on shell. </font>
  <br>
  <br>
  <font face="sans-serif" size="2">Someone knows something about this?
 Thank you for help!!!</font>
  <br>
  <br>
  <br>
  <font face="sans-serif" size="2">Aritz.</font>
  <pre wrap="">
<hr size="4" width="90%">
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
<a class="moz-txt-link-freetext" href="http://sourceforge.net/powerbar/db2/">http://sourceforge.net/powerbar/db2/</a></pre>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Nagios-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/nagios-users">https://lists.sourceforge.net/lists/listinfo/nagios-users</a>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 11">
<meta name="Originator" content="Microsoft Word 11">
<link rel="File-List" href="Firma_archivos/filelist.xml">
<link rel="Edit-Time-Data" href="Firma_archivos/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>Jose Luis Fernández Sánchez</title>
<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:HyphenationZone>21</w:HyphenationZone>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-alt:\5B8B\4F53;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;
        mso-font-charset:0;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:1627421319 -2147483648 8 0 66047 0;}
@font-face
        {font-family:"Arial Narrow";
        panose-1:2 11 5 6 2 2 2 3 2 4;
        mso-font-charset:0;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:647 0 0 0 159 0;}
@font-face
        {font-family:Webdings;
        panose-1:5 3 1 2 1 5 9 6 7 3;
        mso-font-charset:2;
        mso-generic-font-family:roman;
        mso-font-pitch:variable;
        mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0cm;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {mso-style-noshow:yes;
        color:blue;
        text-decoration:underline;
        text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;
        text-underline:single;}
span.spelle
        {mso-style-name:spelle;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;
        mso-header-margin:35.4pt;
        mso-footer-margin:35.4pt;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
        {mso-style-name:"Tabla normal";
        mso-tstyle-rowband-size:0;
        mso-tstyle-colband-size:0;
        mso-style-noshow:yes;
        mso-style-parent:"";
        mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
        mso-para-margin:0cm;
        mso-para-margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.0pt;
        font-family:"Times New Roman";
        mso-ansi-language:#0400;
        mso-fareast-language:#0400;
        mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="2050"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
<div class="Section1">
<p class="MsoNormal"><span
 style="font-size: 11pt; font-family: "Arial Narrow"; color: gray;">José
Luís Fernández
Sánchez<o:p></o:p></span></p>
<p class="MsoNormal"><span
 style="font-size: 11pt; font-family: "Arial Narrow"; color: gray;">Área
de Nuevas
Tecnologías<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left: 35.4pt;"><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: rgb(0, 114, 41);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: gray;">C/
Marie Curie, nº 6 –
bajo derecha. 29590. PTA. Málaga<o:p></o:p></span></p>
<p class="MsoNormal"><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: gray;">Tel.
+34 951 299 524 –
Fax: +34 </span><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: gray;">951
299 596</span><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: gray;"><o:p></o:p></span></p>
<p class="MsoNormal"><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: gray;">Correo-e:
<a href="mailto:joseluis.fernandez@juntadeandalucia.es">joseluis.fernandez@juntadeandalucia.es</a><o:p></o:p></span></p>
<p class="MsoNormal"><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: gray;"><a
 href="http://www.juntadeandalucia.es/fundaciondeserviciossociales"><span
 style="color: gray;">www.juntadeandalucia.es/fundaciondeserviciossociales</span></a><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left: 35.4pt;"><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: gray;"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
 style="font-size: 10pt; font-family: "Arial Narrow"; color: blue;"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
 style="font-size: 9pt; font-family: "Arial Narrow"; color: blue;"><!--[if gte vml 1]><v:shapetype
 id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
 path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
 <v:stroke joinstyle="miter"/>
 <v:formulas>
  <v:f eqn="if lineDrawn pixelLineWidth 0"/>
  <v:f eqn="sum @0 1 0"/>
  <v:f eqn="sum 0 0 @1"/>
  <v:f eqn="prod @2 1 2"/>
  <v:f eqn="prod @3 21600 pixelWidth"/>
  <v:f eqn="prod @3 21600 pixelHeight"/>
  <v:f eqn="sum @0 0 1"/>
  <v:f eqn="prod @6 1 2"/>
  <v:f eqn="prod @7 21600 pixelWidth"/>
  <v:f eqn="sum @8 21600 0"/>
  <v:f eqn="prod @7 21600 pixelHeight"/>
  <v:f eqn="sum @10 21600 0"/>
 </v:formulas>
 <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
 <o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:226.5pt;
 height:37.5pt'>
 <v:imagedata src=".\Firma_archivos\image003.jpg" o:title="logo_fass_web"/>
</v:sha
pe><![endif]--><!--[if !vml]--><img
 src="cid:part1.07050508.08080501@juntadeandalucia.es"
 v:shapes="_x0000_i1025" border="0" height="50" width="302"><!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal" style="text-align: justify;"><span
 style="font-size: 7pt; font-family: Arial; color: gray;">Este mensaje
se dirige exclusivamente a su
destinatario y puede contener información privilegiada o confidencial.
Si no es
Ud. el destinatario indicado, queda notificado de que la utilización,
divulgación y/o copia sin autorización está prohibida en virtud de la
legislación vigente. Si ha recibido este mensaje por error, le rogamos
que nos
lo comunique inmediatamente por esta misma vía y proceda a su
destrucción.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-align: justify;"><span
 style="font-size: 7pt; font-family: Arial; color: gray;" lang="EN-GB">This
message is intended exclusively for its addressee and may contain
information that is CONFIDENTIAL and protected by professional
privilege. If you
are not the intended recipient your are hereby notified that any
dissemination,
copy or disclosure of this communication is strictly prohibited by law.
If this
message has been received in error, please immediately notify us via
e-mail and
delete it.<o:p></o:p></span></p>
<p class="MsoNormal"><span class="spelle"><b><i><span
 style="font-size: 24pt; font-family: Webdings; color: gray;">P</span></i></b></span><span
 class="spelle"><i><span
 style="font-size: 7.5pt; font-family: Arial; color: gray;"> Antes de
imprimir, piense en su compromiso con el MEDIO
AMBIENTE!</span></i></span><span class="spelle"><i><span
 style="font-size: 7.5pt;"><o:p></o:p></span></i></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>