简体   繁体   English

如何获取 EC2 Windows 实例 AWS 上的用户数

[英]How to get user count on a EC2 Windows Instance AWS

I'm trying to incorporate some AWS features into my JSF application.我正在尝试将一些 AWS 功能合并到我的 JSF 应用程序中。 I have multiple EC2 instances running windows server, I would like to know how many windows users are connected to each instance and if they are actively using the system or not.我有多个运行 windows 服务器的 EC2 实例,我想知道有多少 windows 用户连接到每个实例,以及他们是否正在积极使用系统。

That info will be further used to create and terminate instances on the fly.该信息将进一步用于动态创建和终止实例。 I've tried using a ELB, but there is no metric for number of users connected and if they are active or not.我尝试过使用 ELB,但没有衡量连接的用户数量以及它们是否处于活动状态的指标。

Currently I'm using the Java AWS SDK 1.11.657 due to some application constraints.目前,由于某些应用程序限制,我正在使用 Java AWS SDK 1.11.657。 Given that I have a list of my instances and power to create and terminate them, how would I go about finding the number of users connected to each instance?鉴于我有一个实例列表以及创建和终止它们的能力,我将如何 go 查找连接到每个实例的用户数量? Did not find anything online using the Java SDK.使用 Java SDK 在网上没有找到任何东西。 Thank you.谢谢你。

You can use the Remote Desktop Services API/SDK or PowerShell cmdlet ( Get-RDUserSession ) to determine the count of active RDP sessions.您可以使用远程桌面服务 API/SDK 或 PowerShell cmdlet ( Get-RDUserSession ) 来确定活动 RDP 会话的计数。 There's also, allegedly, a more sophisticated cross-server PowerShell script .据称,还有一个更复杂的跨服务器 PowerShell 脚本

To remotely invoke PowerShell scripts on Windows instances, you can use SSM Run Command.要在 Windows 实例上远程调用 PowerShell 脚本,您可以使用 SSM 运行命令。 Here's an example of using the awscli to do this:这是使用awscli执行此操作的示例:

aws ssm send-command \
    --document-name "AWS-RunShellScript" \
    --comment "List Windows services" \
    --instance-ids "i-1234567890,i-0987654321" \
    --parameters commands="service --status-all" \
    --output text

Note that your Windows instances need to be set up in advance to support this so see this tutorial .请注意,您的 Windows 实例需要提前设置以支持此功能,请参阅本教程 It's likely Linux-oriented but hopefully this gets you started in the right direction.它可能是面向 Linux 的,但希望这能让您朝着正确的方向开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM