Open Sessions on the system
Hello all!! I need a program that can check if there are more the 10 sessions open on my system...if this is true to send a message on the root terminal...i'm a beginer...help me plz
|
you can create a scriptby using w | wc -l this command gives you the number of opened sessions to the server (from telnet,ssh,console) as a next command for sending message (screen message) talk or wall according to your needs when you create a script put it to the cron and run for every minute so this can do what you mean.
regards, |
mkdir /etc/cron.minute
in your /etc/crontab add * * * * * root run-parts /etc/cron.minute now create the script file under /etc/cron.minute/ example vi terminal-watch then chmod +x terminal-watch cut-n-paste script------------------------------------------------------------------ P=`w | grep :0 | wc | awk '{print $1}'` if [ "$P" -le "10" ] ; then # echo "ok $P" exit fi # this put a message in your syslog.. if its important enough to email..its important # enough to log... # log to local4.info /usr/bin/logger -t Terminal-USE -p local4.info "More than 10 terminals open ($P)" mail -s "Number of terminals open ($P) on host yourhostname" your@mail.address.com -c whom-ever-you-want-to-cc@email.address.com cut-n-paste script------------------------------------------------------------------ |
All times are GMT -5. The time now is 04:30 PM. |