With Firmware V3.5.2 and later you can specify from the management GUI the amount of time (in minutes) the console server waits before it terminates an idle ssh, pmshell or web connection .
- Select Serial and Network: Authentication
- Web Management Session Timeout specifies the browser console session idle timeout in minutes. The default setting is 20 minutes. It may be set from 10 to 1440 minutes
- CLI Management Session Timeout specifies the ssh console session idle timeout in minutes. The default setting is to never expire
- Console Server Session Timeout specifies the pmshell serial console server session idle timeout in minutes. The default setting is to never expire
Alternately you can terminate with a script e.g. he script below will kill idle pmshell sessions that were started with any method (pmshell from command line, direct to tcp port, user:serial etc.). However the connection must be ssh. Telnet is not supported as it does not connect to a ttyP# port.
This script can be put it into /etc/config/crontab.root to run as a cron job every minute. It is currently set up to kill idle sessions over two minutes, but that can be increased up to about 60 minutes. As the idle timer changes from minutes to hours you would have to make sure the cron job run times don’t allow the idle time to roll past minutes to hours or else it will fail to kill the process.
# cat /etc/config/scripts/kill-idle-pmshell
#!/bin/bash
# max idle time in minutes
MAXIDLE=2
OLDIFS=$IFS
IFS='
'
# get idle times of pmshell
for i in `w -h | grep pmshell | awk '{ print $2,$4 }' | sed 's/:.*$//' | sed -e '/^.*[0-9]s$/d'`;
do
idletime=`echo $i | awk '{ print $2 }'`
# if idle time is greater or equal to maxidle, get PIDs of the ttys
if [ $idletime -ge $MAXIDLE ];
then
TTYTOKILL=`echo "$i" | awk '{print $1}' | sed 's/^.*\///'`
PIDSTOKILL=`ps | grep $TTYTOKILL | awk '{print $1}' | sed '2d'`
# kill PID’s
for ps in $PIDSTOKILL;
do
kill -9 $ps
done
fi
done
IFS=$OLDIFS
#
Comments
0 comments
Article is closed for comments.