-2

I want to figure out the memory usage of 100 EC2 instances and the name of the scripts that are running in them (Probably push it to a DB).

Any ideas on how to do this the most efficient way in PHP or Java.

BantuRam
  • 1
  • 1
  • 2
  • Yes. Don't use either and use parallel ssh instead with a shell script. – David Hoelzer Jul 19 '17 at 15:06
  • Use this to programmatically connect to EC2 instances : https://stackoverflow.com/questions/19006555/ec2-connect-to-running-instance-by-using-the-api?rq=1 – worker_bee Jul 19 '17 at 15:40
  • 1
    If folks are interested in creating a venue for these types of questions, follow the proposal for a [dedicated Cloud Computing site on StackExchange](https://area51.stackexchange.com/proposals/110490/cloud-computing-aws-azure-google-openstack-etc?referrer=Gtut7wQSWPk88jFJz_zqMg2) and up-vote some sample questions. – John Rotenstein Jul 20 '17 at 00:53
  • Thanks @DavidHoelzer, trying to figure out something relevant. – BantuRam Jul 20 '17 at 04:32

1 Answers1

0

Rather than going out to 100 instances and doing stuff (which is hard to scale), you should have the instances automatically report this information to a central service.

For example, here is a Linux script that can measure memory and send the metrics back to Amazon CloudWatch: Monitoring Memory and Disk Metrics for Amazon EC2 Linux Instances

You could use a similar script to send your own metric to CloudWatch, particularly if it is a numeric answer.

However, if you do decide to centrally query each server for information, you should use the Systems Manager Run Command that can automatically execute scripts on multiple Amazon EC2 instances simultaneously.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • I do not want to play around with the instances as it is in production. This is a one time activity and thus looking for a quick script. But this is interesting, i'll look into it. – BantuRam Jul 20 '17 at 04:31