Monitoring side
Tool Ansible
Scheduled Tasks
*/10 * * * */dev/shm/history_log.sh
Build Scripts
vim/dev/shm/history_log.sh
#!/bin/bash
function History_log () {
local time
Time= ' date-d " -10 min" "+%f%h:%m" '
TIM=${TIME%[0-9]}
Remote_ab-h test-c "Tail-300/tmp/all_history" |grep "$tim" >>/tmp/all_history
}
History_log
Which Remote_ab
Alias remote_ab= '/dev/shm/remote_ansi '
/dev/shm/remote_ansi
Vim/dev/shm/remote_ansi
#!/bin/bash
While getopts "H:C:" opt
Do
Case $opt in
H
host= $OPTARG
;;
C
Command= $OPTARG
;;
*)
echo "Please click--help"
;;
Esac
Done
If ["x$host"! = "Xtest"-a "x$host"! = "XOnline"]
Then
echo "Make a choise in [Test|online]"
Exit
Fi
Remote_ansi-i/home/ec2-user/remote_ansi/hosts $host-a "$command"
Remote_ab//ansible after installation, rename ansible, and then create a soft link
Mv/usr/bin_ansible/usr/bin/remote_ansi
Client
# echo "Export histtimeformat= ' [%F%T] '" >>/etc/profile
Then modify the/etc/skel/.bash_logout
# ~/.bash_logout
History|awk ' {$1= ' "}1 ' >/tmp/history_ ' whoami '
Sed-i "s/^/' hostname ' whoami '/g"/tmp/history_ ' WhoAmI '
Cat/tmp/history_ ' WhoAmI ' >>/tmp/all_history
History-c
> ~/.bash_history
This script can let the new end user to collect the log port function, to let the current user can also be collected logs, you need to modify the existence of the user side plus directory lower
. bash_logout file
The content is the same as above, note that the/tmp/all_history file permission must be 777
Once this is done, you can monitor all user-side operation history on the server.
This article is from the "Autumn Song" blog, please be sure to keep this source http://qiufengsong.blog.51cto.com/7520243/1565687
How to monitor the user account history used on a Linux server