problems with a Script on nagios

Aritz.Lazkano at DaimlerChrysler.com Aritz.Lazkano at DaimlerChrysler.com
Thu May 31 09:47:58 CEST 2007


Hi Nagiosexchange users!!!

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.


check_acces 
-----------------------
#!/bin/bash

di=`date '+%B %d'`
for i in `cut -f1 -d: /etc/passwd`;
do
kkY=`grep  \Failed\ \keyboard-interactive/pam\ \for\ \$i /var/log/messages 
|cut -c1-15|awk "/$di/"`
if [ "$kkY" != "" ]
then
sa1="$sa1 User: $i Date of Attempts:$kkY"
fi
done

kk6=`grep  \Failed\ \keyboard-interactive/pam\ \for\ \illegal\ \user 
/var/log/messages |cut -c1-15 |awk "/$di/"`

sal2="EXISTING USERS:$sa1 NO EXISTING USERS: Date of Attempts:$kk6"

sal3=`echo $sal2`
echo $sal3


The script works fine on shell, I execute the script  like this 
./check_acces and it returns this 


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

this is ok, it works fine.

 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. 


 
 
 
 


Service                              Status           Last Check   
Duration                 Attempt                    Status information     
 

 
Incorrect Access 








OK
05-31-2007 09:30:46
2d 23h 30m 55s
1/4
EXISTING USERS: NO EXISTING USERS: Date of Attempts: 

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. 

Someone knows something about this?  Thank you for help!!!


Aritz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20070531/27cb65f9/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
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.
http://sourceforge.net/powerbar/db2/
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list