command execution alert


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users command execution alert
# 1  
Old 03-14-2010
command execution alert

hi Guys!

My requirement is... I need to get notified if somebody executes a specific commands...like kill or httpd stop.... something like that....

can somebody help me out...

Regards,
kiran
# 2  
Old 03-14-2010
If it is REALLY important, you can define an alias in /etc/profile
example using a protected directory
Code:
alias kill=/usr/local/bin/kill

/usr/local/bin/kill is a shell script:
Code:
echo "$USER just fired off: $@" | /usr/bin/mailx -s 'kill command issued' me@mycomputer.com
shift
/usr/bin/kill $@

Normally this kind of stuff is not necessary on a system where you have not granted excessive rights to ordinary users.
[/code]
# 3  
Old 03-15-2010
MySQL

You can use the following way.

input_file.txt content "running the listing command (ls)"


Code:
alias ls='ls;mail user_name -s Subject <input_file.txt'

if you run the ls command then mail will send to the specified user.
using the above command you can give mail alert to the users.
# 4  
Old 03-15-2010
thanks guys....it probably fulfill my requirement....

just to learn out of curiosity...what happens when i execute a command on shell prompt...will it log the command execution in any files??

---------- Post updated at 05:00 PM ---------- Previous update was at 04:28 PM ----------

the solution provided is very smart...but i need to monitor around 150 services spreed across 50 servers. it is very difficult for me to put a cron as per the services running on the servers.

Please help to get the better solution...
# 5  
Old 03-15-2010
Try to see the .bash_history file in your home directory.
# 6  
Old 03-15-2010
the issue with .bash_history,
1) improper exit from shell will not log command history in .bash_history file.
2) .bash_history file will be updated only after the user exits from the shell, if user runs the kill command or stooped any process, i will only know after he exits from the shell.....Smilie

correct me if i am wrong!!!...
# 7  
Old 03-15-2010
You might be interested in commercial products like Tripwire.

Another possibility (in Linux, other UNIX dialects I'm not sure) is to use a PRELOAD-library replacing the system calls fork() and exec(). If these system calls would write to the syslog you could at least document any command issued in way not even root could modify (without raising an alarm). I have once seen this done but can't remember what the name of the library was.

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution of command at command prompt

Hello Experts, I am still learning linux and have come across a question, hope to get some answer. I have two servers, and both have the same version of svn client installed and both have the same user_id. my SVN client version: svn, version 1.6.11 (r934486) compiled Mar 2 2011,... (4 Replies)
Discussion started by: babyPen1985
4 Replies

2. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

3. Shell Programming and Scripting

Want to terminate command execution when string found in the command output

Hi Experts, I am very much new to linux scripting, I am currently working on reducing my manual work and hence writing a script to automate few task. I am running below command to snmpwalk the router.. snmpwalk -v 3 -u WANDL_SU -a MD5 -A vfipmpls -x DES -X VfIpMpLs -l authPriv... (19 Replies)
Discussion started by: Hanumant.madane
19 Replies

4. Shell Programming and Scripting

Multiple command execution

I want to open more than 2 files(f1,f2). commands for opening those files are stored in one file (f3). command to execute the file (f3). (3 Replies)
Discussion started by: Mahendravarma
3 Replies

5. Shell Programming and Scripting

both sides execution of command

Hi, i am struggling with a chunk of code. for ((i=1; i<=3; i++));do one-$i ="/tmp/one.$RANDOM" done How to execute the above code. In both sides(LHS and RHS), i am executing commands. it is not allowing to execute. can you please give the idea. It should be very... (8 Replies)
Discussion started by: munna_dude
8 Replies

6. Solaris

get the total execution of command

hi, i have to get the info between start to stop of a command execution suppose, if we execute the command like pkgadd then while its executing it ask some questions , i have to get total information untill pkgadd command complete into a perticular file. (3 Replies)
Discussion started by: shankr3
3 Replies

7. UNIX for Dummies Questions & Answers

Command execution in grep

I'm taking Unix Scripting course and we've been given the following command grep -l "`echo '\t'`" foo What this command is basically doing is giving the lines in the ordinary file foo that contains the letter 't'. From my understanding, command substation occurs first. So echo '\t' is... (2 Replies)
Discussion started by: kkhan00
2 Replies

8. Shell Programming and Scripting

Code for execution command by command

a) cd /root/user/dir/sd/disk ./runInstaller -silent -responseFile b) cd /root1/user1 cp /root/user/dir/sd/disk/ram.txt now a) executes and starts running but b) interupts a) and is executed while a) is running on the other hand so I want b) to start only after successfull completion of... (6 Replies)
Discussion started by: sriki32
6 Replies

9. Shell Programming and Scripting

command execution time

Hi all, I want to display a progressbar depending upon the completion status of a command. I am coding from scratch as I dont want to use in place code. so Is there anyway of getting the progress of a command in percentage or in any other units while its running , is it possible using the top... (5 Replies)
Discussion started by: hashin_p
5 Replies

10. UNIX for Advanced & Expert Users

command execution ??

hi i have small shell script as follows cd /utilities/promoter/tmp grep SENDREPLY $1 | grep 'zzzzz@zzz.com' | awk -F" -f1 > /tmp/$LOGNAME/$1.request cd /tmp/$LOGNAME grep -e "\.sql" -e "\.md" $1.request > upd_$1.txt grep -v -e "\.sql" -e "\.md" $1.request > copy_$1.txt ... (1 Reply)
Discussion started by: zedex
1 Replies
Login or Register to Ask a Question