LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2008, 06:52 AM   #1
Techlord
LQ Newbie
 
Registered: May 2008
Posts: 1

Rep: Reputation: 0
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
 
Old 05-13-2008, 07:12 AM   #2
smus
Member
 
Registered: Nov 2005
Location: Turkey
Distribution: Suse
Posts: 104

Rep: Reputation: 16
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,
 
Old 05-13-2008, 07:49 AM   #3
tgreaser
LQ Newbie
 
Registered: Feb 2007
Location: Morgantown, WV
Distribution: RedHat, Fedora
Posts: 24

Rep: Reputation: 16
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------------------------------------------------------------------
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ubuntu Open Week: Sessions You May Want to Read LXer Syndicated Linux News 0 05-04-2008 04:30 AM
LXer: TEPR 2007 Open Source Speakers/Sessions LXer Syndicated Linux News 0 05-20-2007 05:16 PM
Manage Open SSH sessions BlueTornJacket Linux - Networking 5 03-10-2007 07:10 PM
How to open multiple sessions of Kaffeine? NickC Linux - Software 1 04-06-2006 05:54 PM
Can't open multiple X sessions JasonSmead Linux - General 1 08-10-2003 02:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration