大网数据广告活动
服务器运维问答

How to find disconnected xrdp sessions?

· 52CE 我爱测

I have a Xubuntu 14.04 Server here that runs xrdp to have a couple of users connect to it. Now there's one problem: users who access this server via RDP from Windows thin clients often use the "X" to close the RDP session (theref…

问题原文

原帖链接 · wullxz · CC BY-SA 3.0

I have a Xubuntu 14.04 Server here that runs xrdp to have a couple of users connect to it.
Now there's one problem: users who access this server via RDP from Windows thin clients often use the "X" to close the RDP session (therefore disconnect but not logout).

I know there are some options in sesman.ini to deal with that kind of behaviour, but as the manpage says, those options are currently ignored (and have been for years).
The options which would solve my problems are:
KillDisconnected
DisconnectedTimeLimit
IdleTimeLimit

Now I need to hack something that deals with disconnected sessions. My first thought was to just kill all remote users who are disconnected - but I don't know how to get that information which sessions are disconnected.

So... how do I find disconnected sessions?
Or: is there already any preferred way to deal with disconnected sessions?

已采纳解答

原帖链接 · wullxz · CC BY-SA 3.0

I finally found a solution to this.
First of all, I had to install a small program called xprintidle:

sudo apt-get install xprintidle

After that I wrote a small bash script that first fetches all displayes used by Xvnc and xrdp and then checks those display sessions if they've been idle for more than a number of minutes:

#!/bin/bash

displays=`ps aux | grep Xvnc | grep -v 'grep\|sed' | sed -r 's|.*(Xvnc :[0-9]*).*|\1|' | cut -d' ' -f 2`
limit=180


date
echo "Checking for inactive sessions!"
while read -r d; do
    export DISPLAY=$d
    idle=`xprintidle`
    idleMins=$(($idle/1000/60))
    if [[ $idleMins -gt $limit ]]; then
        echo "WARN Display $d is logged in for longer than ${limit}min (${idleMins}m)"
    else
        echo "INFO Display $d is still ok (${idleMins}m)"
    fi  
done <<< "$displays"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-10-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。