简体   繁体   中英

How to get user count on a EC2 Windows Instance AWS

I'm trying to incorporate some AWS features into my JSF application. 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.

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.

Currently I'm using the Java AWS SDK 1.11.657 due to some application constraints. 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? Did not find anything online using the 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. There's also, allegedly, a more sophisticated cross-server PowerShell script .

To remotely invoke PowerShell scripts on Windows instances, you can use SSM Run Command. Here's an example of using the awscli to do this:

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 . It's likely Linux-oriented but hopefully this gets you started in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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